Skip to content

Commit dbd7304

Browse files
prog-supdexpalkan
authored andcommitted
ci: Add workflow to build and release Pro binaries
(cherry picked from commit 434cd71086d7d655e70475eeacc5224c8764981c)
1 parent 58161a1 commit dbd7304

1 file changed

Lines changed: 102 additions & 0 deletions

File tree

.github/workflows/release.yml

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

0 commit comments

Comments
 (0)