-
Notifications
You must be signed in to change notification settings - Fork 0
297 lines (265 loc) · 10.9 KB
/
Copy pathrelease.yml
File metadata and controls
297 lines (265 loc) · 10.9 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
name: "🚀 Release"
on:
push:
tags:
- "v*"
concurrency:
group: release-${{ github.ref }}
cancel-in-progress: false
permissions:
contents: read
jobs:
release:
name: "🚀 GoReleaser + Cosign"
runs-on: ubuntu-latest
timeout-minutes: 30
permissions:
contents: write
packages: write
id-token: write
attestations: write
steps:
- name: Harden Runner
uses: step-security/harden-runner@bf7454d06d71f1098171f2acdf0cd4708d7b5920 # v2.20.0
with:
egress-policy: block
allowed-endpoints: >
9236a389bd48b984df91adc1bc924620.r2.cloudflarestorage.com:443
api.github.com:443
auth.docker.io:443
cgr.dev:443
dl-cdn.alpinelinux.org:443
fulcio.sigstore.dev:443
get.anchore.io:443
ghcr.io:443
github.com:443
goreleaser.com:443
packages.wolfi.dev:443
pkg-containers.githubusercontent.com:443
production.cloudflare.docker.com:443
production.cloudfront.docker.com:443
proxy.golang.org:443
raw.githubusercontent.com:443
registry-1.docker.io:443
rekor.sigstore.dev:443
release-assets.githubusercontent.com:443
timestamp.sigstore.dev:443
toolbox-data.anchore.io:443
tuf-repo-cdn.sigstore.dev:443
uploads.github.com:443
- name: Checkout
uses: actions/checkout@3d3c42e5aac5ba805825da76410c181273ba90b1 # v7.0.1
with:
fetch-depth: 0
persist-credentials: false
- name: Setup Go
uses: actions/setup-go@b7ad1dad31e06c5925ef5d2fc7ad053ef454303e # v7.0.0
with:
go-version-file: go.mod
# Release builds are hermetic: no restored module/build cache can
# influence published artifacts (zizmor cache-poisoning). Modules
# are fetched fresh from the proxy on every release.
cache: false
- name: Install cosign
uses: sigstore/cosign-installer@6f9f17788090df1f26f669e9d70d6ae9567deba6 # v4.1.2
- name: Install syft
uses: anchore/sbom-action/download-syft@e22c389904149dbc22b58101806040fa8d37a610 # v0.24.0
- name: Login to GHCR
uses: docker/login-action@dbcb813823bdd20940b903addbd779551569679f # v4.6.0
with:
registry: ghcr.io
username: ${{ github.actor }}
password: ${{ secrets.GITHUB_TOKEN }}
- name: Set up Docker Buildx
uses: docker/setup-buildx-action@bb05f3f5519dd87d3ba754cc423b652a5edd6d2c # v4.2.0
- name: Set up QEMU
uses: docker/setup-qemu-action@96fe6ef7f33517b61c61be40b68a1882f3264fb8 # v4.2.0
- name: Run GoReleaser
uses: goreleaser/goreleaser-action@f06c13b6b1a9625abc9e6e439d9c05a8f2190e94 # v7.2.3
with:
version: "v2.16.0"
args: release --clean
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
HOMEBREW_TAP_TOKEN: ${{ secrets.HOMEBREW_TAP_TOKEN }}
- name: Resolve container manifest digest
id: manifest-digest
shell: bash
run: |
VERSION="${GITHUB_REF_NAME#v}"
DIGEST=$(docker buildx imagetools inspect "ghcr.io/codeswhat/portwing:${VERSION}" \
--format '{{json .Manifest.Digest}}' | tr -d '"' || true)
if [ -z "$DIGEST" ]; then
echo "No manifest digest resolved, skipping image attestation."
fi
echo "digest=$DIGEST" >> "$GITHUB_OUTPUT"
# Attests every artifact listed in checksums.txt: archives, packages, and
# per-archive SBOMs. Verify any one with:
# gh attestation verify <asset> --repo CodesWhat/portwing
# Gated on public visibility: GitHub artifact attestation is not available
# for private repos on this org's plan (cosign blob signatures in
# checksums.txt.bundle still authenticates those assets either way).
- name: Attest checksummed release assets
if: github.event.repository.visibility == 'public'
uses: actions/attest-build-provenance@0f67c3f4856b2e3261c31976d6725780e5e4c373 # v4.1.1
with:
subject-checksums: dist/checksums.txt
# We don't consume GitHub's artifact-metadata catalog; the Sigstore
# attestation (Rekor + gh attestation verify) is the source of truth.
create-storage-record: false
# Container images (per-arch AND manifest lists) are cosign keyless-signed
# by GoReleaser docker_signs; the version-tag manifest additionally gets
# GitHub build provenance here when the repo is public.
- name: Attest container manifest
if: github.event.repository.visibility == 'public' && steps.manifest-digest.outputs.digest != ''
uses: actions/attest-build-provenance@0f67c3f4856b2e3261c31976d6725780e5e4c373 # v4.1.1
with:
subject-name: ghcr.io/codeswhat/portwing
subject-digest: ${{ steps.manifest-digest.outputs.digest }}
push-to-registry: true
# OCI digest subjects have no file artifacts to catalog, so the
# artifact-metadata storage record always errors "no artifacts found".
# The attestation is pushed to the registry and gh-verifiable regardless.
create-storage-record: false
verify-published:
name: "✅ Verify Published"
needs: release
runs-on: ubuntu-latest
timeout-minutes: 15
permissions:
contents: read
packages: read
# Gate: Sigstore public-ledger attestation verification requires the repo to
# be public (so the OIDC token was issued against a public-visible identity).
# On private repos this step is skipped to avoid spurious failures.
if: github.event.repository.visibility == 'public'
steps:
- name: Harden Runner
uses: step-security/harden-runner@bf7454d06d71f1098171f2acdf0cd4708d7b5920 # v2.20.0
with:
egress-policy: block
allowed-endpoints: >
api.github.com:443
ghcr.io:443
github.com:443
pkg-containers.githubusercontent.com:443
release-assets.githubusercontent.com:443
tmaproduction.blob.core.windows.net:443
tuf-repo-cdn.sigstore.dev:443
tuf-repo.github.com:443
- name: Install cosign
uses: sigstore/cosign-installer@6f9f17788090df1f26f669e9d70d6ae9567deba6 # v4.1.2
- name: Pull released image
run: |
VERSION="${GITHUB_REF_NAME#v}"
docker pull "ghcr.io/codeswhat/portwing:${VERSION}"
- name: Verify cosign signature
run: |
VERSION="${GITHUB_REF_NAME#v}"
cosign verify \
--certificate-identity="https://github.com/CodesWhat/portwing/.github/workflows/release.yml@refs/tags/${GITHUB_REF_NAME}" \
--certificate-oidc-issuer="https://token.actions.githubusercontent.com" \
"ghcr.io/codeswhat/portwing:${VERSION}"
- name: Verify gh attestation
run: |
VERSION="${GITHUB_REF_NAME#v}"
gh attestation verify "oci://ghcr.io/codeswhat/portwing:${VERSION}" \
--repo CodesWhat/portwing
env:
GH_TOKEN: ${{ secrets.GITHUB_TOKEN }}
verify-native-packages:
name: "✅ Verify Native Packages"
needs: release
runs-on: ubuntu-latest
timeout-minutes: 15
permissions:
contents: read
steps:
- name: Harden Runner
uses: step-security/harden-runner@bf7454d06d71f1098171f2acdf0cd4708d7b5920 # v2.20.0
with:
egress-policy: block
allowed-endpoints: >
api.github.com:443
auth.docker.io:443
github.com:443
production.cloudflare.docker.com:443
production.cloudfront.docker.com:443
registry-1.docker.io:443
release-assets.githubusercontent.com:443
rekor.sigstore.dev:443
tuf-repo-cdn.sigstore.dev:443
- name: Install cosign
uses: sigstore/cosign-installer@6f9f17788090df1f26f669e9d70d6ae9567deba6 # v4.1.2
- name: Download native packages and signatures
env:
GH_TOKEN: ${{ secrets.GITHUB_TOKEN }}
run: |
mkdir -p packages
gh release download "${GITHUB_REF_NAME}" \
--repo "${GITHUB_REPOSITORY}" \
--pattern "*.deb" \
--pattern "*.deb.bundle" \
--pattern "*.rpm" \
--pattern "*.rpm.bundle" \
--dir packages
- name: Verify native package signatures
run: |
set -euo pipefail
for package in packages/*.deb packages/*.rpm; do
cosign verify-blob \
--certificate-identity="https://github.com/CodesWhat/portwing/.github/workflows/release.yml@refs/tags/${GITHUB_REF_NAME}" \
--certificate-oidc-issuer="https://token.actions.githubusercontent.com" \
--bundle="${package}.bundle" \
"${package}"
done
- name: Verify deb package install
run: |
docker run --rm \
--volume "${PWD}/packages:/packages:ro" \
ubuntu:24.04@sha256:4fbb8e6a8395de5a7550b33509421a2bafbc0aab6c06ba2cef9ebffbc7092d90 \
bash -euxo pipefail -c '
dpkg --install /packages/portwing_*_linux_amd64.deb
/usr/bin/portwing version
test -f /usr/lib/systemd/system/portwing.service
grep -Fq "ExecStart=/usr/bin/portwing" /usr/lib/systemd/system/portwing.service
'
- name: Verify rpm package install
run: |
docker run --rm \
--volume "${PWD}/packages:/packages:ro" \
fedora:42@sha256:99e203b80b1c3d8f7e161ec10a68fd02b081ef83a3963553e513c82846b97814 \
bash -euxo pipefail -c '
rpm --install /packages/portwing_*_linux_amd64.rpm
/usr/bin/portwing version
test -f /usr/lib/systemd/system/portwing.service
grep -Fq "ExecStart=/usr/bin/portwing" /usr/lib/systemd/system/portwing.service
'
verify-homebrew:
name: "✅ Verify Homebrew"
needs: release
if: ${{ !contains(github.ref_name, '-') }}
runs-on: macos-26
timeout-minutes: 15
permissions:
contents: read
env:
HOMEBREW_NO_ANALYTICS: "1"
HOMEBREW_NO_AUTO_UPDATE: "1"
steps:
- name: Harden Runner
uses: step-security/harden-runner@bf7454d06d71f1098171f2acdf0cd4708d7b5920 # v2.20.0
with:
egress-policy: block
allowed-endpoints: >
api.github.com:443
formulae.brew.sh:443
github.com:443
raw.githubusercontent.com:443
release-assets.githubusercontent.com:443
- name: Verify Homebrew cask install
run: |
brew tap CodesWhat/tap https://github.com/CodesWhat/homebrew-tap.git
brew install --cask codeswhat/tap/portwing
portwing version
brew uninstall --cask portwing