Skip to content

feat: add automated cross-platform binary builds and releases #2

feat: add automated cross-platform binary builds and releases

feat: add automated cross-platform binary builds and releases #2

Workflow file for this run

name: Build Binaries
on:
push:
branches: [ main ]
pull_request:
branches: [ main ]
jobs:
build:
name: Build Cross-Platform Binaries
runs-on: ubuntu-latest
strategy:
matrix:
include:
# Linux builds
- goos: linux
goarch: amd64
name: jail-linux-amd64
- goos: linux
goarch: arm64
name: jail-linux-arm64
# macOS builds
- goos: darwin
goarch: amd64
name: jail-darwin-amd64
- goos: darwin
goarch: arm64
name: jail-darwin-arm64
steps:
- name: Check out code
uses: actions/checkout@v4
- name: Set up Go
uses: actions/setup-go@v5
with:
go-version: '1.25'
check-latest: true
- name: Cache Go modules
uses: actions/cache@v4
with:
path: |
~/.cache/go-build
~/go/pkg/mod
key: ${{ runner.os }}-go-${{ hashFiles('**/go.sum') }}
restore-keys: |
${{ runner.os }}-go-
- name: Download dependencies
run: go mod download
- name: Build binary
env:
GOOS: ${{ matrix.goos }}
GOARCH: ${{ matrix.goarch }}
CGO_ENABLED: 0
run: |
# Add version info if available
VERSION="dev-${{ github.sha }}"
if [ "${{ github.ref_type }}" = "tag" ]; then
VERSION="${{ github.ref_name }}"
fi
go build -ldflags="-s -w -X main.version=$VERSION" -o ${{ matrix.name }} .
- name: Upload binary as artifact
uses: actions/upload-artifact@v4
with:
name: ${{ matrix.name }}
path: ${{ matrix.name }}
retention-days: 30
summary:
name: Build Summary
needs: build
runs-on: ubuntu-latest
if: always()
steps:
- name: Build Summary
run: |
echo "## πŸ› οΈ Build Summary" >> $GITHUB_STEP_SUMMARY
echo "" >> $GITHUB_STEP_SUMMARY
echo "Cross-platform binaries have been built and are available as artifacts." >> $GITHUB_STEP_SUMMARY
echo "" >> $GITHUB_STEP_SUMMARY
echo "### πŸ“¦ Available Binaries" >> $GITHUB_STEP_SUMMARY
echo "" >> $GITHUB_STEP_SUMMARY
echo "- 🐧 **Linux (x64)**: jail-linux-amd64" >> $GITHUB_STEP_SUMMARY
echo "- 🐧 **Linux (ARM64)**: jail-linux-arm64" >> $GITHUB_STEP_SUMMARY
echo "- 🍎 **macOS (Intel)**: jail-darwin-amd64" >> $GITHUB_STEP_SUMMARY
echo "- 🍎 **macOS (Apple Silicon)**: jail-darwin-arm64" >> $GITHUB_STEP_SUMMARY
echo "" >> $GITHUB_STEP_SUMMARY
echo "### πŸ“Ž Download Instructions" >> $GITHUB_STEP_SUMMARY
echo "" >> $GITHUB_STEP_SUMMARY
echo "1. Go to the **Actions** tab" >> $GITHUB_STEP_SUMMARY
echo "2. Click on this workflow run" >> $GITHUB_STEP_SUMMARY
echo "3. Scroll down to **Artifacts** section" >> $GITHUB_STEP_SUMMARY
echo "4. Download the binary for your platform" >> $GITHUB_STEP_SUMMARY