-
Notifications
You must be signed in to change notification settings - Fork 4
350 lines (295 loc) · 10.1 KB
/
Copy pathrelease.yml
File metadata and controls
350 lines (295 loc) · 10.1 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
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
name: Release
on:
push:
tags:
- "v*"
permissions:
contents: write
env:
CARGO_TERM_COLOR: always
jobs:
build:
name: Build ${{ matrix.target }}
runs-on: ${{ matrix.runner }}
strategy:
fail-fast: false
matrix:
include:
- target: x86_64-unknown-linux-gnu
runner: ubuntu-latest
archive: tar.gz
use-cross: false
- target: aarch64-unknown-linux-gnu
runner: ubuntu-latest
archive: tar.gz
use-cross: true
- target: x86_64-apple-darwin
runner: macos-14
archive: tar.gz
use-cross: false
- target: aarch64-apple-darwin
runner: macos-14
archive: tar.gz
use-cross: false
- target: x86_64-pc-windows-msvc
runner: windows-latest
archive: zip
use-cross: false
steps:
- uses: actions/checkout@v4
- name: Install Rust toolchain
run: |
rustup update stable
rustup default stable
rustup target add ${{ matrix.target }}
- name: Install cross
if: matrix.use-cross
run: cargo install cross --locked
- name: Build
run: |
if [ "${{ matrix.use-cross }}" = "true" ]; then
cross build --release --target ${{ matrix.target }}
else
cargo build --release --target ${{ matrix.target }}
fi
shell: bash
- name: Package (Unix)
if: matrix.archive == 'tar.gz'
run: |
cd target/${{ matrix.target }}/release
tar czf ../../../authy-${{ matrix.target }}.tar.gz authy
shell: bash
- name: Package (Windows)
if: matrix.archive == 'zip'
run: |
cd target/${{ matrix.target }}/release
7z a ../../../authy-${{ matrix.target }}.zip authy.exe
shell: bash
- name: Upload artifact
uses: actions/upload-artifact@v4
with:
name: authy-${{ matrix.target }}
path: authy-${{ matrix.target }}.${{ matrix.archive }}
release:
name: GitHub Release
needs: build
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- name: Download artifacts
uses: actions/download-artifact@v4
with:
path: artifacts
- name: Create release
uses: softprops/action-gh-release@v2
with:
generate_release_notes: true
files: artifacts/**/*
# ── Node.js native binding (napi-rs) ────────────────────────────
node-build:
name: Node.js ${{ matrix.node-arch }}
runs-on: ${{ matrix.runner }}
strategy:
fail-fast: false
matrix:
include:
- target: x86_64-unknown-linux-gnu
runner: ubuntu-latest
node-arch: linux-x64-gnu
- target: aarch64-unknown-linux-gnu
runner: ubuntu-latest
node-arch: linux-arm64-gnu
use-napi-cross: true
- target: x86_64-apple-darwin
runner: macos-14
node-arch: darwin-x64
- target: aarch64-apple-darwin
runner: macos-14
node-arch: darwin-arm64
- target: x86_64-pc-windows-msvc
runner: windows-latest
node-arch: win32-x64-msvc
steps:
- uses: actions/checkout@v4
- name: Install Rust toolchain
run: |
rustup update stable
rustup default stable
rustup target add ${{ matrix.target }}
- uses: actions/setup-node@v4
with:
node-version: 20
- name: Install napi-rs CLI
run: npm install -g @napi-rs/cli
- name: Install aarch64 cross-compilation toolchain
if: matrix.use-napi-cross
run: |
sudo apt-get update
sudo apt-get install -y gcc-aarch64-linux-gnu g++-aarch64-linux-gnu
- name: Build native module
working-directory: bindings/node
run: napi build --release --target ${{ matrix.target }} --platform
shell: bash
env:
CARGO_TARGET_AARCH64_UNKNOWN_LINUX_GNU_LINKER: ${{ matrix.use-napi-cross && 'aarch64-linux-gnu-gcc' || '' }}
- name: Upload native artifact
uses: actions/upload-artifact@v4
with:
name: node-${{ matrix.node-arch }}
path: bindings/node/*.node
if-no-files-found: error
# ── Publish unified npm package (native binding + CLI binary) ───
npm-publish:
name: Publish npm package
needs: [build, node-build, release]
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- uses: actions/setup-node@v4
with:
node-version: 20
registry-url: https://registry.npmjs.org
# Collect napi-rs .node files
- name: Download native binding artifacts
uses: actions/download-artifact@v4
with:
pattern: node-*
path: bindings/node
merge-multiple: true
# Collect prebuilt CLI binaries
- name: Download CLI binary artifacts
uses: actions/download-artifact@v4
with:
path: artifacts
- name: Place CLI binaries into package
run: |
# Linux x64
tar xzf artifacts/authy-x86_64-unknown-linux-gnu/authy-x86_64-unknown-linux-gnu.tar.gz -C /tmp
mv /tmp/authy bindings/node/bin/authy-linux-x64
# Linux arm64
tar xzf artifacts/authy-aarch64-unknown-linux-gnu/authy-aarch64-unknown-linux-gnu.tar.gz -C /tmp
mv /tmp/authy bindings/node/bin/authy-linux-arm64
# macOS x64
tar xzf artifacts/authy-x86_64-apple-darwin/authy-x86_64-apple-darwin.tar.gz -C /tmp
mv /tmp/authy bindings/node/bin/authy-darwin-x64
# macOS arm64
tar xzf artifacts/authy-aarch64-apple-darwin/authy-aarch64-apple-darwin.tar.gz -C /tmp
mv /tmp/authy bindings/node/bin/authy-darwin-arm64
# Windows x64
cd artifacts/authy-x86_64-pc-windows-msvc
7z x authy-x86_64-pc-windows-msvc.zip -o/tmp/win
cd ../..
mv /tmp/win/authy.exe bindings/node/bin/authy-win32-x64.exe
# Make all binaries executable
chmod +x bindings/node/bin/authy-*
- name: List package contents
run: |
echo "=== Native modules ==="
ls -la bindings/node/*.node
echo "=== CLI binaries ==="
ls -la bindings/node/bin/
- name: Extract version from tag
id: version
run: echo "version=${GITHUB_REF_NAME#v}" >> "$GITHUB_OUTPUT"
- name: Update package version
working-directory: bindings/node
run: npm version "${{ steps.version.outputs.version }}" --no-git-tag-version --allow-same-version
- name: Publish
working-directory: bindings/node
env:
NODE_AUTH_TOKEN: ${{ secrets.NPM_TOKEN }}
run: npm publish --access public
# ── Python native binding (PyO3 + maturin) ─────────────────────
python-build:
name: Python ${{ matrix.target }}
runs-on: ${{ matrix.runner }}
strategy:
fail-fast: false
matrix:
include:
- target: x86_64-unknown-linux-gnu
runner: ubuntu-latest
- target: aarch64-unknown-linux-gnu
runner: ubuntu-latest
- target: x86_64-apple-darwin
runner: macos-14
- target: aarch64-apple-darwin
runner: macos-14
- target: x86_64-pc-windows-msvc
runner: windows-latest
steps:
- uses: actions/checkout@v4
- uses: actions/setup-python@v5
with:
python-version: "3.12"
- name: Build wheels
uses: PyO3/maturin-action@v1
with:
target: ${{ matrix.target }}
args: --release --out dist -i 3.9 3.10 3.11 3.12 3.13
manylinux: auto
working-directory: bindings/python
- name: Upload wheel artifacts
uses: actions/upload-artifact@v4
with:
name: python-wheel-${{ matrix.target }}
path: bindings/python/dist/*.whl
python-sdist:
name: Python sdist
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- name: Build sdist
uses: PyO3/maturin-action@v1
with:
command: sdist
args: --out dist
working-directory: bindings/python
- name: Upload sdist artifact
uses: actions/upload-artifact@v4
with:
name: python-sdist
path: bindings/python/dist/*.tar.gz
pypi-publish:
name: Publish to PyPI
needs: [python-build, python-sdist, release]
runs-on: ubuntu-latest
steps:
- name: Download wheel artifacts
uses: actions/download-artifact@v4
with:
pattern: python-wheel-*
path: dist
merge-multiple: true
- name: Download sdist artifact
uses: actions/download-artifact@v4
with:
name: python-sdist
path: dist
- name: List distributions
run: ls -la dist/
- name: Publish to PyPI
uses: pypa/gh-action-pypi-publish@release/v1
with:
password: ${{ secrets.PYPI_TOKEN }}
# ── Go module tag ──────────────────────────────────────────────
go-tag:
name: Tag Go module
needs: release
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- name: Extract version from tag
id: version
run: echo "version=${GITHUB_REF_NAME}" >> "$GITHUB_OUTPUT"
- name: Create Go subdirectory tag
run: |
git config user.name "github-actions[bot]"
git config user.email "github-actions[bot]@users.noreply.github.com"
TAG="packages/go/${{ steps.version.outputs.version }}"
if git ls-remote --tags origin "$TAG" | grep -q "$TAG"; then
echo "Tag $TAG already exists, skipping"
else
git tag "$TAG"
git push origin "$TAG"
fi