This repository was archived by the owner on Oct 27, 2026. It is now read-only.
Repository navigation
306 lines (299 loc) · 12 KB
/
Copy pathrelease.yml
File metadata and controls
306 lines (299 loc) · 12 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
name: release
on:
push:
tags:
- "v*"
workflow_dispatch:
inputs:
version:
description: Release version without the leading v
required: true
type: string
permissions:
contents: write
id-token: write
attestations: write
concurrency:
group: release-${{ github.ref }}
cancel-in-progress: false
jobs:
audit:
runs-on: ubuntu-latest
timeout-minutes: 10
steps:
- uses: actions/checkout@v7.0.0
- name: Resolve release version
id: version
env:
INPUT_VERSION: ${{ inputs.version }}
run: |
set -euo pipefail
version="${INPUT_VERSION:-${GITHUB_REF_NAME#v}}"
version="${version#v}"
test "$GITHUB_REF" = "refs/tags/v${version}"
source_version=$(sed -n 's/^version = "\([^"]*\)"/\1/p' Cargo.toml | head -n 1)
test "$source_version" = "$version"
echo "value=${version}" >> "$GITHUB_OUTPUT"
- uses: taiki-e/install-action@v2
with:
tool: cargo-audit@0.22.2
- uses: sigstore/cosign-installer@v4.0.0
- name: Audit locked Rust dependencies
env:
VERSION: ${{ steps.version.outputs.value }}
run: |
set -euo pipefail
mkdir -p dist
report="dist/agent-remote-cli-${VERSION}.cargo-audit.json"
cargo audit --json > "$report"
(cd dist && sha256sum "$(basename "$report")" > "$(basename "$report").sha256")
cosign sign-blob --yes --bundle "$report.sigstore.json" "$report"
cosign verify-blob \
--bundle "$report.sigstore.json" \
--certificate-identity \
"https://github.com/${GITHUB_REPOSITORY}/.github/workflows/release.yml@${GITHUB_REF}" \
--certificate-oidc-issuer "https://token.actions.githubusercontent.com" \
"$report"
- uses: actions/upload-artifact@v7.0.1
with:
name: agent-remote-cli-audit
path: |
dist/*.cargo-audit.json
dist/*.cargo-audit.json.sha256
dist/*.cargo-audit.json.sigstore.json
if-no-files-found: error
release:
name: build ${{ matrix.target }}
runs-on: ${{ matrix.os }}
timeout-minutes: 60
environment: production-community-release
strategy:
fail-fast: false
matrix:
include:
- os: ubuntu-latest
target: x86_64-unknown-linux-gnu
- os: ubuntu-latest
target: aarch64-unknown-linux-gnu
- os: macos-15-intel
target: x86_64-apple-darwin
- os: macos-14
target: aarch64-apple-darwin
steps:
- uses: actions/checkout@v7.0.0
- uses: dtolnay/rust-toolchain@stable
with:
targets: ${{ matrix.target }}
- uses: Swatinem/rust-cache@v2.9.2
with:
key: release-${{ matrix.target }}
- uses: actions/setup-go@v6
with:
go-version: "1.24.x"
cache: false
- name: Install Linux ARM64 linker
if: matrix.target == 'aarch64-unknown-linux-gnu'
run: |
sudo apt-get update
sudo apt-get install -y gcc-aarch64-linux-gnu
- name: Install managed-tool build dependencies
run: |
if [[ "${{ runner.os }}" == "Linux" ]]; then
sudo apt-get update
sudo apt-get install -y autoconf automake build-essential bison pkg-config xz-utils
else
brew install automake pkg-config
fi
- name: Restore managed tool binaries
uses: actions/cache@v6.1.0
with:
path: .cache/managed-tools/${{ matrix.target }}
key: managed-tools-v2-${{ runner.os }}-${{ matrix.target }}-${{ hashFiles('scripts/build-managed-tools.sh') }}
- name: Resolve release version
id: version
env:
INPUT_VERSION: ${{ inputs.version }}
run: |
set -euo pipefail
version="${INPUT_VERSION:-${GITHUB_REF_NAME#v}}"
version="${version#v}"
if ! [[ "$version" =~ ^[0-9]+\.[0-9]+\.[0-9]+([-.+][0-9A-Za-z.-]+)?$ ]]; then
echo "invalid semantic version: $version" >&2
exit 2
fi
test "$GITHUB_REF" = "refs/tags/v${version}"
source_version=$(sed -n 's/^version = "\([^"]*\)"/\1/p' Cargo.toml | head -n 1)
test "$source_version" = "$version"
echo "value=${version}" >> "$GITHUB_OUTPUT"
- name: Build release package
env:
CARGO_TARGET_AARCH64_UNKNOWN_LINUX_GNU_LINKER: aarch64-linux-gnu-gcc
CARGO_TARGET_DIR: ${{ runner.temp }}/agent-remote-cli-release-target
DEVICE_APP_SIGNER_CERTIFICATE_SHA1: ${{ vars.COMMUNITY_SIGNER_CERTIFICATE_SHA1 }}
MANAGED_TOOLS_CACHE_DIR: ${{ github.workspace }}/.cache/managed-tools
REQUIRE_DEVICE_SIGNING_IDENTITY: "1"
TARGETS: ${{ matrix.target }}
VERSION: ${{ steps.version.outputs.value }}
run: |
set -euo pipefail
if [[ "$TARGETS" == *-apple-darwin ]]; then
if ! [[ "$DEVICE_APP_SIGNER_CERTIFICATE_SHA1" =~ ^[A-F0-9]{40}$ ]]; then
echo "protected COMMUNITY_SIGNER_CERTIFICATE_SHA1 is missing or invalid" >&2
exit 2
fi
export AGENT_REMOTE_DEVICE_SIGNER_CERTIFICATE_SHA1="$DEVICE_APP_SIGNER_CERTIFICATE_SHA1"
export AGENT_REMOTE_DEVICE_CREDENTIAL_MODE="community-file"
fi
scripts/package-release.sh
- name: Generate package SBOM
uses: anchore/sbom-action@v0
with:
path: dist/agent-remote-cli-${{ steps.version.outputs.value }}-${{ matrix.target }}
format: spdx-json
output-file: dist/agent-remote-cli-${{ steps.version.outputs.value }}-${{ matrix.target }}.spdx.json
- uses: sigstore/cosign-installer@v4.0.0
- name: Sign, attest, and verify package
env:
GH_TOKEN: ${{ github.token }}
TARGET: ${{ matrix.target }}
VERSION: ${{ steps.version.outputs.value }}
run: |
set -euo pipefail
archive="dist/agent-remote-cli-${VERSION}-${TARGET}.tar.gz"
(cd dist && shasum -a 256 --check "$(basename "$archive").sha256")
cosign sign-blob --yes --bundle "$archive.sigstore.json" "$archive"
cosign verify-blob \
--bundle "$archive.sigstore.json" \
--certificate-identity \
"https://github.com/${GITHUB_REPOSITORY}/.github/workflows/release.yml@${GITHUB_REF}" \
--certificate-oidc-issuer "https://token.actions.githubusercontent.com" \
"$archive"
- name: Attest package provenance
uses: actions/attest-build-provenance@v3
with:
subject-path: dist/agent-remote-cli-${{ steps.version.outputs.value }}-${{ matrix.target }}.tar.gz
- name: Verify package provenance
env:
GH_TOKEN: ${{ github.token }}
TARGET: ${{ matrix.target }}
VERSION: ${{ steps.version.outputs.value }}
run: gh attestation verify "dist/agent-remote-cli-${VERSION}-${TARGET}.tar.gz" --repo "$GITHUB_REPOSITORY"
- uses: actions/upload-artifact@v7.0.1
with:
name: agent-remote-cli-${{ matrix.target }}
path: |
dist/*.tar.gz
dist/*.tar.gz.sha256
dist/*.tar.gz.sigstore.json
dist/*.spdx.json
if-no-files-found: error
release-windows:
name: build ${{ matrix.target }}
runs-on: ${{ matrix.os }}
timeout-minutes: 45
strategy:
fail-fast: false
matrix:
include:
- os: windows-latest
target: x86_64-pc-windows-msvc
- os: windows-latest
target: aarch64-pc-windows-msvc
steps:
- uses: actions/checkout@v7.0.0
- uses: dtolnay/rust-toolchain@stable
with:
targets: ${{ matrix.target }}
- uses: Swatinem/rust-cache@v2.9.2
with:
key: release-${{ matrix.target }}
- name: Resolve release version
id: version
shell: pwsh
env:
INPUT_VERSION: ${{ inputs.version }}
run: |
$version = if ($env:INPUT_VERSION) { $env:INPUT_VERSION } else { $env:GITHUB_REF_NAME.TrimStart("v") }
$version = $version.TrimStart("v")
if ($version -notmatch '^[0-9]+\.[0-9]+\.[0-9]+([-.+][0-9A-Za-z.-]+)?$') { throw "invalid semantic version" }
if ($env:GITHUB_REF -ne "refs/tags/v$version") { throw "release must run from the exact version tag" }
$sourceVersion = [regex]::Match((Get-Content Cargo.toml -Raw), '(?m)^version = "([^"]+)"').Groups[1].Value
if ($sourceVersion -ne $version) { throw "source version does not match release version" }
"value=$version" >> $env:GITHUB_OUTPUT
- name: Build release package
shell: pwsh
run: ./scripts/package-release.ps1 -Version "${{ steps.version.outputs.value }}" -Target "${{ matrix.target }}"
- name: Generate package SBOM
uses: anchore/sbom-action@v0
with:
path: dist/agent-remote-cli-${{ steps.version.outputs.value }}-${{ matrix.target }}
format: spdx-json
output-file: dist/agent-remote-cli-${{ steps.version.outputs.value }}-${{ matrix.target }}.spdx.json
- uses: sigstore/cosign-installer@v4.0.0
- name: Sign and verify package
shell: pwsh
run: |
$archive = "dist/agent-remote-cli-${{ steps.version.outputs.value }}-${{ matrix.target }}.zip"
$expected = ((Get-Content "$archive.sha256" -Raw) -split '\s+')[0]
$actual = (Get-FileHash $archive -Algorithm SHA256).Hash.ToLowerInvariant()
if ($actual -ne $expected) { throw "package checksum mismatch" }
cosign sign-blob --yes --bundle "$archive.sigstore.json" "$archive"
if ($LASTEXITCODE -ne 0) { throw "package signing failed" }
cosign verify-blob `
--bundle "$archive.sigstore.json" `
--certificate-identity "https://github.com/$env:GITHUB_REPOSITORY/.github/workflows/release.yml@$env:GITHUB_REF" `
--certificate-oidc-issuer "https://token.actions.githubusercontent.com" `
"$archive"
if ($LASTEXITCODE -ne 0) { throw "package signature verification failed" }
- name: Attest package provenance
uses: actions/attest-build-provenance@v3
with:
subject-path: dist/agent-remote-cli-${{ steps.version.outputs.value }}-${{ matrix.target }}.zip
- name: Verify package provenance
shell: pwsh
env:
GH_TOKEN: ${{ github.token }}
run: gh attestation verify "dist/agent-remote-cli-${{ steps.version.outputs.value }}-${{ matrix.target }}.zip" --repo "$env:GITHUB_REPOSITORY"
- uses: actions/upload-artifact@v7.0.1
with:
name: agent-remote-cli-${{ matrix.target }}
path: |
dist/*.zip
dist/*.zip.sha256
dist/*.zip.sigstore.json
dist/*.spdx.json
if-no-files-found: error
publish:
runs-on: ubuntu-latest
timeout-minutes: 10
needs: [audit, release, release-windows]
steps:
- name: Resolve release version
id: version
env:
INPUT_VERSION: ${{ inputs.version }}
run: |
set -euo pipefail
version="${INPUT_VERSION:-${GITHUB_REF_NAME#v}}"
version="${version#v}"
echo "value=${version}" >> "$GITHUB_OUTPUT"
- uses: actions/download-artifact@v8.0.1
with:
path: dist
merge-multiple: true
- uses: softprops/action-gh-release@v3.0.1
with:
tag_name: v${{ steps.version.outputs.value }}
generate_release_notes: true
fail_on_unmatched_files: true
files: |
dist/*.tar.gz
dist/*.tar.gz.sha256
dist/*.tar.gz.sigstore.json
dist/*.zip
dist/*.zip.sha256
dist/*.zip.sigstore.json
dist/*.spdx.json
dist/*.cargo-audit.json
dist/*.cargo-audit.json.sha256
dist/*.cargo-audit.json.sigstore.json