fix: semantic release #24
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 | |
| on: | |
| push: | |
| branches: [main, master] | |
| pull_request: | |
| branches: [main, master] | |
| workflow_dispatch: | |
| permissions: | |
| contents: write | |
| issues: write | |
| pull-requests: write | |
| jobs: | |
| test: | |
| name: Test | |
| runs-on: ubuntu-latest | |
| steps: | |
| - name: Checkout | |
| uses: actions/checkout@v4 | |
| - name: Setup Go | |
| uses: actions/setup-go@v5 | |
| with: | |
| go-version: '1.25' | |
| cache: true | |
| - name: Configure Go Toolchain | |
| run: go env -w GOTOOLCHAIN=go1.25.0+auto | |
| - name: Run tests | |
| env: | |
| GOTOOLCHAIN: go1.25.0+auto | |
| run: go test -v -race -coverprofile=coverage.txt -covermode=atomic ./... | |
| - name: Upload coverage | |
| uses: codecov/codecov-action@v4 | |
| with: | |
| files: ./coverage.txt | |
| fail_ci_if_error: false | |
| lint: | |
| name: Lint | |
| runs-on: ubuntu-latest | |
| steps: | |
| - name: Checkout | |
| uses: actions/checkout@v4 | |
| - name: Setup Go | |
| uses: actions/setup-go@v5 | |
| with: | |
| go-version: '1.25' | |
| cache: true | |
| - name: Configure Go Toolchain | |
| run: go env -w GOTOOLCHAIN=go1.25.0+auto | |
| - name: golangci-lint | |
| uses: golangci/golangci-lint-action@v9 | |
| with: | |
| version: v2.8.0 | |
| build: | |
| name: Build | |
| runs-on: ${{ matrix.os }} | |
| needs: [test, lint] | |
| strategy: | |
| matrix: | |
| include: | |
| - os: ubuntu-latest | |
| targets: | | |
| linux/amd64 | |
| linux/arm64 | |
| - os: macos-latest | |
| targets: | | |
| darwin/amd64 | |
| darwin/arm64 | |
| windows/amd64 | |
| steps: | |
| - name: Checkout | |
| uses: actions/checkout@v4 | |
| - name: Setup Go | |
| uses: actions/setup-go@v5 | |
| with: | |
| go-version: '1.25' | |
| cache: true | |
| - name: Configure Go Toolchain | |
| run: go env -w GOTOOLCHAIN=go1.25.0+auto | |
| - name: Build all targets | |
| env: | |
| CGO_ENABLED: 0 | |
| GOTOOLCHAIN: go1.25.0+auto | |
| run: | | |
| VERSION="${{ github.ref_name }}" | |
| if [ "${{ github.event_name }}" = "pull_request" ]; then | |
| VERSION="pr-${{ github.event.pull_request.number }}" | |
| fi | |
| echo "${{ matrix.targets }}" | while IFS= read -r target; do | |
| if [ -z "$target" ]; then | |
| continue | |
| fi | |
| IFS='/' read -r goos goarch <<< "$target" | |
| suffix="" | |
| if [ "$goos" = "windows" ]; then | |
| suffix=".exe" | |
| fi | |
| echo "Building $goos/$goarch..." | |
| GOOS=$goos GOARCH=$goarch go build -ldflags="-s -w -X main.version=${VERSION}" -o ggo-$goos-$goarch$suffix ./cmd/ggo | |
| done | |
| - name: Upload artifacts | |
| uses: actions/upload-artifact@v4 | |
| with: | |
| name: ggo-${{ matrix.os }} | |
| path: | | |
| ggo-* | |
| if-no-files-found: error | |
| - name: Prepare binaries for Cloudflare R2 upload | |
| if: matrix.os == 'ubuntu-latest' && github.event_name == 'push' && github.ref == 'refs/heads/main' | |
| run: | | |
| mkdir -p temp-upload | |
| cp ggo-linux-amd64 temp-upload/gpugo-linux-amd64 | |
| cp ggo-linux-arm64 temp-upload/gpugo-linux-arm64 | |
| - name: Prepare install.sh for Cloudflare R2 upload | |
| if: matrix.os == 'ubuntu-latest' && github.event_name == 'push' && github.ref == 'refs/heads/main' | |
| run: | | |
| mkdir -p install-upload | |
| cp install.sh install-upload/install.sh | |
| - name: Upload Latest Binary to Cloudflare R2 | |
| if: matrix.os == 'ubuntu-latest' && github.event_name == 'push' && github.ref == 'refs/heads/main' | |
| uses: ryand56/r2-upload-action@latest | |
| with: | |
| r2-account-id: ${{ secrets.R2_ACCOUNT_ID }} | |
| r2-access-key-id: ${{ secrets.R2_ACCESS_KEY_ID }} | |
| r2-secret-access-key: ${{ secrets.R2_SECRET_ACCESS_KEY }} | |
| r2-bucket: "cuda-fusion-libs" | |
| source-dir: temp-upload | |
| destination-dir: ./archive/gpugo/latest/ | |
| keep-file-fresh: true | |
| - name: Upload install.sh to Cloudflare R2 | |
| if: matrix.os == 'ubuntu-latest' && github.event_name == 'push' && github.ref == 'refs/heads/main' | |
| uses: ryand56/r2-upload-action@latest | |
| with: | |
| r2-account-id: ${{ secrets.R2_ACCOUNT_ID }} | |
| r2-access-key-id: ${{ secrets.R2_ACCESS_KEY_ID }} | |
| r2-secret-access-key: ${{ secrets.R2_SECRET_ACCESS_KEY }} | |
| r2-bucket: "cuda-fusion-libs" | |
| source-dir: install-upload | |
| destination-dir: ./archive/gpugo/ | |
| keep-file-fresh: true | |
| semantic-release: | |
| name: Semantic Release | |
| runs-on: ubuntu-latest | |
| needs: build | |
| if: github.event_name == 'push' && github.ref == 'refs/heads/main' | |
| outputs: | |
| published: ${{ steps.semantic.outputs.new_release_published }} | |
| version: ${{ steps.semantic.outputs.new_release_version }} | |
| tag: ${{ steps.semantic.outputs.new_release_git_tag }} | |
| steps: | |
| - name: Checkout | |
| uses: actions/checkout@v4 | |
| with: | |
| fetch-depth: 0 | |
| persist-credentials: false | |
| - name: Setup Node.js | |
| uses: actions/setup-node@v4 | |
| with: | |
| node-version: 'lts/*' | |
| - name: Semantic Release | |
| id: semantic | |
| uses: cycjimmy/semantic-release-action@v4 | |
| with: | |
| extra_plugins: | | |
| @semantic-release/release-notes-generator | |
| @semantic-release/github | |
| @semantic-release/git | |
| env: | |
| GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} | |
| release: | |
| name: Release | |
| runs-on: ubuntu-latest | |
| needs: semantic-release | |
| if: needs.semantic-release.outputs.published == 'true' | |
| steps: | |
| - name: Checkout | |
| uses: actions/checkout@v4 | |
| - name: Setup Go | |
| uses: actions/setup-go@v5 | |
| with: | |
| go-version: '1.25' | |
| cache: true | |
| - name: Configure Go Toolchain | |
| run: go env -w GOTOOLCHAIN=go1.25.0+auto | |
| - name: Build versioned binaries | |
| env: | |
| CGO_ENABLED: 0 | |
| GOTOOLCHAIN: go1.25.0+auto | |
| run: | | |
| VERSION="${{ needs.semantic-release.outputs.version }}" | |
| mkdir -p release | |
| # Linux amd64 | |
| GOOS=linux GOARCH=amd64 go build -ldflags="-s -w -X main.version=v${VERSION}" -o release/ggo-linux-amd64 ./cmd/ggo | |
| # Linux arm64 | |
| GOOS=linux GOARCH=arm64 go build -ldflags="-s -w -X main.version=v${VERSION}" -o release/ggo-linux-arm64 ./cmd/ggo | |
| # Darwin amd64 | |
| GOOS=darwin GOARCH=amd64 go build -ldflags="-s -w -X main.version=v${VERSION}" -o release/ggo-darwin-amd64 ./cmd/ggo | |
| # Darwin arm64 | |
| GOOS=darwin GOARCH=arm64 go build -ldflags="-s -w -X main.version=v${VERSION}" -o release/ggo-darwin-arm64 ./cmd/ggo | |
| # Windows amd64 | |
| GOOS=windows GOARCH=amd64 go build -ldflags="-s -w -X main.version=v${VERSION}" -o release/ggo-windows-amd64.exe ./cmd/ggo | |
| # Generate checksums | |
| cd release | |
| for f in ggo-*; do | |
| sha256sum "$f" > "$f.sha256" | |
| done | |
| ls -la | |
| - name: Upload release assets | |
| uses: softprops/action-gh-release@v2 | |
| with: | |
| tag_name: ${{ needs.semantic-release.outputs.tag }} | |
| files: release/* | |
| draft: false | |
| prerelease: false | |
| env: | |
| GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} | |
| - name: Prepare versioned binaries for R2 upload | |
| run: | | |
| mkdir -p r2-upload | |
| cp release/ggo-linux-amd64 r2-upload/gpugo-linux-amd64 | |
| cp release/ggo-linux-arm64 r2-upload/gpugo-linux-arm64 | |
| - name: Upload Versioned Binary to Cloudflare R2 | |
| uses: ryand56/r2-upload-action@latest | |
| with: | |
| r2-account-id: ${{ secrets.R2_ACCOUNT_ID }} | |
| r2-access-key-id: ${{ secrets.R2_ACCESS_KEY_ID }} | |
| r2-secret-access-key: ${{ secrets.R2_SECRET_ACCESS_KEY }} | |
| r2-bucket: "cuda-fusion-libs" | |
| source-dir: r2-upload | |
| destination-dir: ./archive/gpugo/v${{ needs.semantic-release.outputs.version }}/ |