-
-
Notifications
You must be signed in to change notification settings - Fork 0
324 lines (287 loc) · 10.3 KB
/
release.yml
File metadata and controls
324 lines (287 loc) · 10.3 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:
inputs:
tag:
description: "Existing tag to release (e.g. v0.1.0)"
required: true
type: string
concurrency:
group: release-${{ github.workflow }}-${{ github.event_name }}-${{ github.ref_name }}-${{ inputs.tag || 'none' }}
cancel-in-progress: false
jobs:
meta:
name: Resolve tag + validate
runs-on: ubuntu-latest
permissions:
contents: read
outputs:
tag: ${{ steps.tag.outputs.tag }}
version: ${{ steps.version.outputs.version }}
steps:
- name: Resolve tag
id: tag
shell: bash
run: |
if [[ "${{ github.event_name }}" == "workflow_dispatch" ]]; then
echo "tag=${{ inputs.tag }}" >> "$GITHUB_OUTPUT"
else
echo "tag=${{ github.ref_name }}" >> "$GITHUB_OUTPUT"
fi
- name: Checkout
uses: actions/checkout@34e114876b0b11c390a56381ad16ebd13914f8d5 # v4
with:
fetch-depth: 0
ref: ${{ steps.tag.outputs.tag }}
- name: Validate tag matches Cargo.toml version
id: version
shell: bash
env:
TAG: ${{ steps.tag.outputs.tag }}
run: |
VERSION="$(python3 scripts/release/validate_tag.py --tag "$TAG")"
echo "Validated tag $TAG for Cargo.toml version $VERSION"
echo "version=$VERSION" >> "$GITHUB_OUTPUT"
verify:
name: Verify (${{ matrix.os }})
needs: meta
strategy:
fail-fast: false
matrix:
os:
- ubuntu-latest
- macos-latest
runs-on: ${{ matrix.os }}
permissions:
contents: read
steps:
- name: Checkout
uses: actions/checkout@34e114876b0b11c390a56381ad16ebd13914f8d5 # v4
with:
ref: ${{ needs.meta.outputs.tag }}
- name: Setup Rust
uses: dtolnay/rust-toolchain@4be9e76fd7c4901c61fb841f559994984270fce7 # stable
with:
toolchain: 1.88.0
components: rustfmt, clippy
- name: Rust cache
uses: Swatinem/rust-cache@779680da715d629ac1d338a641029a2f4372abb5 # v2
- name: Setup Go
if: ${{ matrix.os == 'ubuntu-latest' }}
uses: actions/setup-go@40f1582b2485089dde7abd97c1529aa768e1baff # v5
with:
go-version: "1.22.x"
- name: Setup Node
if: ${{ matrix.os == 'ubuntu-latest' }}
uses: actions/setup-node@49933ea5288caeca8642d1e84afbd3f7d6820020 # v4
with:
node-version: "20.x"
- name: Setup uv
if: ${{ matrix.os == 'ubuntu-latest' }}
uses: astral-sh/setup-uv@caf0cab7a618c569241d31dcd442f54681755d39 # v3
- name: Install core check tooling (Linux)
if: ${{ matrix.os == 'ubuntu-latest' }}
env:
UV_CACHE_DIR: ${{ github.workspace }}/.uv-cache
UV_TOOL_DIR: ${{ github.workspace }}/.uv-tools
run: make install-tools-core
- name: Run core checks (Linux)
if: ${{ matrix.os == 'ubuntu-latest' }}
env:
UV_CACHE_DIR: ${{ github.workspace }}/.uv-cache
UV_TOOL_DIR: ${{ github.workspace }}/.uv-tools
run: make check-core
- name: Run Rust checks (macOS)
if: ${{ matrix.os == 'macos-latest' }}
run: make check-rust
publish-crates:
name: Publish to crates.io
needs: [meta, verify]
runs-on: ubuntu-latest
environment: crates-io
permissions:
contents: read
id-token: write
steps:
- name: Checkout
uses: actions/checkout@34e114876b0b11c390a56381ad16ebd13914f8d5 # v4
with:
ref: ${{ needs.meta.outputs.tag }}
- name: Setup Rust
uses: dtolnay/rust-toolchain@4be9e76fd7c4901c61fb841f559994984270fce7 # stable
with:
toolchain: 1.88.0
- name: Rust cache
uses: Swatinem/rust-cache@779680da715d629ac1d338a641029a2f4372abb5 # v2
- name: Authenticate with crates.io (trusted publishing)
id: crates-auth
uses: rust-lang/crates-io-auth-action@b7e9a28eded4986ec6b1fa40eeee8f8f165559ec # v1
- name: Verify publish payload (dry run)
env:
CARGO_REGISTRY_TOKEN: ${{ steps.crates-auth.outputs.token }}
run: ./scripts/release/publish_crate.sh --dry-run
- name: Publish
env:
CARGO_REGISTRY_TOKEN: ${{ steps.crates-auth.outputs.token }}
run: ./scripts/release/publish_crate.sh
github-release:
name: Create GitHub Release
needs: [meta, verify]
runs-on: ubuntu-latest
permissions:
contents: write
steps:
- name: Checkout
uses: actions/checkout@34e114876b0b11c390a56381ad16ebd13914f8d5 # v4
with:
fetch-depth: 0
ref: ${{ needs.meta.outputs.tag }}
- name: Generate release notes (git-cliff)
id: git-cliff
uses: orhun/git-cliff-action@e16f179f0be49ecdfe63753837f20b9531642772 # v4
with:
config: git-cliff.toml
args: -vv --latest --strip header
env:
OUTPUT: RELEASE_NOTES.md
GITHUB_REPO: ${{ github.repository }}
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
- name: Create GitHub Release
uses: softprops/action-gh-release@a06a81a03ee405af7f2048a818ed3f03bbf83c7b # v2
with:
tag_name: ${{ needs.meta.outputs.tag }}
name: ${{ needs.meta.outputs.tag }}
body: ${{ steps.git-cliff.outputs.content }}
dispatch-homebrew-tap-pr:
name: Dispatch Homebrew Tap PR workflow
needs: [meta, github-release]
runs-on: ubuntu-latest
continue-on-error: true
permissions:
actions: write
contents: read
steps:
- name: Dispatch Homebrew Tap PR workflow
id: dispatch
uses: actions/github-script@f28e40c7f34bde8b3046d885e986cb6290c5673b # v7
with:
github-token: ${{ secrets.GITHUB_TOKEN }}
script: |
const tag = '${{ needs.meta.outputs.tag }}';
const workflowId = 'homebrew-tap-pr.yml';
const ref = context.payload.repository.default_branch;
const { owner, repo } = context.repo;
core.info(`Dispatching ${workflowId} for tag ${tag} on ref ${ref}`);
try {
await github.rest.actions.createWorkflowDispatch({
owner,
repo,
workflow_id: workflowId,
ref,
inputs: { tag },
});
core.info(`Dispatched ${workflowId} with tag=${tag}`);
} catch (error) {
core.error(
`Failed to dispatch ${workflowId} for tag ${tag}: ${error.message}`
);
core.error(
`Manual fallback: gh workflow run ${workflowId} -R ${owner}/${repo} -f tag=${tag}`
);
core.error(
"See RELEASING.md -> Homebrew tap sync flow (example) for dispatch fallback guidance."
);
core.setFailed(error.message);
}
- name: Dispatch fallback guidance
if: ${{ failure() }}
run: |
echo "::warning::Homebrew tap workflow dispatch failed. Crate release remains non-blocking."
echo "::warning::Manual fallback: gh workflow run homebrew-tap-pr.yml -R ${{ github.repository }} -f tag=${{ needs.meta.outputs.tag }}"
echo "::warning::See RELEASING.md -> Homebrew tap sync flow (example)."
build:
name: Build & Upload Binaries
needs: [meta, github-release]
strategy:
fail-fast: false
matrix:
os:
- ubuntu-latest
- macos-latest
- windows-latest
runs-on: ${{ matrix.os }}
permissions:
contents: write
steps:
- name: Checkout
uses: actions/checkout@34e114876b0b11c390a56381ad16ebd13914f8d5 # v4
with:
ref: ${{ needs.meta.outputs.tag }}
- name: Setup Rust
uses: dtolnay/rust-toolchain@4be9e76fd7c4901c61fb841f559994984270fce7 # stable
with:
toolchain: 1.88.0
- name: Rust cache
uses: Swatinem/rust-cache@779680da715d629ac1d338a641029a2f4372abb5 # v2
- name: Build
run: cargo build --release --locked
- name: Package (Unix)
if: runner.os != 'Windows'
shell: bash
run: |
BIN="envgen"
ASSET="envgen-${{ needs.meta.outputs.tag }}-${{ runner.os }}-${{ runner.arch }}.tar.gz"
tar -czf "$ASSET" -C target/release "$BIN"
echo "ASSET=$ASSET" >> "$GITHUB_ENV"
echo "ASSET_PATH=$ASSET" >> "$GITHUB_ENV"
- name: Package (Windows)
if: runner.os == 'Windows'
shell: pwsh
run: |
$bin = "envgen.exe"
$asset = "envgen-${{ needs.meta.outputs.tag }}-${{ runner.os }}-${{ runner.arch }}.zip"
Compress-Archive -Path "target/release/$bin" -DestinationPath $asset -Force
"ASSET=$asset" | Out-File -FilePath $env:GITHUB_ENV -Encoding utf8 -Append
"ASSET_PATH=$asset" | Out-File -FilePath $env:GITHUB_ENV -Encoding utf8 -Append
- name: Upload release asset
uses: svenstaro/upload-release-action@6b7fa9f267e90b50a19fef07b3596790bb941741 # v2
with:
repo_token: ${{ secrets.GITHUB_TOKEN }}
tag: ${{ needs.meta.outputs.tag }}
file: ${{ env.ASSET_PATH }}
asset_name: ${{ env.ASSET }}
overwrite: true
homebrew-core:
name: Open homebrew-core bump PR
needs: [meta, verify, publish-crates]
runs-on: macos-latest
permissions:
contents: read
env:
HOMEBREW_GITHUB_API_TOKEN: ${{ secrets.HOMEBREW_GITHUB_API_TOKEN }}
steps:
- name: Brew update
if: ${{ env.HOMEBREW_GITHUB_API_TOKEN != '' }}
run: brew update
- name: Check formula exists
id: formula
shell: bash
if: ${{ env.HOMEBREW_GITHUB_API_TOKEN != '' }}
run: |
if brew info envgen >/dev/null 2>&1; then
echo "exists=true" >> "$GITHUB_OUTPUT"
else
echo "exists=false" >> "$GITHUB_OUTPUT"
fi
- name: Bump formula PR
if: ${{ env.HOMEBREW_GITHUB_API_TOKEN != '' && steps.formula.outputs.exists == 'true' }}
run: |
brew bump-formula-pr \
--tag "${{ needs.meta.outputs.tag }}" \
--version "${{ needs.meta.outputs.version }}" \
--no-browse \
--no-audit \
envgen