This repository was archived by the owner on Oct 31, 2025. It is now read-only.
π refactor(release.yml): streamline build matrix setup
#4
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: Build for multiple platforms | |
| id: build_release | |
| run: | | |
| mkdir -p release | |
| # Define platforms array directly in bash | |
| platforms=( | |
| "linux,amd64," | |
| "linux,arm64," | |
| "darwin,amd64," | |
| "darwin,arm64," | |
| "windows,amd64,.exe" | |
| ) | |
| # Loop through platforms | |
| for platform in "${platforms[@]}"; do | |
| IFS=',' read -r GOOS GOARCH EXT <<< "$platform" | |
| 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 | |
| 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: | | |
| cd release | |
| # Create archives for Unix platforms | |
| for PLATFORM in linux-amd64 linux-arm64 darwin-amd64 darwin-arm64; do | |
| if [ -f "neoprotect-notifier-$PLATFORM" ] && [ -f "neoprotect-notifier-$PLATFORM.sha256" ]; then | |
| echo "Creating archive for $PLATFORM" | |
| 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 | |
| echo "Creating archive for windows-amd64" | |
| 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 | |
| else | |
| echo "Warning: Missing files for windows-amd64" | |
| fi | |
| # List created archives | |
| echo "Created archives:" | |
| ls -la *.tar.gz *.zip 2>/dev/null || echo "No archives created" | |
| - 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 }} |