-
Notifications
You must be signed in to change notification settings - Fork 0
176 lines (154 loc) · 5.73 KB
/
release.yaml
File metadata and controls
176 lines (154 loc) · 5.73 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
name: release
on:
push:
tags:
- "v*.*.*"
permissions:
contents: write # create GitHub Release
packages: write # push to ghcr.io
id-token: write # cosign keyless + build provenance
attestations: write # build provenance attestation
env:
REGISTRY: ghcr.io
jobs:
release:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
with:
fetch-depth: 0
# OCI references must be lowercase; ${{ github.repository }} preserves
# case (e.g. "Varashi/..."). docker CLI tolerates this silently, but
# syft and other strict parsers reject it. Normalize once here.
- name: Normalize names
run: |
echo "IMAGE_NAME=${GITHUB_REPOSITORY,,}" >> "$GITHUB_ENV"
echo "CHART_REPO=ghcr.io/${GITHUB_REPOSITORY_OWNER,,}/charts" >> "$GITHUB_ENV"
- name: Resolve version
id: ver
run: |
tag="${GITHUB_REF_NAME}"
version="${tag#v}"
echo "tag=${tag}" >> "$GITHUB_OUTPUT"
echo "version=${version}" >> "$GITHUB_OUTPUT"
- name: Extract CHANGELOG section
id: changelog
run: |
version="${{ steps.ver.outputs.version }}"
awk -v v="$version" '
$0 ~ "^## \\[" v "\\]" { flag=1; next }
flag && $0 ~ "^## \\[" { exit }
flag { print }
' CHANGELOG.md > RELEASE_BODY.md
if [ ! -s RELEASE_BODY.md ]; then
echo "See [CHANGELOG.md](./CHANGELOG.md)." > RELEASE_BODY.md
fi
- uses: docker/setup-qemu-action@v3
- uses: docker/setup-buildx-action@v3
- name: Log in to ghcr.io
uses: docker/login-action@v3
with:
registry: ${{ env.REGISTRY }}
username: ${{ github.actor }}
password: ${{ secrets.GITHUB_TOKEN }}
- name: Docker metadata
id: meta
uses: docker/metadata-action@v5
with:
images: ${{ env.REGISTRY }}/${{ env.IMAGE_NAME }}
tags: |
type=semver,pattern={{version}}
type=semver,pattern={{major}}.{{minor}}
type=semver,pattern={{major}}
type=raw,value=latest
- name: Build and push (multi-arch)
id: build
uses: docker/build-push-action@v6
with:
context: .
platforms: linux/amd64,linux/arm64
push: true
tags: ${{ steps.meta.outputs.tags }}
labels: ${{ steps.meta.outputs.labels }}
provenance: true
# SBOM is produced downstream by anchore/sbom-action and attached
# as a cosign attestation, so skip the buildx-embedded SBOM to
# avoid two different SBOMs against the same digest.
sbom: false
cache-from: type=gha
cache-to: type=gha,mode=max
- name: Install cosign
uses: sigstore/cosign-installer@v3
- name: Cosign keyless sign
env:
DIGEST: ${{ steps.build.outputs.digest }}
IMAGE: ${{ env.REGISTRY }}/${{ env.IMAGE_NAME }}
# All tags point at the same digest; sign the digest once rather
# than re-signing it per tag.
run: cosign sign --yes "${IMAGE}@${DIGEST}"
- name: Generate SBOM (SPDX)
uses: anchore/sbom-action@v0
with:
image: ${{ env.REGISTRY }}/${{ env.IMAGE_NAME }}@${{ steps.build.outputs.digest }}
format: spdx-json
output-file: sbom.spdx.json
upload-release-assets: false
upload-artifact: false
- name: Attest build provenance
uses: actions/attest-build-provenance@v2
with:
subject-name: ${{ env.REGISTRY }}/${{ env.IMAGE_NAME }}
subject-digest: ${{ steps.build.outputs.digest }}
push-to-registry: true
- name: Attach SBOM to image
env:
DIGEST: ${{ steps.build.outputs.digest }}
IMAGE: ${{ env.REGISTRY }}/${{ env.IMAGE_NAME }}
run: |
cosign attest --yes --predicate sbom.spdx.json \
--type spdxjson \
"${IMAGE}@${DIGEST}"
- uses: azure/setup-helm@v4
with:
version: v3.16.3
- name: Package Helm chart
run: |
version="${{ steps.ver.outputs.version }}"
helm package chart/ \
--version "${version}" \
--app-version "${version}" \
--destination .
- name: Helm registry login
run: |
echo "${{ secrets.GITHUB_TOKEN }}" \
| helm registry login ${{ env.REGISTRY }} \
--username ${{ github.actor }} --password-stdin
- name: Push Helm chart (OCI)
id: chart_push
run: |
version="${{ steps.ver.outputs.version }}"
# helm push prints "Digest: sha256:..." to stderr; tee to capture.
helm push "gpu-node-vsphere-maintenance-controller-${version}.tgz" \
"oci://${{ env.CHART_REPO }}" 2>&1 | tee push.log
digest=$(awk '/^Digest: /{print $2}' push.log)
if [ -z "$digest" ]; then
echo "Failed to capture chart digest" >&2
exit 1
fi
echo "digest=${digest}" >> "$GITHUB_OUTPUT"
- name: Cosign keyless sign (chart)
env:
DIGEST: ${{ steps.chart_push.outputs.digest }}
CHART_REF: ${{ env.CHART_REPO }}/gpu-node-vsphere-maintenance-controller
run: cosign sign --yes "${CHART_REF}@${DIGEST}"
- name: Create GitHub Release
uses: softprops/action-gh-release@v2
with:
tag_name: ${{ steps.ver.outputs.tag }}
name: ${{ steps.ver.outputs.tag }}
body_path: RELEASE_BODY.md
draft: false
prerelease: false
files: |
sbom.spdx.json
gpu-node-vsphere-maintenance-controller-${{ steps.ver.outputs.version }}.tgz