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
name: release
on:
push:
tags:
- "v*.*.*"
workflow_dispatch:
# Read-only by default; jobs opt into more.
permissions: read-all
concurrency:
group: release-${{ github.ref }}
cancel-in-progress: false
jobs:
build:
name: build (${{ matrix.target }})
runs-on: ${{ matrix.os }}
permissions:
contents: read
strategy:
fail-fast: false
matrix:
include:
- os: ubuntu-latest
target: x86_64-unknown-linux-gnu
archive: tar.gz
- os: ubuntu-latest
target: aarch64-unknown-linux-gnu
archive: tar.gz
cross: true
- os: macos-latest
target: x86_64-apple-darwin
archive: tar.gz
- os: macos-latest
target: aarch64-apple-darwin
archive: tar.gz
- os: windows-latest
target: x86_64-pc-windows-msvc
archive: zip
steps:
- name: Checkout
uses: actions/checkout@9c091bb21b7c1c1d1991bb908d89e4e9dddfe3e0 # v7.0.0
with:
persist-credentials: false
- name: Install Rust toolchain
uses: dtolnay/rust-toolchain@stable
with:
targets: ${{ matrix.target }}
- name: Cache cargo
uses: Swatinem/rust-cache@23869a5bd66c73db3c0ac40331f3206eb23791dc # v2.9.1
with:
key: ${{ matrix.target }}
- uses: actions/setup-python@v6
with:
python-version: '3.11'
- name: Build native binary and Python wheel
uses: PyO3/maturin-action@86b9d133d34bc1b40018696f782949dac11bd380 # v1.49.4
with:
maturin-version: v1.11.5
target: ${{ matrix.target }}
manylinux: '2_28'
args: --release --locked --compatibility pypi --out wheels
- name: Package
shell: bash
run: |
set -euo pipefail
name="aiscope-${GITHUB_REF_NAME}-${{ matrix.target }}"
mkdir "$name"
if [[ "${{ matrix.os }}" == "windows-latest" ]]; then
cp "target/${{ matrix.target }}/release/aiscope.exe" "$name/"
cp "$name/aiscope.exe" "$name.exe"
echo "BINARY=$name.exe" >> "$GITHUB_ENV"
else
cp "target/${{ matrix.target }}/release/aiscope" "$name/"
cp "$name/aiscope" "$name.bin"
echo "BINARY=$name.bin" >> "$GITHUB_ENV"
fi
cp README.md LICENSE CHANGELOG.md "$name/"
if [[ "${{ matrix.archive }}" == "zip" ]]; then
7z a "$name.zip" "$name"
echo "ASSET=$name.zip" >> "$GITHUB_ENV"
else
tar czf "$name.tar.gz" "$name"
echo "ASSET=$name.tar.gz" >> "$GITHUB_ENV"
fi
- name: Checksum
shell: bash
run: |
if [[ "${{ matrix.os }}" == "macos-latest" ]]; then
shasum -a 256 "$ASSET" > "$ASSET.sha256"
shasum -a 256 "$BINARY" > "$BINARY.sha256"
else
sha256sum "$ASSET" > "$ASSET.sha256"
sha256sum "$BINARY" > "$BINARY.sha256"
fi
- name: Upload artifact
uses: actions/upload-artifact@043fb46d1a93c77aae656e7c1c64a875d1fc6a0a # v7.0.1
with:
name: ${{ matrix.target }}
path: |
${{ env.ASSET }}
${{ env.ASSET }}.sha256
${{ env.BINARY }}
${{ env.BINARY }}.sha256
- name: Upload Python wheel
uses: actions/upload-artifact@043fb46d1a93c77aae656e7c1c64a875d1fc6a0a
with:
name: wheel-${{ matrix.target }}
path: wheels/*.whl
publish:
name: publish github release
needs: build
runs-on: ubuntu-latest
permissions:
contents: write
steps:
- name: Checkout
uses: actions/checkout@9c091bb21b7c1c1d1991bb908d89e4e9dddfe3e0 # v7.0.0
with:
persist-credentials: false
- name: Download artifacts
uses: actions/download-artifact@d3f86a106a0bac45b974a628896c90dbdf5c8093 # v4.3.0
with:
path: dist
- uses: actions/setup-node@v6
with:
node-version: '24'
- name: Check npm launcher and package public bundles
run: |
npm test
python scripts/prepare_packages.py
- name: Extract release notes from CHANGELOG
shell: bash
run: |
set -euo pipefail
version="${GITHUB_REF_NAME#v}"
# Print everything between "## [<version>]" and the next "## [" heading.
awk -v ver="$version" '
$0 ~ "^## \\[" ver "\\]" { found=1; next }
found && /^## \[/ { exit }
found { print }
' CHANGELOG.md > RELEASE_NOTES.md
if [ ! -s RELEASE_NOTES.md ]; then
echo "Release ${GITHUB_REF_NAME}" > RELEASE_NOTES.md
fi
echo "----- RELEASE_NOTES.md -----"
cat RELEASE_NOTES.md
- name: Create GitHub Release
uses: softprops/action-gh-release@b4309332981a82ec1c5618f44dd2e27cc8bfbfda # v3.0.0
with:
generate_release_notes: true
body_path: RELEASE_NOTES.md
files: |
dist/*/*
dist/*.tgz
dist/*.zip
npm:
needs: publish
runs-on: ubuntu-latest
environment: npm
permissions:
contents: read
id-token: write
steps:
- uses: actions/checkout@v6
- uses: actions/setup-node@v6
with:
node-version: '24'
registry-url: https://registry.npmjs.org
package-manager-cache: false
- run: npm install --global npm@latest
- name: Publish missing npm version
shell: bash
run: |
VERSION="${GITHUB_REF_NAME#v}"
STATUS=$(curl --silent --output /dev/null --write-out '%{http_code}' "https://registry.npmjs.org/aiscope-cli/$VERSION")
if [ "$STATUS" = "404" ]; then npm publish --access public --provenance; elif [ "$STATUS" != "200" ]; then exit 1; fi
pypi:
needs: publish
runs-on: ubuntu-latest
environment: pypi
permissions:
id-token: write
steps:
- uses: actions/download-artifact@v4
with:
pattern: wheel-*
merge-multiple: true
path: wheels
- uses: pypa/gh-action-pypi-publish@release/v1
with:
packages-dir: wheels/
skip-existing: true
crates-io:
name: publish crates.io
needs: publish
runs-on: ubuntu-latest
if: ${{ vars.PUBLISH_CRATES_IO == 'true' }}
permissions:
contents: read
steps:
- name: Checkout
uses: actions/checkout@9c091bb21b7c1c1d1991bb908d89e4e9dddfe3e0 # v7.0.0
with:
persist-credentials: false
- name: Install Rust toolchain
uses: dtolnay/rust-toolchain@stable
- name: Publish
env:
CARGO_REGISTRY_TOKEN: ${{ secrets.CARGO_REGISTRY_TOKEN }}
run: cargo publish --locked