-
Notifications
You must be signed in to change notification settings - Fork 103
324 lines (292 loc) · 11.6 KB
/
Copy pathrelease.yml
File metadata and controls
324 lines (292 loc) · 11.6 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
name: Release
on:
push:
tags:
- 'v*.*.*'
workflow_dispatch: {} # allows triggering from release-prepare.yml
permissions:
contents: write
id-token: write # Required for cosign keyless signing
jobs:
# ---------------------------------------------------------------------------
# Linux builds — parallel with macOS and WASM
# ---------------------------------------------------------------------------
build-linux:
name: Build Linux
runs-on: ubuntu-latest
env:
RUSTFLAGS: "-C target-feature=+crt-static"
steps:
- uses: actions/checkout@3d3c42e5aac5ba805825da76410c181273ba90b1 # v7.0.1
with:
fetch-depth: 0
- name: Fetch all tags
run: git fetch --force --tags
- name: Install Rust
run: |
rustup toolchain install stable --profile minimal
rustup default stable
rustup target add x86_64-unknown-linux-musl aarch64-unknown-linux-musl
- name: Cache Rust dependencies
uses: actions/cache@55cc8345863c7cc4c66a329aec7e433d2d1c52a9 # v6.1.0
with:
path: |
~/.cargo/registry/index
~/.cargo/registry/cache
~/.cargo/git/db
target
key: ${{ runner.os }}-cargo-release-${{ hashFiles('**/Cargo.lock') }}
restore-keys: |
${{ runner.os }}-cargo-release-
- uses: ./.github/actions/install-musl-toolchain
- name: Install syft
uses: anchore/sbom-action/download-syft@e22c389904149dbc22b58101806040fa8d37a610 # v0.24.0
- uses: goreleaser/goreleaser-action@f06c13b6b1a9625abc9e6e439d9c05a8f2190e94 # v7.2.3
with:
distribution: goreleaser
version: "~> v2"
args: release --clean --config .goreleaser-linux.yaml --skip=publish
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
- name: Upload artifacts
uses: actions/upload-artifact@043fb46d1a93c77aae656e7c1c64a875d1fc6a0a # v7.0.1
with:
name: dist-linux
path: |
dist/*.tar.gz
dist/*.sbom.json
retention-days: 1
# ---------------------------------------------------------------------------
# macOS builds — parallel with Linux and WASM
# ---------------------------------------------------------------------------
build-macos:
name: Build macOS
runs-on: macos-latest-xlarge
steps:
- uses: actions/checkout@3d3c42e5aac5ba805825da76410c181273ba90b1 # v7.0.1
with:
fetch-depth: 0
- name: Fetch all tags
run: git fetch --force --tags
- name: Install Rust
run: |
rustup toolchain install stable --profile minimal
rustup default stable
rustup target add x86_64-apple-darwin
- name: Cache Rust dependencies
uses: actions/cache@55cc8345863c7cc4c66a329aec7e433d2d1c52a9 # v6.1.0
with:
path: |
~/.cargo/registry/index
~/.cargo/registry/cache
~/.cargo/git/db
target
key: ${{ runner.os }}-cargo-release-${{ hashFiles('**/Cargo.lock') }}
restore-keys: |
${{ runner.os }}-cargo-release-
- name: Install syft
uses: anchore/sbom-action/download-syft@e22c389904149dbc22b58101806040fa8d37a610 # v0.24.0
- uses: goreleaser/goreleaser-action@f06c13b6b1a9625abc9e6e439d9c05a8f2190e94 # v7.2.3
with:
distribution: goreleaser
version: "~> v2"
args: release --clean --config .goreleaser-macos.yaml --skip=publish
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
- name: Upload artifacts
uses: actions/upload-artifact@043fb46d1a93c77aae656e7c1c64a875d1fc6a0a # v7.0.1
with:
name: dist-macos
path: |
dist/*.tar.gz
dist/*.sbom.json
retention-days: 1
# ---------------------------------------------------------------------------
# WASM builds — parallel with Linux and macOS
# ---------------------------------------------------------------------------
build-wasm:
name: Build WASM
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@3d3c42e5aac5ba805825da76410c181273ba90b1 # v7.0.1
with:
fetch-depth: 0
- name: Install Rust
run: |
rustup toolchain install stable --profile minimal
rustup default stable
rustup target add wasm32-wasip2 wasm32-unknown-unknown
- name: Cache Rust dependencies
uses: actions/cache@55cc8345863c7cc4c66a329aec7e433d2d1c52a9 # v6.1.0
with:
path: |
~/.cargo/registry/index
~/.cargo/registry/cache
~/.cargo/git/db
target
key: ${{ runner.os }}-cargo-wasm-${{ hashFiles('**/Cargo.lock') }}
restore-keys: |
${{ runner.os }}-cargo-wasm-
- name: Install wasm-pack
run: curl https://rustwasm.github.io/wasm-pack/installer/init.sh -sSf | sh
- name: Build WASI
run: |
cargo build --release --target wasm32-wasip2 --no-default-features --features wasi
mkdir -p wasm-out
cp target/wasm32-wasip2/release/pup.wasm wasm-out/pup_wasi.wasm
- name: Build browser WASM
run: |
wasm-pack build --target web --no-default-features --features browser
tar czf wasm-out/pup_browser_wasm.tar.gz -C pkg .
- name: Upload artifacts
uses: actions/upload-artifact@043fb46d1a93c77aae656e7c1c64a875d1fc6a0a # v7.0.1
with:
name: dist-wasm
path: wasm-out/
retention-days: 1
# ---------------------------------------------------------------------------
# Windows build — parallel with everything else
# ---------------------------------------------------------------------------
build-windows:
name: Build Windows
runs-on: windows-latest
defaults:
run:
shell: bash
steps:
- uses: actions/checkout@3d3c42e5aac5ba805825da76410c181273ba90b1 # v7.0.1
with:
fetch-depth: 0
- name: Enable long paths
run: git config --global core.longpaths true
- name: Install NASM
run: |
choco install nasm -y
echo "C:\Program Files\NASM" >> "$GITHUB_PATH"
- name: Install Rust
run: |
rustup toolchain install stable --profile minimal
rustup default stable
- name: Cache Rust dependencies
uses: actions/cache@55cc8345863c7cc4c66a329aec7e433d2d1c52a9 # v6.1.0
with:
path: |
~/.cargo/registry/index
~/.cargo/registry/cache
~/.cargo/git/db
target
key: ${{ runner.os }}-cargo-release-${{ hashFiles('**/Cargo.lock') }}
restore-keys: |
${{ runner.os }}-cargo-release-
- name: Build
run: cargo build --release
- name: Get version from tag
id: version
run: echo "version=${GITHUB_REF_NAME#v}" >> "$GITHUB_OUTPUT"
- name: Package
run: |
mkdir -p staging
cp target/release/pup.exe staging/
cp LICENSE staging/
cp LICENSE-3rdparty.csv staging/
cp README.md staging/
cd staging
7z a "../pup_${{ steps.version.outputs.version }}_Windows_x86_64.zip" .
- name: Upload artifacts
uses: actions/upload-artifact@043fb46d1a93c77aae656e7c1c64a875d1fc6a0a # v7.0.1
with:
name: dist-windows
path: "pup_*_Windows_x86_64.zip"
retention-days: 1
# ---------------------------------------------------------------------------
# Finalize — collect all artifacts, checksum, sign, publish release
# ---------------------------------------------------------------------------
finalize:
name: Publish Release
needs: [build-linux, build-macos, build-wasm, build-windows]
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@3d3c42e5aac5ba805825da76410c181273ba90b1 # v7.0.1
with:
fetch-depth: 0
- name: Download all artifacts
uses: actions/download-artifact@3e5f45b2cfb9172054b4087a40e8e0b5a5461e7c # v8.0.1
with:
path: collected/
- name: Get version from tag
id: version
run: echo "version=${GITHUB_REF_NAME#v}" >> "$GITHUB_OUTPUT"
- name: Collect release assets
run: |
mkdir -p release-assets
echo "=== Downloaded artifacts ==="
find collected/ -type f | sort
# Goreleaser archives and SBOMs (upload-artifact preserves relative paths under dist/)
find collected/dist-linux collected/dist-macos -type f \( -name '*.tar.gz' -o -name '*.sbom.json' \) \
-exec cp {} release-assets/ \;
# WASM
cp collected/dist-wasm/pup_wasi.wasm release-assets/
cp collected/dist-wasm/pup_browser_wasm.tar.gz release-assets/
# Windows
cp collected/dist-windows/*.zip release-assets/
echo "=== Release assets ==="
ls -la release-assets/
- name: Generate checksums
working-directory: release-assets
run: |
CHECKSUMS="pup_${{ steps.version.outputs.version }}_checksums.txt"
sha256sum * > "$CHECKSUMS"
echo "=== Checksums ==="
cat "$CHECKSUMS"
- name: Install cosign
uses: sigstore/cosign-installer@6f9f17788090df1f26f669e9d70d6ae9567deba6 # v4.1.2
- name: Sign checksums
working-directory: release-assets
run: |
CHECKSUMS="pup_${{ steps.version.outputs.version }}_checksums.txt"
cosign sign-blob \
--bundle="${CHECKSUMS}.sigstore.json" \
"$CHECKSUMS" \
--yes
- name: Create GitHub release
run: |
VERSION="${{ steps.version.outputs.version }}"
TAG="${GITHUB_REF_NAME}"
cat > release-notes.md <<EOF
## Pup ${VERSION}
### Installation
\`\`\`bash
# macOS (Apple Silicon)
curl -L https://github.com/DataDog/pup/releases/download/${TAG}/pup_${VERSION}_Darwin_arm64.tar.gz | tar xz
# macOS (Intel)
curl -L https://github.com/DataDog/pup/releases/download/${TAG}/pup_${VERSION}_Darwin_x86_64.tar.gz | tar xz
# Linux (x86_64)
curl -L https://github.com/DataDog/pup/releases/download/${TAG}/pup_${VERSION}_Linux_x86_64.tar.gz | tar xz
# Linux (arm64)
curl -L https://github.com/DataDog/pup/releases/download/${TAG}/pup_${VERSION}_Linux_arm64.tar.gz | tar xz
# Windows (x86_64)
curl -L https://github.com/DataDog/pup/releases/download/${TAG}/pup_${VERSION}_Windows_x86_64.zip -o pup.zip
tar -xf pup.zip
\`\`\`
### WASM
- **WASI** (\`pup_wasi.wasm\`): Run in Wasmtime or any WASI Preview 2 runtime
- **Browser WASM** (\`pup_browser_wasm.tar.gz\`): npm-ready package with \`PupClient\` JS class and TypeScript definitions
### Verifying
\`\`\`bash
# Verify checksums
sha256sum -c pup_${VERSION}_checksums.txt
# Verify signature (requires cosign)
cosign verify-blob \\
--bundle pup_${VERSION}_checksums.txt.sigstore.json \\
pup_${VERSION}_checksums.txt
\`\`\`
EOF
# Strip leading whitespace from heredoc (indented in YAML)
sed -i 's/^ //' release-notes.md
gh release create "$TAG" \
--title "Release $VERSION" \
--notes-file release-notes.md \
--generate-notes \
release-assets/*
env:
GH_TOKEN: ${{ secrets.GITHUB_TOKEN }}