Repository navigation
259 lines (218 loc) · 7.15 KB
/
Copy pathrelease.yml
File metadata and controls
259 lines (218 loc) · 7.15 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
name: Release
# Publishes:
# - a GitHub release with the wesl-cli binary for every target.
# - `wesl-rs-web` to npm.
# - the workspace crates to crates.io.
#
# Triggered by pushing a `vX.Y.Z` tag. The manual dispatch only runs the build jobs.
on:
workflow_dispatch:
push:
tags:
- v[0-9]+.[0-9]+.[0-9]+
permissions: {}
env:
CARGO_TERM_COLOR: always
STABLE_TOOLCHAIN: "1.97.1"
NODE_VERSION: "24"
concurrency:
group: ${{ github.workflow }}-${{ github.ref }}
cancel-in-progress: false
jobs:
wesl-cli:
name: build wesl-cli (${{ matrix.target }})
runs-on: ${{ matrix.os }}
timeout-minutes: 30
strategy:
fail-fast: false
matrix:
include:
- os: windows-latest
target: x86_64-pc-windows-msvc
- os: windows-latest
target: aarch64-pc-windows-msvc
- os: ubuntu-latest
target: x86_64-unknown-linux-gnu
- os: ubuntu-24.04-arm
target: aarch64-unknown-linux-gnu
- os: macos-14
target: x86_64-apple-darwin
- os: macos-14
target: aarch64-apple-darwin
steps:
- name: Checkout
uses: actions/checkout@v7
- name: Install Rust toolchain
uses: dtolnay/rust-toolchain@stable
with:
toolchain: ${{ env.STABLE_TOOLCHAIN }}
target: ${{ matrix.target }}
- name: Build wesl-cli
run: cargo build --release --locked --target ${{ matrix.target }} -p wesl-cli
- name: Package wesl-cli
shell: bash
run: |
set -euo pipefail
target="${{ matrix.target }}"
out="target/${target}/release"
pkg="wesl-${target}"
mkdir -p "${pkg}"
# CLI binary
if [[ "${target}" == *windows* ]]; then
cp "${out}/wesl.exe" "${pkg}/"
else
cp "${out}/wesl" "${pkg}/"
fi
cp README.md LICENSE-APACHE LICENSE-MIT "${pkg}/"
ls -la "${pkg}"
# Archive
if [[ "${target}" == *windows* ]]; then
7z a "${pkg}.zip" "${pkg}"
else
tar czf "${pkg}.tar.gz" "${pkg}"
fi
- name: Upload artifacts
uses: actions/upload-artifact@v7
with:
name: wesl-cli-${{ matrix.target }}
path: ./wesl-${{ matrix.target }}.*
if-no-files-found: error
wesl-rs-web:
name: build wesl-rs-web
runs-on: ubuntu-latest
timeout-minutes: 30
steps:
- name: Checkout
uses: actions/checkout@v7
- name: Install Rust toolchain
uses: dtolnay/rust-toolchain@stable
with:
toolchain: ${{ env.STABLE_TOOLCHAIN }}
target: wasm32-unknown-unknown
- name: Install wasm-pack
uses: taiki-e/install-action@wasm-pack
- name: Install Node.js
uses: actions/setup-node@v7
with:
node-version: ${{ env.NODE_VERSION }}
- name: Build wesl-rs-web
run: cargo xtask wesl-rs-web --release
- name: Create tarball
working-directory: ./crates/wesl-rs-web
run: |
npm pack
mv wesl-rs-web-*.tgz ../../wesl-rs-web.tgz
- name: Check tarball
run: |
contents="$(tar -tzf wesl-rs-web.tgz)"
for file in package.json README.md LICENSE-APACHE LICENSE-MIT dist/wesl-rs-web.js dist/wesl-rs-web.d.ts dist/wesl-rs-web_bg.wasm; do
grep -qxF "package/$file" <<< "$contents" || { echo "::error::tarball is missing $file"; exit 1; }
done
- name: Upload artifacts
uses: actions/upload-artifact@v7
with:
name: wesl-rs-web
path: ./wesl-rs-web.tgz
if-no-files-found: error
publish-github:
name: Publish (GitHub Release)
if: startsWith(github.ref, 'refs/tags/v')
needs: ["wesl-cli", "wesl-rs-web"]
timeout-minutes: 30
runs-on: ubuntu-latest
permissions:
contents: write
steps:
- name: Checkout repository
uses: actions/checkout@v7
- name: Set release tag
run: |
echo "TAG=${GITHUB_REF_NAME}" >> "$GITHUB_ENV"
- name: Download dist artifacts
uses: actions/download-artifact@v8
with:
path: dist
merge-multiple: true
- name: Display artifacts
run: ls -la ./dist
- name: Publish release
uses: softprops/action-gh-release@v3
with:
tag_name: ${{ env.TAG }}
name: ${{ env.TAG }}
target_commitish: ${{ github.sha }}
prerelease: false
generate_release_notes: true
files: dist/*
fail_on_unmatched_files: true
token: ${{ secrets.GITHUB_TOKEN }}
publish-crates-io:
name: Publish (crates.io)
needs: publish-github
timeout-minutes: 30
runs-on: ubuntu-latest
permissions:
contents: read
id-token: write # trusted publishing (OIDC)
steps:
- name: Checkout repository
uses: actions/checkout@v7
- name: Install Rust toolchain
uses: dtolnay/rust-toolchain@stable
with:
toolchain: ${{ env.STABLE_TOOLCHAIN }}
- name: Authenticate with crates.io
uses: rust-lang/crates-io-auth-action@v1
id: auth
- name: Publish to crates.io
run: |
set -euo pipefail
# publishes crates in dependency order, and ignores if it already exists.
# tokrepr, tokrepr-derive and wesl-core have independent versions.
# The rest share the same versioning.
for crate in tokrepr-derive tokrepr wesl-core wesl-macros wgsl-types wgsl-parse wesl-quote wesl wesl-cli; do
echo "publishing ${crate}"
if ! output="$(cargo publish --locked -p "$crate" 2>&1)"; then
echo "$output"
if grep -q "already exists" <<< "$output"; then
echo "::notice::${crate} is already published"
else
exit 1
fi
fi
done
env:
CARGO_REGISTRY_TOKEN: ${{ steps.auth.outputs.token }}
publish-npm:
name: Publish (npm)
needs: publish-github
timeout-minutes: 15
runs-on: ubuntu-latest
permissions:
contents: read
id-token: write # trusted publishing (OIDC)
steps:
- name: Checkout repository
uses: actions/checkout@v7
- name: Install Node.js
uses: actions/setup-node@v7
with:
node-version: ${{ env.NODE_VERSION }}
registry-url: 'https://registry.npmjs.org'
package-manager-cache: false # never use caching in release builds
- name: Download wesl-rs-web artifact
uses: actions/download-artifact@v8
with:
name: wesl-rs-web
path: ./dist
- name: Display artifact
run: ls -al ./dist
- name: Publish to npm
run: |
tarball=./dist/wesl-rs-web.tgz
version="$(tar -xOzf "${tarball}" package/package.json | jq -r .version)"
if [ "$(npm view "wesl-rs-web@${version}" version 2>/dev/null)" = "${version}" ]; then
echo "::notice::wesl-rs-web@${version} is already published"
exit 0
fi
npm stage publish "${tarball}"