This repository was archived by the owner on Oct 31, 2025. It is now read-only.
⚙️ ops(release.yml): enhance build process with debug info and cond…
#3
Workflow file for this run
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| name: Build and Release | |
| on: | |
| push: | |
| tags: | |
| - 'v*' | |
| jobs: | |
| build: | |
| name: Build and Release | |
| runs-on: ubuntu-latest | |
| permissions: | |
| contents: write | |
| steps: | |
| - name: Checkout code | |
| uses: actions/checkout@v3 | |
| - name: Set up Go | |
| uses: actions/setup-go@v4 | |
| with: | |
| go-version: '1.20' | |
| - name: Get tag version | |
| id: get_version | |
| run: echo "VERSION=${GITHUB_REF#refs/tags/}" >> $GITHUB_ENV | |
| - name: Set up build matrix | |
| id: setup_matrix | |
| run: | | |
| echo "matrix<<EOF" >> $GITHUB_OUTPUT | |
| cat << 'JSON_EOF' >> $GITHUB_OUTPUT | |
| [ | |
| {"GOOS": "linux", "GOARCH": "amd64", "extension": ""}, | |
| {"GOOS": "linux", "GOARCH": "arm64", "extension": ""}, | |
| {"GOOS": "darwin", "GOARCH": "amd64", "extension": ""}, | |
| {"GOOS": "darwin", "GOARCH": "arm64", "extension": ""}, | |
| {"GOOS": "windows", "GOARCH": "amd64", "extension": ".exe"} | |
| ] | |
| JSON_EOF | |
| echo "EOF" >> $GITHUB_OUTPUT | |
| - name: Build for multiple platforms | |
| id: build_release | |
| run: | | |
| mkdir -p release | |
| # For debugging | |
| echo "Matrix content: ${{ steps.setup_matrix.outputs.matrix }}" | |
| echo "${{ steps.setup_matrix.outputs.matrix }}" | jq -c '.[]' | while read -r os_arch; do | |
| GOOS=$(echo $os_arch | jq -r '.GOOS') | |
| GOARCH=$(echo $os_arch | jq -r '.GOARCH') | |
| EXT=$(echo $os_arch | jq -r '.extension') | |
| echo "Building for $GOOS/$GOARCH..." | |
| # Set environment variables for this build | |
| export GOOS=$GOOS | |
| export GOARCH=$GOARCH | |
| # Build the application | |
| output_name="neoprotect-notifier-$GOOS-$GOARCH$EXT" | |
| go build -v -o "release/$output_name" -ldflags="-X main.Version=${{ env.VERSION }}" | |
| # Create checksum without changing directories | |
| pushd release | |
| sha256sum "$output_name" > "${output_name}.sha256" | |
| popd | |
| done | |
| ls -la release/ | |
| - name: Prepare config.json.example | |
| run: | | |
| cat > release/config.json.example << 'EOF' | |
| { | |
| "apiKey": "your-neoprotect-api-key", | |
| "apiEndpoint": "https://api.neoprotect.net/v2", | |
| "pollIntervalSeconds": 60, | |
| "monitorMode": "all", | |
| "specificIPs": [ | |
| "192.168.1.1" | |
| ], | |
| "enabledIntegrations": [ | |
| "discord", | |
| "webhook", | |
| "console" | |
| ], | |
| "integrationConfigs": { | |
| "discord": { | |
| "webhookUrl": "https://discord.com/api/webhooks/YOUR/DISCORD/WEBHOOK", | |
| "username": "NeoProtect Monitor" | |
| }, | |
| "discord_bot": { | |
| "token": "YOUR_DISCORD_BOT_TOKEN", | |
| "clientId": "YOUR_DISCORD_CLIENT_ID", | |
| "guildId": "YOUR_DISCORD_GUILD_ID", | |
| "channelId": "YOUR_DISCORD_CHANNEL_ID" | |
| }, | |
| "webhook": { | |
| "url": "https://your-webhook-endpoint.com/notify", | |
| "headers": { | |
| "Authorization": "Bearer your-token-here", | |
| "Content-Type": "application/json" | |
| }, | |
| "timeout": 10 | |
| }, | |
| "console": { | |
| "logPrefix": "NEOPROTECT", | |
| "formatJson": false, | |
| "colorEnabled": true | |
| } | |
| } | |
| } | |
| EOF | |
| - name: Create archive files | |
| run: | | |
| ls -la release/ # Debug: list all files | |
| cd release | |
| # Create archives only if files exist | |
| for PLATFORM in linux-amd64 linux-arm64 darwin-amd64 darwin-arm64; do | |
| if [ -f "neoprotect-notifier-$PLATFORM" ] && [ -f "neoprotect-notifier-$PLATFORM.sha256" ]; then | |
| tar -czf "neoprotect-notifier-$PLATFORM.tar.gz" "neoprotect-notifier-$PLATFORM" "neoprotect-notifier-$PLATFORM.sha256" config.json.example | |
| else | |
| echo "Warning: Missing files for $PLATFORM" | |
| fi | |
| done | |
| # Windows archive | |
| if [ -f "neoprotect-notifier-windows-amd64.exe" ]; then | |
| apt-get update && apt-get install -y zip | |
| zip neoprotect-notifier-windows-amd64.zip neoprotect-notifier-windows-amd64.exe neoprotect-notifier-windows-amd64.exe.sha256 config.json.example | |
| fi | |
| - name: Create Release | |
| id: create_release | |
| uses: softprops/action-gh-release@v1 | |
| with: | |
| name: NeoProtect Notifier ${{ env.VERSION }} | |
| draft: false | |
| prerelease: false | |
| generate_release_notes: true | |
| files: | | |
| release/neoprotect-notifier-linux-amd64.tar.gz | |
| release/neoprotect-notifier-linux-arm64.tar.gz | |
| release/neoprotect-notifier-darwin-amd64.tar.gz | |
| release/neoprotect-notifier-darwin-arm64.tar.gz | |
| release/neoprotect-notifier-windows-amd64.zip | |
| env: | |
| GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} |