|
| 1 | +name: release |
| 2 | +on: |
| 3 | + release: |
| 4 | + types: [published] |
| 5 | + workflow_dispatch: |
| 6 | + pull_request: |
| 7 | + |
| 8 | +permissions: |
| 9 | + contents: write |
| 10 | + |
| 11 | +jobs: |
| 12 | + build: |
| 13 | + env: |
| 14 | + # check only direct github for anycable dependencies |
| 15 | + GOPRIVATE: github.com/anycable/* |
| 16 | + GONOSUMDB: github.com/anycable/* |
| 17 | + runs-on: ubuntu-latest |
| 18 | + strategy: |
| 19 | + matrix: |
| 20 | + goos: [ linux, darwin ] |
| 21 | + goarch: [ amd64, arm64 ] |
| 22 | + steps: |
| 23 | + - name: Checkout repository code |
| 24 | + uses: actions/checkout@v4 |
| 25 | + |
| 26 | + - name: Setup golang |
| 27 | + uses: actions/setup-go@v5 |
| 28 | + with: |
| 29 | + go-version-file: go.mod |
| 30 | + |
| 31 | + - name: Get AnyCable version |
| 32 | + id: anycable |
| 33 | + run: | |
| 34 | + set -euo pipefail |
| 35 | + ver="$(grep -E '^\s*github\.com/anycable/anycable-go\s+v[0-9A-Za-z\.\-\+]+' go.mod | awk '{print $2}')" |
| 36 | + test -n "$ver" |
| 37 | + echo "version=$ver" >> "$GITHUB_OUTPUT" |
| 38 | +
|
| 39 | + - name: Replace dependency with Pro version with auth |
| 40 | + env: |
| 41 | + GH_PAT: ${{ secrets.GH_PAT }} |
| 42 | + run: | |
| 43 | + set -euxo pipefail |
| 44 | + git config --global url."https://x-access-token:${GH_PAT}@github.com/".insteadOf "https://github.com/" |
| 45 | +
|
| 46 | + go mod edit -dropreplace=github.com/anycable/anycable-go || true |
| 47 | + go mod edit -replace=github.com/anycable/anycable-go=github.com/anycable/anycable-pro-source-releases@${{ steps.anycable.outputs.version }} |
| 48 | +
|
| 49 | + go env GOPRIVATE GONOSUMDB GOPROXY GOSUMDB |
| 50 | + go mod tidy |
| 51 | +
|
| 52 | + - name: Download and vendor all dependencies |
| 53 | + run: | |
| 54 | + set -euxo pipefail |
| 55 | + go mod vendor |
| 56 | +
|
| 57 | + # for test/debug purpose: will be removed |
| 58 | + - name: Checks that module shows to Pro |
| 59 | + run: | |
| 60 | + set -euxo pipefail |
| 61 | + go list -m -json github.com/anycable/anycable-go |
| 62 | +
|
| 63 | + - name: Build ${{ matrix.goos }}/${{ matrix.goarch }} |
| 64 | + env: |
| 65 | + CGO_ENABLED: 0 |
| 66 | + GOOS: ${{ matrix.goos }} |
| 67 | + GOARCH: ${{ matrix.goarch }} |
| 68 | + run: | |
| 69 | + mkdir -p dist |
| 70 | + go build -mod=vendor -trimpath -ldflags "-s -w" \ |
| 71 | + -o "dist/anycable-thruster-${{ matrix.goos }}-${{ matrix.goarch }}" ./cmd/thrust |
| 72 | + chmod +x "dist/anycable-thruster-${{ matrix.goos }}-${{ matrix.goarch }}" |
| 73 | +
|
| 74 | + - name: Upload artifacts |
| 75 | + uses: actions/upload-artifact@v4 |
| 76 | + with: |
| 77 | + name: dist-${{ matrix.goos }}-${{ matrix.goarch }} |
| 78 | + path: dist/* |
| 79 | + if-no-files-found: error |
| 80 | + |
| 81 | + publish: |
| 82 | + runs-on: ubuntu-latest |
| 83 | + needs: build |
| 84 | + if: ${{ github.event_name == 'release' }} |
| 85 | + steps: |
| 86 | + - name: Download all artifacts |
| 87 | + uses: actions/download-artifact@v4 |
| 88 | + with: |
| 89 | + pattern: dist-* |
| 90 | + merge-multiple: true |
| 91 | + path: dist |
| 92 | + |
| 93 | + # for test/debug purpose: will be removed |
| 94 | + - name: Show built artifacts |
| 95 | + run: | |
| 96 | + set -euxo pipefail |
| 97 | + ls -lah dist |
| 98 | +
|
| 99 | + - name: Upload to release (once) |
| 100 | + uses: softprops/action-gh-release@v2 |
| 101 | + with: |
| 102 | + files: | |
| 103 | + dist/anycable-thruster-* |
0 commit comments