Merge pull request #9 from nathfavour/master #8
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 | |
| echo "Workspace: $GITHUB_WORKSPACE" | |
| ls -la $GITHUB_WORKSPACE | |
| mkdir -p dist | |
| # Explicitly set GOWORK | |
| export GOWORK=$GITHUB_WORKSPACE/go.work | |
| # Ensure workspace is synced | |
| go work sync | |
| platforms=( | |
| "linux/amd64" | |
| "linux/arm64" | |
| "darwin/amd64" | |
| "darwin/arm64" | |
| "windows/amd64" | |
| "windows/arm64" | |
| "android/arm64" | |
| ) | |
| for platform in "${platforms[@]}"; do | |
| 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..." | |
| CGO_ENABLED=0 GOOS=$GOOS GOARCH=$GOARCH go build -ldflags="-s -w" -trimpath -o "dist/$output_name" ./cmd/vibeaura | |
| done | |
| - 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 }} |