Repository navigation
181 lines (164 loc) · 7.86 KB
/
Copy pathrelease.yaml
File metadata and controls
181 lines (164 loc) · 7.86 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
name: Release
# Pushing a tag vX.Y.Z publishes quay.io/nebari/javo:X.Y.Z (linux/amd64 and
# linux/arm64) and the chart oci://quay.io/nebari/charts/javo X.Y.Z, whose
# image defaults name that image by digest. Both are signed with cosign
# (keyless: the signature names this workflow and the tag) and the image
# carries BuildKit's provenance and an SBOM; site/src/content/docs/
# contributing/index.md shows how to verify them.
on:
push:
tags: ["v*.*.*"]
permissions:
contents: read
concurrency:
group: release-${{ github.ref }}
cancel-in-progress: false
env:
IMAGE: quay.io/nebari/javo
CHARTS: oci://quay.io/nebari/charts
# Go for the javo binaries: the official linux/amd64 release archive and
# the sha256 go.dev publishes for it; go.mod's toolchain line must name
# the same version (checked below).
GO_VERSION: go1.26.11
GO_SHA256: 9849f4e04ee35303714e34fbc3ac8ab44ea3e448a95aa182f91e3b9b79c710ec
# The BuildKit daemon that builds the image, and the SBOM scanner it runs,
# by index digest (DEPENDENCIES.md), instead of the moving tags buildx
# pulls by default.
BUILDKIT_IMAGE: moby/buildkit:v0.34.1@sha256:99368f3e46177c6405b9740e4461d91cee004128daeecca78d4ceac50ec1da5c
SBOM_GENERATOR: docker.io/docker/buildkit-syft-scanner:1.12.0@sha256:ae4f3b554449e7e25548e7d8ccc029d17357348e30c6e3df01b92bc93654d6a9
# Helm 4.3.1 linux/amd64 release binary and the sha256 published with it
# (the same release the Dockerfile's helm stage pins).
HELM_VERSION: v4.3.1
HELM_SHA256: 0403a88ae20913d11b10a2467b50087721fea7581736da6b9d3992f5357fe54b
jobs:
release:
name: Image and chart
runs-on: ubuntu-24.04
# Nothing is restored from a cache, so javo compiles from nothing.
timeout-minutes: 20
# The release environment admits only tags v* (its deployment rule), and
# is where the Quay credentials belong; no other workflow or job reads
# them (test/workflows).
environment: release
permissions:
contents: read
# Reads the CI runs of the tagged commit.
actions: read
# cosign's keyless signing: the OIDC token names this workflow and tag.
id-token: write
steps:
# The tagged commit's files from GitHub's tarball endpoint: under a
# second, where actions/checkout's git fetch takes 8 to 16 s on these
# runners. Nothing here needs the git history.
- name: Fetch the commit
env:
GH_TOKEN: ${{ github.token }}
run: |
curl -fsSL -H "Authorization: Bearer $GH_TOKEN" \
"https://api.github.com/repos/$GITHUB_REPOSITORY/tarball/$GITHUB_SHA" |
tar -xz --strip-components=1
- name: Version from tag
id: version
env:
TAG: ${{ github.ref_name }}
run: |
if ! printf '%s\n' "$TAG" | grep -Eq '^v(0|[1-9][0-9]*)\.(0|[1-9][0-9]*)\.(0|[1-9][0-9]*)$'; then
echo "::error::tag $TAG is not vX.Y.Z"
exit 1
fi
echo "version=${TAG#v}" >> "$GITHUB_OUTPUT"
# Only a commit on main whose Go and UI workflows passed on main is
# released: a tag on an unmerged or failing commit publishes nothing.
# go.yml and ui.yml run on every push to main, so each commit has
# both runs; while they are still going, this fails, and the release
# is re-run once they pass.
- name: Check the commit is on main and passed CI
env:
GH_TOKEN: ${{ github.token }}
run: scripts/release/check-release-commit.sh "$GITHUB_SHA" go.yml ui.yml
- name: Install Go
run: |
want=$(awk '$1 == "toolchain" { print $2 }' go.mod)
if [ "$want" != "$GO_VERSION" ]; then
echo "::error::go.mod names toolchain $want, the release installs $GO_VERSION; update GO_VERSION and GO_SHA256"
exit 1
fi
curl -fsSLo "$RUNNER_TEMP/go.tgz" "https://dl.google.com/go/$GO_VERSION.linux-amd64.tar.gz"
echo "$GO_SHA256 $RUNNER_TEMP/go.tgz" | sha256sum -c -
tar -xzf "$RUNNER_TEMP/go.tgz" -C "$RUNNER_TEMP"
echo "$RUNNER_TEMP/go/bin" >> "$GITHUB_PATH"
# This Go and no other: no download of a toolchain go.mod names.
echo "GOTOOLCHAIN=local" >> "$GITHUB_ENV"
# The image's javo binaries, both architectures at once (the image's
# javo-bin stage is replaced by this folder). No build cache is
# restored (test/workflows): what is signed is compiled from the
# tagged commit and the modules go.sum names, nothing an earlier run
# left behind.
- name: Compile javo
env:
JAVO_VERSION: ${{ github.ref_name }}
JAVO_COMMIT: ${{ github.sha }}
run: scripts/build/cross-build-javo.sh "$RUNNER_TEMP/javo-bin"
# The runner is thrown away after the job, so the builder is not
# removed at the end (about 6 s).
- uses: docker/setup-buildx-action@f87e5991a6d7451dcb8d9637bfbc97413f497069 # v4.4.1
with:
cleanup: false
driver-opts: image=${{ env.BUILDKIT_IMAGE }}
# Quay with the organisation's robot account (QUAY_USERNAME, QUAY_TOKEN).
- uses: docker/login-action@81c6f93d4bc991e510b342a00b419b3bb4efc5c6 # v4.7.0
with:
registry: quay.io
username: ${{ secrets.QUAY_USERNAME }}
password: ${{ secrets.QUAY_TOKEN }}
# Every stage that runs a command runs on this runner's platform; the
# two architectures differ only in the files copied in. No layer cache
# is read or written: every stage is built for this release.
# The index carries BuildKit's provenance (mode=max: the full build
# definition) and an SPDX SBOM for each platform.
- name: Build and push the image
id: image
uses: docker/build-push-action@c3c9e263c25d99ce0380d002d59b67737d91b0dc # v7.4.0
with:
context: .
build-contexts: javo-bin=${{ runner.temp }}/javo-bin
platforms: linux/amd64,linux/arm64
push: true
provenance: mode=max
attests: type=sbom,generator=${{ env.SBOM_GENERATOR }}
tags: ${{ env.IMAGE }}:${{ steps.version.outputs.version }}
# cosign v3.0.6, the release this installer version pins by sha256.
- uses: sigstore/cosign-installer@6f9f17788090df1f26f669e9d70d6ae9567deba6 # v4.1.2
- name: Sign the image
env:
DIGEST: ${{ steps.image.outputs.digest }}
run: cosign sign --yes "$IMAGE@$DIGEST"
- name: Install helm
run: |
curl -fsSLo "$RUNNER_TEMP/helm.tgz" "https://get.helm.sh/helm-$HELM_VERSION-linux-amd64.tar.gz"
echo "$HELM_SHA256 $RUNNER_TEMP/helm.tgz" | sha256sum -c -
tar -xzf "$RUNNER_TEMP/helm.tgz" -C "$RUNNER_TEMP"
echo "$RUNNER_TEMP/linux-amd64" >> "$GITHUB_PATH"
- name: Set the chart's version and image
env:
VERSION: ${{ steps.version.outputs.version }}
DIGEST: ${{ steps.image.outputs.digest }}
run: scripts/release/set-chart-release.sh deploy/helm/javo "$VERSION" "$IMAGE" "$DIGEST"
- name: Package, push and sign the chart
env:
VERSION: ${{ steps.version.outputs.version }}
QUAY_USERNAME: ${{ secrets.QUAY_USERNAME }}
QUAY_TOKEN: ${{ secrets.QUAY_TOKEN }}
run: |
set -o pipefail
helm lint deploy/helm/javo
helm package deploy/helm/javo --destination "$RUNNER_TEMP/chart"
printf '%s' "$QUAY_TOKEN" | helm registry login quay.io --username "$QUAY_USERNAME" --password-stdin
helm push "$RUNNER_TEMP/chart/javo-$VERSION.tgz" "$CHARTS" 2>&1 | tee "$RUNNER_TEMP/push.log"
# helm prints the pushed manifest as "Digest: sha256:...".
digest=$(sed -n 's/^Digest: \(sha256:[0-9a-f]\{64\}\)$/\1/p' "$RUNNER_TEMP/push.log")
if [ -z "$digest" ]; then
echo "::error::helm push printed no digest"
exit 1
fi
cosign sign --yes "${CHARTS#oci://}/javo@$digest"