forked from latentsignal-org/periscope
-
Notifications
You must be signed in to change notification settings - Fork 0
288 lines (247 loc) · 9.43 KB
/
Copy pathrelease.yml
File metadata and controls
288 lines (247 loc) · 9.43 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
name: Release
on:
push:
tags:
- 'v*'
permissions:
contents: read
jobs:
build-linux:
strategy:
fail-fast: false
matrix:
include:
- goarch: amd64
runner: ubuntu-latest
container: quay.io/pypa/manylinux_2_28_x86_64@sha256:853663dc8253b62be437bb52a5caecffd020792af4442f55d927d22e0ea795ae
- goarch: arm64
runner: ubuntu-24.04-arm
container: quay.io/pypa/manylinux_2_28_aarch64@sha256:ca1f9d96910e129d38f999644a1f211a6cdb4147da9f19157a49d72c5092453a
runs-on: ${{ matrix.runner }}
container: ${{ matrix.container }}
steps:
- uses: actions/checkout@de0fac2e4500dabe0009e67214ff5f5447ce83dd # v6.0.2
with:
persist-credentials: false
- uses: actions/setup-go@4a3601121dd01d1626a1e23e37211e3254c1c06c # v6.4.0
with:
go-version-file: go.mod
- uses: actions/setup-node@48b55a011bda9f5d6aeb4c2d9c7362e8dae4041e # v6.4.0
with:
node-version: "24"
- name: Build frontend
run: npm ci && npm run build
working-directory: frontend
- name: Embed frontend
shell: bash
run: |
rm -rf internal/web/dist
cp -r frontend/dist internal/web/dist
- name: Build
shell: bash
env:
GOOS: linux
GOARCH: ${{ matrix.goarch }}
CGO_ENABLED: "1"
run: |
VERSION=${GITHUB_REF#refs/tags/v}
COMMIT=${GITHUB_SHA::8}
BUILD_DATE=$(date -u +"%Y-%m-%dT%H:%M:%SZ")
mkdir -p dist
LDFLAGS="-s -w -X main.version=v${VERSION} -X main.commit=${COMMIT} -X main.buildDate=${BUILD_DATE}"
go build -tags fts5 -buildvcs=false -ldflags="$LDFLAGS" -trimpath \
-o dist/periscope ./cmd/periscope
# Smoke test (native builds — no cross-compilation)
./dist/periscope --version
# Verify glibc compatibility
MAX_GLIBC="GLIBC_2.28"
HIGHEST=$(objdump -T dist/periscope | grep -oP 'GLIBC_\d+\.\d+' | sort -t. -k1,1n -k2,2n | tail -1)
echo "Highest glibc symbol: $HIGHEST (max allowed: $MAX_GLIBC)"
if [ "$(printf '%s\n%s' "$MAX_GLIBC" "$HIGHEST" | sort -t. -k1,1n -k2,2n | tail -1)" != "$MAX_GLIBC" ]; then
echo "ERROR: Binary requires $HIGHEST but wheel claims $MAX_GLIBC"
exit 1
fi
cd dist
ARCHIVE="periscope_${VERSION}_linux_${{ matrix.goarch }}.tar.gz"
tar czf "$ARCHIVE" periscope
rm periscope
- uses: actions/upload-artifact@043fb46d1a93c77aae656e7c1c64a875d1fc6a0a # v7.0.1
with:
name: periscope-linux-${{ matrix.goarch }}
path: dist/*.tar.gz
build:
strategy:
fail-fast: false
matrix:
include:
- os: macos-15
goos: darwin
goarch: amd64
- os: macos-15
goos: darwin
goarch: arm64
- os: windows-latest
goos: windows
goarch: amd64
runs-on: ${{ matrix.os }}
steps:
- uses: actions/checkout@de0fac2e4500dabe0009e67214ff5f5447ce83dd # v6.0.2
with:
persist-credentials: false
- uses: actions/setup-go@4a3601121dd01d1626a1e23e37211e3254c1c06c # v6.4.0
with:
go-version-file: go.mod
- uses: actions/setup-node@48b55a011bda9f5d6aeb4c2d9c7362e8dae4041e # v6.4.0
with:
node-version: "24"
- name: Build frontend
run: npm ci && npm run build
working-directory: frontend
- name: Embed frontend
shell: bash
run: |
rm -rf internal/web/dist
cp -r frontend/dist internal/web/dist
- name: Setup MinGW (Windows)
if: matrix.goos == 'windows'
uses: msys2/setup-msys2@e9898307ac31d1a803454791be09ab9973336e1c # v2
with:
msystem: MINGW64
update: false
install: mingw-w64-x86_64-gcc
path-type: inherit
- name: Build
shell: bash
env:
GOOS: ${{ matrix.goos }}
GOARCH: ${{ matrix.goarch }}
CGO_ENABLED: "1"
MACOSX_DEPLOYMENT_TARGET: ${{ matrix.goos == 'darwin' && '11.0' || '' }}
run: |
VERSION=${GITHUB_REF#refs/tags/v}
COMMIT=${GITHUB_SHA::8}
BUILD_DATE=$(date -u +"%Y-%m-%dT%H:%M:%SZ")
EXT=""
if [ "$GOOS" = "windows" ]; then EXT=".exe"; fi
mkdir -p dist
LDFLAGS="-s -w -X main.version=v${VERSION} -X main.commit=${COMMIT} -X main.buildDate=${BUILD_DATE}"
go build -tags fts5 -ldflags="$LDFLAGS" -trimpath \
-o dist/periscope${EXT} ./cmd/periscope
# Smoke test (skip cross-compiled darwin/amd64 on ARM runner)
if [ "$GOARCH" = "$(go env GOHOSTARCH)" ]; then
./dist/periscope${EXT} --version
fi
# Verify macOS deployment target
if [ "$GOOS" = "darwin" ]; then
MINOS=$(otool -l dist/periscope | grep -A3 LC_BUILD_VERSION | grep minos | awk '{print $2}')
echo "Minimum macOS version: $MINOS"
if [ "$MINOS" != "11.0" ]; then
echo "ERROR: Expected minos 11.0, got $MINOS"
exit 1
fi
fi
cd dist
if [ "$GOOS" = "windows" ]; then
ARCHIVE="periscope_${VERSION}_${{ matrix.goos }}_${{ matrix.goarch }}.zip"
7z a "$ARCHIVE" periscope${EXT}
else
ARCHIVE="periscope_${VERSION}_${{ matrix.goos }}_${{ matrix.goarch }}.tar.gz"
tar czf "$ARCHIVE" periscope${EXT}
fi
rm periscope${EXT}
- uses: actions/upload-artifact@043fb46d1a93c77aae656e7c1c64a875d1fc6a0a # v7.0.1
with:
name: periscope-${{ matrix.goos }}-${{ matrix.goarch }}
path: |
dist/*.tar.gz
dist/*.zip
release:
needs: [build-linux, build]
runs-on: ubuntu-latest
permissions:
contents: write
steps:
- uses: actions/checkout@de0fac2e4500dabe0009e67214ff5f5447ce83dd # v6.0.2
with:
persist-credentials: false
- uses: actions/download-artifact@3e5f45b2cfb9172054b4087a40e8e0b5a5461e7c # v8.0.1
with:
path: artifacts
merge-multiple: true
- name: Generate checksums
run: |
cd artifacts
sha256sum *.tar.gz *.zip > SHA256SUMS
cat SHA256SUMS
- name: Get tag message
id: tag_message
run: |
TAG_NAME="${GITHUB_REF#refs/tags/}"
TAG_TYPE=$(git cat-file -t "$TAG_NAME")
if [ "$TAG_TYPE" != "tag" ]; then
echo "Warning: $TAG_NAME is a lightweight tag, using auto-generated notes"
echo "has_body=false" >> $GITHUB_OUTPUT
exit 0
fi
TAG_MSG=$(git tag -l --format='%(contents:body)' "$TAG_NAME")
if [ -n "$TAG_MSG" ]; then
DELIM="TAGMSG_$(date +%s%N)"
echo "body<<$DELIM" >> $GITHUB_OUTPUT
echo "$TAG_MSG" >> $GITHUB_OUTPUT
echo "$DELIM" >> $GITHUB_OUTPUT
echo "has_body=true" >> $GITHUB_OUTPUT
else
echo "has_body=false" >> $GITHUB_OUTPUT
fi
- name: Create Release
uses: softprops/action-gh-release@b4309332981a82ec1c5618f44dd2e27cc8bfbfda # v3.0.0
with:
files: |
artifacts/*.tar.gz
artifacts/*.zip
artifacts/SHA256SUMS
body: ${{ steps.tag_message.outputs.has_body == 'true' && steps.tag_message.outputs.body || '' }}
generate_release_notes: ${{ steps.tag_message.outputs.has_body != 'true' }}
pypi:
# Disabled by default — the 'periscope' package name on PyPI is taken by an unrelated
# project (Patrick Dessalle, v0.2.4). To enable: set the ENABLE_PYPI_PUBLISH repo
# variable to 'true' AND configure an OIDC Trusted Publisher at pypi.org with:
# project name: <your-package-name>, owner: diazMelgarejo, repo: periscope,
# workflow: release.yml, environment: pypi
if: vars.ENABLE_PYPI_PUBLISH == 'true'
needs: [build-linux, build, release]
runs-on: ubuntu-latest
environment: pypi
permissions:
contents: read
id-token: write
steps:
- uses: actions/checkout@de0fac2e4500dabe0009e67214ff5f5447ce83dd # v6.0.2
with:
persist-credentials: false
- uses: actions/setup-python@a309ff8b426b58ec0e2a45f0f869d46889d02405 # v6.2.0
with:
python-version: "3.12"
- uses: actions/download-artifact@3e5f45b2cfb9172054b4087a40e8e0b5a5461e7c # v8.0.1
with:
path: artifacts
merge-multiple: true
- name: Build wheels
run: |
VERSION=${GITHUB_REF#refs/tags/v}
python scripts/build_wheels.py \
--version "$VERSION" \
--input-dir artifacts \
--output-dir wheels \
--readme README.md \
--require-all
- name: Smoke test wheel
run: |
VERSION=${GITHUB_REF#refs/tags/v}
WHL_VERSION=$(python3 -c "import re,sys; v='${VERSION}'; m=re.match(r'^(\d+\.\d+\.\d+)-(.+)$',v); print(m.group(1)+'+'+m.group(2).replace('-','.')if m else v)")
pip install "wheels/periscope-${WHL_VERSION}-py3-none-manylinux_2_28_x86_64.whl"
periscope --version
- name: Publish to PyPI
uses: pypa/gh-action-pypi-publish@cef221092ed1bacb1cc03d23a2d87d1d172e277b # v1.14.0
with:
packages-dir: wheels/