-
Notifications
You must be signed in to change notification settings - Fork 20
306 lines (267 loc) · 9.42 KB
/
release.yml
File metadata and controls
306 lines (267 loc) · 9.42 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
name: Release
on:
workflow_dispatch:
inputs:
version:
description: 'Version to publish'
required: true
jobs:
build-and-publish-platform-packages:
name: Build ${{ matrix.platform }}
runs-on: ${{ matrix.os }}
strategy:
matrix:
include:
- os: ubuntu-latest
target: x86_64-unknown-linux-musl
platform: linux-x64
os_name: linux
cpu: x64
- os: macos-latest
target: x86_64-apple-darwin
platform: darwin-x64
os_name: darwin
cpu: x64
- os: macos-latest
target: aarch64-apple-darwin
platform: darwin-arm64
os_name: darwin
cpu: arm64
- os: windows-latest
target: x86_64-pc-windows-msvc
platform: win32-x64
os_name: win32
cpu: x64
steps:
- name: Checkout
uses: actions/checkout@v4
- name: Get version
id: version
shell: bash
run: |
VERSION="${{ github.event.release.tag_name || github.event.inputs.version }}"
VERSION="${VERSION#v}"
echo "version=$VERSION" >> $GITHUB_OUTPUT
- name: Install Rust
uses: dtolnay/rust-toolchain@stable
with:
targets: ${{ matrix.target }}
- name: Install musl tools (x64)
if: matrix.target == 'x86_64-unknown-linux-musl'
run: sudo apt-get install -y musl-tools
- name: Build
working-directory: crates/capsule-cli
run: cargo build --release --target ${{ matrix.target }}
- name: Setup Node.js
uses: actions/setup-node@v4
with:
node-version: '20'
registry-url: 'https://registry.npmjs.org'
- name: Create platform package (Unix)
if: runner.os != 'Windows'
run: |
mkdir -p dist
cp crates/capsule-cli/target/${{ matrix.target }}/release/capsule dist/
cat > dist/package.json << EOF
{
"name": "@capsule-run/cli-${{ matrix.platform }}",
"version": "${{ steps.version.outputs.version }}",
"os": ["${{ matrix.os_name }}"],
"cpu": ["${{ matrix.cpu }}"],
"bin": { "capsule": "./capsule" },
"license": "Apache-2.0"
}
EOF
- name: Create platform package (Windows)
if: runner.os == 'Windows'
shell: bash
run: |
mkdir -p dist
cp crates/capsule-cli/target/${{ matrix.target }}/release/capsule.exe dist/
cat > dist/package.json << EOF
{
"name": "@capsule-run/cli-${{ matrix.platform }}",
"version": "${{ steps.version.outputs.version }}",
"os": ["${{ matrix.os_name }}"],
"cpu": ["${{ matrix.cpu }}"],
"bin": { "capsule": "./capsule.exe" },
"license": "Apache-2.0"
}
EOF
- name: Check if platform package version exists
id: check_platform_version
shell: bash
run: |
if (npm view @capsule-run/cli-${{ matrix.platform }}@${{ steps.version.outputs.version }} version) >/dev/null 2>&1; then
echo "exists=true" >> $GITHUB_OUTPUT
else
echo "exists=false" >> $GITHUB_OUTPUT
fi
- name: Publish platform package
if: steps.check_platform_version.outputs.exists != 'true'
working-directory: dist
run: npm publish --access public
env:
NODE_AUTH_TOKEN: ${{ secrets.NPM_TOKEN }}
publish-npm-cli:
name: Publish @capsule-run/cli
needs: build-and-publish-platform-packages
runs-on: ubuntu-latest
steps:
- name: Checkout
uses: actions/checkout@v4
- name: Setup Node.js
uses: actions/setup-node@v4
with:
node-version: '20'
registry-url: 'https://registry.npmjs.org'
- name: Get version
id: version
run: |
VERSION="${{ github.event.release.tag_name || github.event.inputs.version }}"
VERSION="${VERSION#v}"
echo "version=$VERSION" >> $GITHUB_OUTPUT
- name: Check if CLI package version exists
id: check_cli_version
run: |
if (npm view @capsule-run/cli@${{ steps.version.outputs.version }} version) >/dev/null 2>&1; then
echo "exists=true" >> $GITHUB_OUTPUT
else
echo "exists=false" >> $GITHUB_OUTPUT
fi
- name: Publish
if: steps.check_cli_version.outputs.exists != 'true'
working-directory: crates/capsule-cli/npm
run: npm publish --access public
env:
NODE_AUTH_TOKEN: ${{ secrets.NPM_TOKEN }}
publish-crates:
name: Publish to crates.io
runs-on: ubuntu-latest
steps:
- name: Checkout
uses: actions/checkout@v4
- name: Install Rust
uses: dtolnay/rust-toolchain@stable
- name: Prepare capsule-core for publishing
run: |
cp -r crates/capsule-wit crates/capsule-core/
sed -i 's|../../../../capsule-wit|../../../capsule-wit|g' crates/capsule-core/src/wasm/compiler/mod.rs
sed -i 's|"../capsule-wit"|"./capsule-wit"|g' crates/capsule-core/src/wasm/state.rs
sed -i 's|../../../../capsule-wit|../../../capsule-wit|g' crates/capsule-core/src/wasm/utilities/wit_manager.rs
- name: Publish capsule-core
working-directory: crates/capsule-core
run: cargo publish || echo "Version may already exist, continuing..."
env:
CARGO_REGISTRY_TOKEN: ${{ secrets.CARGO_REGISTRY_TOKEN }}
- name: Wait for crates.io index update
run: sleep 60
- name: Publish capsule-run
working-directory: crates/capsule-cli
run: cargo publish || echo "Version may already exist, continuing..."
env:
CARGO_REGISTRY_TOKEN: ${{ secrets.CARGO_REGISTRY_TOKEN }}
publish-npm-sdk:
name: Publish @capsule-run/sdk
runs-on: ubuntu-latest
steps:
- name: Checkout
uses: actions/checkout@v4
- name: Setup Node.js
uses: actions/setup-node@v4
with:
node-version: '20'
registry-url: 'https://registry.npmjs.org'
- name: Get version
id: version
run: |
VERSION="${{ github.event.release.tag_name || github.event.inputs.version }}"
VERSION="${VERSION#v}"
echo "version=$VERSION" >> $GITHUB_OUTPUT
- name: Check if SDK package version exists
id: check_sdk_version
run: |
if (npm view @capsule-run/sdk@${{ steps.version.outputs.version }} version) >/dev/null 2>&1; then
echo "exists=true" >> $GITHUB_OUTPUT
else
echo "exists=false" >> $GITHUB_OUTPUT
fi
- name: Install dependencies
if: steps.check_sdk_version.outputs.exists != 'true'
working-directory: crates/capsule-sdk/javascript
run: npm ci
- name: Build
if: steps.check_sdk_version.outputs.exists != 'true'
working-directory: crates/capsule-sdk/javascript
run: npm run build
- name: Publish
if: steps.check_sdk_version.outputs.exists != 'true'
working-directory: crates/capsule-sdk/javascript
run: npm publish --access public
env:
NODE_AUTH_TOKEN: ${{ secrets.NPM_TOKEN }}
publish-pypi:
name: Publish to PyPI (${{ matrix.os }})
runs-on: ${{ matrix.os }}
strategy:
matrix:
include:
- os: ubuntu-latest
- os: macos-latest
- os: windows-latest
steps:
- name: Checkout
uses: actions/checkout@v4
- name: Setup Python
uses: actions/setup-python@v5
with:
python-version: '3.11'
- name: Install Maturin
run: pip install maturin
- name: Prepare capsule-core WIT files
shell: bash
run: |
cp -r crates/capsule-wit crates/capsule-core/
python -c "
import re
replacements = [
('crates/capsule-core/src/wasm/compiler/mod.rs',
'../../../../capsule-wit', '../../../capsule-wit'),
('crates/capsule-core/src/wasm/state.rs',
'\"../capsule-wit\"', '\"./capsule-wit\"'),
('crates/capsule-core/src/wasm/utilities/wit_manager.rs',
'../../../../capsule-wit', '../../../capsule-wit'),
]
for path, old, new in replacements:
with open(path, 'r') as f:
content = f.read()
with open(path, 'w') as f:
f.write(content.replace(old, new))
"
- name: Copy SDK source for maturin
shell: bash
run: |
cp -r crates/capsule-sdk/python/src crates/capsule-cli/python_src
- name: Update python-source path
shell: bash
run: |
python -c "
file_path = 'crates/capsule-cli/pyproject.toml'
with open(file_path, 'r') as f:
content = f.read()
content = content.replace(
'python-source = \"../capsule-sdk/python/src\"',
'python-source = \"python_src\"'
)
with open(file_path, 'w') as f:
f.write(content)
"
- name: Build and publish
uses: PyO3/maturin-action@v1
with:
manylinux: '2_28'
working-directory: crates/capsule-cli
command: publish
args: --skip-existing
env:
MATURIN_PYPI_TOKEN: ${{ secrets.PYPI_TOKEN }}