|
84 | 84 | if: matrix.go == 'stable' |
85 | 85 | run: go run golang.org/x/vuln/cmd/govulncheck@latest ./... |
86 | 86 |
|
| 87 | + # Builds the Dockerfile for both published platforms without pushing, so a |
| 88 | + # broken image is caught on the PR rather than during a release. |
| 89 | + docker: |
| 90 | + runs-on: ubuntu-latest |
| 91 | + permissions: |
| 92 | + contents: read |
| 93 | + |
| 94 | + steps: |
| 95 | + - uses: actions/checkout@v7 |
| 96 | + |
| 97 | + - name: Set up Docker Buildx |
| 98 | + uses: docker/setup-buildx-action@v3 |
| 99 | + |
| 100 | + - name: Build image (no push) |
| 101 | + uses: docker/build-push-action@v6 |
| 102 | + with: |
| 103 | + context: . |
| 104 | + platforms: linux/amd64,linux/arm64 |
| 105 | + push: false |
| 106 | + build-args: VERSION=ci |
| 107 | + |
87 | 108 | # Single job that owns release creation. It runs once (not a matrix), so |
88 | 109 | # exactly one job ever creates the release for the tag. The upload-assets |
89 | 110 | # matrix below then only adds files to this already-existing release and can |
|
95 | 116 | # published only after all assets are present, so the public never sees a |
96 | 117 | # partial or empty release. |
97 | 118 | create-release: |
98 | | - needs: build |
| 119 | + needs: [ build, docker ] |
99 | 120 | if: startsWith(github.ref, 'refs/tags/v') |
100 | 121 | runs-on: ubuntu-latest |
101 | 122 | permissions: |
@@ -220,6 +241,68 @@ jobs: |
220 | 241 | env: |
221 | 242 | GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} |
222 | 243 |
|
| 244 | + # Publishes a multi-arch image to GHCR once the release itself is public |
| 245 | + # (#40). The Dockerfile cross-compiles in a build-platform builder stage, so |
| 246 | + # arm64 needs no QEMU. `latest` only moves for non-prerelease tags. |
| 247 | + publish-image: |
| 248 | + needs: publish-release |
| 249 | + if: startsWith(github.ref, 'refs/tags/v') |
| 250 | + runs-on: ubuntu-latest |
| 251 | + permissions: |
| 252 | + contents: read |
| 253 | + packages: write |
| 254 | + id-token: write |
| 255 | + attestations: write |
| 256 | + |
| 257 | + steps: |
| 258 | + - uses: actions/checkout@v7 |
| 259 | + |
| 260 | + # GHCR requires lowercase repository names; the owner is mixed case. |
| 261 | + - name: Compute image name |
| 262 | + id: image |
| 263 | + shell: bash |
| 264 | + env: |
| 265 | + OWNER: ${{ github.repository_owner }} |
| 266 | + run: echo "name=ghcr.io/${OWNER,,}/subenum" >> "$GITHUB_OUTPUT" |
| 267 | + |
| 268 | + - name: Set up Docker Buildx |
| 269 | + uses: docker/setup-buildx-action@v3 |
| 270 | + |
| 271 | + - name: Log in to GHCR |
| 272 | + uses: docker/login-action@v3 |
| 273 | + with: |
| 274 | + registry: ghcr.io |
| 275 | + username: ${{ github.actor }} |
| 276 | + password: ${{ secrets.GITHUB_TOKEN }} |
| 277 | + |
| 278 | + - name: Image metadata |
| 279 | + id: meta |
| 280 | + uses: docker/metadata-action@v5 |
| 281 | + with: |
| 282 | + images: ${{ steps.image.outputs.name }} |
| 283 | + tags: | |
| 284 | + type=semver,pattern={{version}} |
| 285 | + type=semver,pattern={{major}}.{{minor}} |
| 286 | + type=raw,value=latest,enable=${{ !contains(github.ref_name, '-') }} |
| 287 | +
|
| 288 | + - name: Build and push |
| 289 | + id: push |
| 290 | + uses: docker/build-push-action@v6 |
| 291 | + with: |
| 292 | + context: . |
| 293 | + platforms: linux/amd64,linux/arm64 |
| 294 | + push: true |
| 295 | + tags: ${{ steps.meta.outputs.tags }} |
| 296 | + labels: ${{ steps.meta.outputs.labels }} |
| 297 | + build-args: VERSION=${{ github.ref_name }} |
| 298 | + |
| 299 | + - name: Attest image provenance |
| 300 | + uses: actions/attest-build-provenance@v3 |
| 301 | + with: |
| 302 | + subject-name: ${{ steps.image.outputs.name }} |
| 303 | + subject-digest: ${{ steps.push.outputs.digest }} |
| 304 | + push-to-registry: true |
| 305 | + |
223 | 306 | # Failure-path cleanup. If the upload matrix fails partway, publish-release is |
224 | 307 | # skipped and the draft release created above would otherwise linger |
225 | 308 | # invisibly until someone removes it by hand. This job runs only when a |
|
0 commit comments