Merge pull request #4 from nathfavour/master #3
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: Release | |
| on: | |
| push: | |
| branches: | |
| - release | |
| tags: | |
| - 'v*' | |
| permissions: | |
| contents: write | |
| jobs: | |
| release: | |
| name: Build and Release | |
| runs-on: ubuntu-latest | |
| steps: | |
| - name: Checkout code | |
| uses: actions/checkout@v4 | |
| with: | |
| fetch-depth: 0 | |
| - name: Set up Go | |
| uses: actions/setup-go@v5 | |
| with: | |
| go-version: '1.24' | |
| cache: true | |
| cache-dependency-path: "**/*.sum" | |
| - name: Get Go cache paths | |
| id: go-cache-paths | |
| run: | | |
| echo "go-build=$(go env GOCACHE)" >> $GITHUB_OUTPUT | |
| echo "go-mod=$(go env GOMODCACHE)" >> $GITHUB_OUTPUT | |
| - name: Cache Go build | |
| uses: actions/cache@v4 | |
| with: | |
| path: | | |
| ${{ steps.go-cache-paths.outputs.go-build }} | |
| ${{ steps.go-cache-paths.outputs.go-mod }} | |
| key: ${{ runner.os }}-go-${{ hashFiles('**/go.sum', 'go.work') }} | |
| restore-keys: | | |
| ${{ runner.os }}-go- | |
| - name: Build binaries | |
| run: | | |
| set -e | |
| mkdir -p dist | |
| platforms=( | |
| "linux/amd64" | |
| "linux/arm64" | |
| "darwin/amd64" | |
| "darwin/arm64" | |
| "windows/amd64" | |
| "windows/arm64" | |
| "android/arm64" | |
| ) | |
| pids=() | |
| for platform in "${platforms[@]}"; do | |
| ( | |
| set -e | |
| platform_split=(${platform//\// }) | |
| GOOS=${platform_split[0]} | |
| GOARCH=${platform_split[1]} | |
| output_name="vibeaura-${GOOS}-${GOARCH}" | |
| if [ "$GOOS" == "windows" ]; then | |
| output_name+=".exe" | |
| fi | |
| echo "Building for $GOOS/$GOARCH..." | |
| GOWORK=$GITHUB_WORKSPACE/go.work CGO_ENABLED=0 GOOS=$GOOS GOARCH=$GOARCH go build -ldflags="-s -w" -trimpath -o "dist/$output_name" ./cmd/vibeaura | |
| ) & | |
| pids+=($!) | |
| done | |
| # Wait for all builds and collect exit codes | |
| exit_code=0 | |
| for pid in "${pids[@]}"; do | |
| wait $pid || exit_code=1 | |
| done | |
| if [ $exit_code -ne 0 ]; then | |
| echo "One or more builds failed" | |
| exit 1 | |
| fi | |
| - name: Create Release | |
| uses: softprops/action-gh-release@v2 | |
| if: startsWith(github.ref, 'refs/tags/') || github.ref == 'refs/heads/release' | |
| with: | |
| files: dist/* | |
| tag_name: ${{ github.ref_name == 'release' && format('latest-{0}', github.sha) || github.ref_name }} | |
| name: ${{ github.ref_name == 'release' && format('Release (latest-{0})', github.sha) || github.ref_name }} | |
| generate_release_notes: true | |
| draft: false | |
| prerelease: ${{ github.ref == 'refs/heads/release' }} | |
| env: | |
| GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} |