Build #228
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: | |
| pull_request: | |
| workflow_dispatch: | |
| permissions: | |
| contents: write | |
| issues: write | |
| pull-requests: write | |
| env: | |
| VERSION_PKG: github.com/NexusGPU/gpu-go/cmd/ggo/version | |
| 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 | |
| semantic-release: | |
| name: Semantic Release | |
| runs-on: ubuntu-latest | |
| needs: [test, lint] | |
| if: github.event_name == 'workflow_dispatch' | |
| 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 }} | |
| # Only runs when semantic-release publishes a new version | |
| release: | |
| name: Build & Release | |
| runs-on: ubuntu-latest | |
| needs: semantic-release | |
| if: needs.semantic-release.outputs.published == 'true' && github.event_name == 'workflow_dispatch' | |
| 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 platform binaries | |
| env: | |
| CGO_ENABLED: 0 | |
| GOTOOLCHAIN: go1.25.0+auto | |
| run: | | |
| VERSION="v${{ needs.semantic-release.outputs.version }}" | |
| COMMIT="${{ github.sha }}" | |
| BUILD_DATE="$(date -u +"%Y-%m-%dT%H:%M:%SZ")" | |
| LDFLAGS="-s -w -X ${VERSION_PKG}.Version=${VERSION} -X ${VERSION_PKG}.Commit=${COMMIT:0:7} -X ${VERSION_PKG}.BuildDate=${BUILD_DATE}" | |
| mkdir -p release | |
| GOOS=linux GOARCH=amd64 go build -ldflags="${LDFLAGS}" -o release/ggo-linux-amd64 ./cmd/ggo | |
| GOOS=linux GOARCH=arm64 go build -ldflags="${LDFLAGS}" -o release/ggo-linux-arm64 ./cmd/ggo | |
| GOOS=darwin GOARCH=amd64 go build -ldflags="${LDFLAGS}" -o release/ggo-darwin-amd64 ./cmd/ggo | |
| GOOS=darwin GOARCH=arm64 go build -ldflags="${LDFLAGS}" -o release/ggo-darwin-arm64 ./cmd/ggo | |
| GOOS=windows GOARCH=amd64 go build -ldflags="${LDFLAGS}" -o release/ggo-windows-amd64.exe ./cmd/ggo | |
| cd release && for f in ggo-*; do sha256sum "$f" > "$f.sha256"; done | |
| ls -la | |
| - name: Upload release assets to GitHub | |
| 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 CDN binaries | |
| run: | | |
| mkdir -p cdn-binaries | |
| cp release/ggo-linux-amd64 cdn-binaries/gpugo-amd64 | |
| cp release/ggo-linux-arm64 cdn-binaries/gpugo-arm64 | |
| cp release/ggo-darwin-amd64 cdn-binaries/gpugo-darwin-amd64 | |
| cp release/ggo-darwin-arm64 cdn-binaries/gpugo-darwin-arm64 | |
| cp release/ggo-windows-amd64.exe cdn-binaries/gpugo-windows-amd64.exe | |
| cd cdn-binaries && for f in gpugo-*; do sha256sum "$f" > "$f.sha256"; done | |
| - name: Prepare install scripts | |
| run: | | |
| mkdir -p cdn-scripts | |
| cp scripts/install.sh scripts/install.ps1 scripts/install.bat cdn-scripts/ | |
| cp scripts/uninstall.sh scripts/uninstall.ps1 scripts/uninstall.bat cdn-scripts/ | |
| - name: Upload to R2 (latest) | |
| 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: cdn-binaries | |
| destination-dir: ./archive/gpugo/latest/ | |
| keep-file-fresh: true | |
| - name: Upload to R2 (versioned) | |
| 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: cdn-binaries | |
| destination-dir: ./archive/gpugo/v${{ needs.semantic-release.outputs.version }}/ | |
| - name: Upload scripts to 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: cdn-scripts | |
| destination-dir: ./archive/gpugo/ | |
| keep-file-fresh: true |