-
Notifications
You must be signed in to change notification settings - Fork 0
240 lines (205 loc) · 7.88 KB
/
release.yml
File metadata and controls
240 lines (205 loc) · 7.88 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
name: Release
on:
push:
tags:
- "v*.*.*"
permissions:
contents: read
jobs:
verify:
name: Verify Release Commit
runs-on: ubuntu-latest
steps:
- name: Checkout
uses: actions/checkout@v4
- name: Setup Node
uses: actions/setup-node@v6
with:
node-version-file: .nvmrc
cache: npm
cache-dependency-path: |
package-lock.json
frontend/package-lock.json
- name: Setup Python
uses: actions/setup-python@v6
with:
python-version: "3.12"
cache: pip
cache-dependency-path: backend/pyproject.toml
- name: Install root tooling
run: npm ci
- name: Install frontend dependencies
run: npm ci
working-directory: frontend
- name: Install backend dependencies
run: |
python -m pip install --upgrade pip
python -m pip install -e ./backend[dev]
- name: Verify generated API types
run: npm run check:contract
- name: Run release verification
run: npm run check
publish-images:
name: Publish GHCR Images
needs: verify
runs-on: ubuntu-latest
permissions:
contents: read
packages: write
id-token: write
attestations: write
artifact-metadata: write
outputs:
backend-attestation-url: ${{ steps.attest-backend.outputs.attestation-url }}
frontend-attestation-url: ${{ steps.attest-frontend.outputs.attestation-url }}
backend-digest: ${{ steps.push-backend.outputs.digest }}
frontend-digest: ${{ steps.push-frontend.outputs.digest }}
steps:
- name: Checkout
uses: actions/checkout@v4
- name: Set lowercase owner
id: vars
run: echo "owner=${GITHUB_REPOSITORY_OWNER,,}" >> "$GITHUB_OUTPUT"
shell: bash
- name: Set up Docker Buildx
uses: docker/setup-buildx-action@v3
- name: Log in to GHCR
uses: docker/login-action@v3
with:
registry: ghcr.io
username: ${{ github.actor }}
password: ${{ secrets.GITHUB_TOKEN }}
- name: Docker metadata for backend
id: meta-backend
uses: docker/metadata-action@v5
with:
images: ghcr.io/${{ steps.vars.outputs.owner }}/nextjs-python-computer-vision-kit-backend
tags: |
type=ref,event=tag
type=semver,pattern={{version}}
type=semver,pattern={{major}}.{{minor}}
type=semver,pattern={{major}}
- name: Docker metadata for frontend
id: meta-frontend
uses: docker/metadata-action@v5
with:
images: ghcr.io/${{ steps.vars.outputs.owner }}/nextjs-python-computer-vision-kit-frontend
tags: |
type=ref,event=tag
type=semver,pattern={{version}}
type=semver,pattern={{major}}.{{minor}}
type=semver,pattern={{major}}
- name: Build and push backend image
id: push-backend
uses: docker/build-push-action@v6
with:
context: ./backend
file: ./backend/Dockerfile
target: runner
push: true
tags: ${{ steps.meta-backend.outputs.tags }}
labels: ${{ steps.meta-backend.outputs.labels }}
cache-from: type=gha
cache-to: type=gha,mode=max
- name: Generate backend provenance attestation
id: attest-backend
uses: actions/attest@v4
with:
subject-name: ghcr.io/${{ steps.vars.outputs.owner }}/nextjs-python-computer-vision-kit-backend
subject-digest: ${{ steps.push-backend.outputs.digest }}
push-to-registry: true
- name: Build and push frontend image
id: push-frontend
uses: docker/build-push-action@v6
with:
context: ./frontend
file: ./frontend/Dockerfile
target: runner
push: true
tags: ${{ steps.meta-frontend.outputs.tags }}
labels: ${{ steps.meta-frontend.outputs.labels }}
cache-from: type=gha
cache-to: type=gha,mode=max
- name: Generate frontend provenance attestation
id: attest-frontend
uses: actions/attest@v4
with:
subject-name: ghcr.io/${{ steps.vars.outputs.owner }}/nextjs-python-computer-vision-kit-frontend
subject-digest: ${{ steps.push-frontend.outputs.digest }}
push-to-registry: true
github-release:
name: Publish GitHub Release
needs: publish-images
runs-on: ubuntu-latest
permissions:
contents: write
packages: read
steps:
- name: Checkout
uses: actions/checkout@v4
- name: Set lowercase owner
id: vars
run: echo "owner=${GITHUB_REPOSITORY_OWNER,,}" >> "$GITHUB_OUTPUT"
shell: bash
- name: Log in to GHCR
uses: docker/login-action@v3
with:
registry: ghcr.io
username: ${{ github.actor }}
password: ${{ secrets.GITHUB_TOKEN }}
- name: Prepare release asset directory
run: mkdir -p dist/release-assets
shell: bash
- name: Generate source SBOM asset
uses: anchore/sbom-action@v0.20.9
with:
path: .
format: spdx-json
syft-version: v1.41.2
output-file: dist/release-assets/repo-source-${{ github.ref_name }}.spdx.json
upload-artifact: false
upload-release-assets: false
- name: Generate backend image SBOM asset
uses: anchore/sbom-action@v0.20.9
with:
image: ghcr.io/${{ steps.vars.outputs.owner }}/nextjs-python-computer-vision-kit-backend@${{ needs.publish-images.outputs.backend-digest }}
format: spdx-json
syft-version: v1.41.2
output-file: dist/release-assets/backend-runner-${{ github.ref_name }}.spdx.json
upload-artifact: false
upload-release-assets: false
- name: Generate frontend image SBOM asset
uses: anchore/sbom-action@v0.20.9
with:
image: ghcr.io/${{ steps.vars.outputs.owner }}/nextjs-python-computer-vision-kit-frontend@${{ needs.publish-images.outputs.frontend-digest }}
format: spdx-json
syft-version: v1.41.2
output-file: dist/release-assets/frontend-runner-${{ github.ref_name }}.spdx.json
upload-artifact: false
upload-release-assets: false
- name: Publish release
uses: softprops/action-gh-release@v2
with:
generate_release_notes: true
append_body: true
files: |
dist/release-assets/repo-source-${{ github.ref_name }}.spdx.json
dist/release-assets/backend-runner-${{ github.ref_name }}.spdx.json
dist/release-assets/frontend-runner-${{ github.ref_name }}.spdx.json
body: |
## Published Images
- `ghcr.io/${{ steps.vars.outputs.owner }}/nextjs-python-computer-vision-kit-backend:${{ github.ref_name }}`
- `ghcr.io/${{ steps.vars.outputs.owner }}/nextjs-python-computer-vision-kit-frontend:${{ github.ref_name }}`
## Provenance Attestations
- Backend image: ${{ needs.publish-images.outputs.backend-attestation-url }}
- Frontend image: ${{ needs.publish-images.outputs.frontend-attestation-url }}
## Attached SBOM Assets
- `repo-source-${{ github.ref_name }}.spdx.json`
- `backend-runner-${{ github.ref_name }}.spdx.json`
- `frontend-runner-${{ github.ref_name }}.spdx.json`
## Verification
```bash
docker login ghcr.io
gh attestation verify oci://ghcr.io/${{ steps.vars.outputs.owner }}/nextjs-python-computer-vision-kit-backend:${{ github.ref_name }} -R ${{ github.repository }}
gh attestation verify oci://ghcr.io/${{ steps.vars.outputs.owner }}/nextjs-python-computer-vision-kit-frontend:${{ github.ref_name }} -R ${{ github.repository }}
```