Skip to content

Commit abfe76a

Browse files
committed
Push image to ghcr in release
1 parent 2571b89 commit abfe76a

1 file changed

Lines changed: 68 additions & 1 deletion

File tree

.github/workflows/release.yml

Lines changed: 68 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,7 @@ on:
1212

1313
permissions:
1414
contents: write
15+
packages: write
1516

1617
env:
1718
CARGO_TERM_COLOR: always
@@ -254,10 +255,76 @@ jobs:
254255
env:
255256
CARGO_REGISTRY_TOKEN: ${{ secrets.CARGO_REGISTRY_TOKEN }}
256257

258+
# Build and push multi-arch Docker image to GHCR (only on tag push, not dry-run)
259+
docker:
260+
name: Docker Image
261+
if: github.ref_type == 'tag' && !(github.event_name == 'workflow_dispatch' && inputs.dry_run)
262+
runs-on: ubuntu-latest
263+
steps:
264+
- uses: actions/checkout@v4
265+
266+
- name: Set up QEMU
267+
uses: docker/setup-qemu-action@v3
268+
269+
- name: Set up Docker Buildx
270+
uses: docker/setup-buildx-action@v3
271+
272+
- name: Log in to GHCR
273+
uses: docker/login-action@v3
274+
with:
275+
registry: ghcr.io
276+
username: ${{ github.actor }}
277+
password: ${{ secrets.GITHUB_TOKEN }}
278+
279+
- name: Extract metadata
280+
id: meta
281+
uses: docker/metadata-action@v5
282+
with:
283+
images: ghcr.io/${{ github.repository }}
284+
tags: |
285+
type=semver,pattern={{version}}
286+
type=semver,pattern={{major}}.{{minor}}
287+
type=semver,pattern={{major}},enable=${{ !startsWith(github.ref, 'refs/tags/v0.') }}
288+
type=raw,value=latest
289+
290+
- name: Build and push
291+
uses: docker/build-push-action@v6
292+
with:
293+
context: .
294+
platforms: linux/amd64,linux/arm64
295+
push: true
296+
tags: ${{ steps.meta.outputs.tags }}
297+
labels: ${{ steps.meta.outputs.labels }}
298+
cache-from: type=gha
299+
cache-to: type=gha,mode=max
300+
301+
# Build multi-arch Docker image without pushing (dry-run validation)
302+
docker-dry-run:
303+
name: Docker Image (Dry Run)
304+
if: github.event_name == 'workflow_dispatch' && inputs.dry_run
305+
runs-on: ubuntu-latest
306+
steps:
307+
- uses: actions/checkout@v4
308+
309+
- name: Set up QEMU
310+
uses: docker/setup-qemu-action@v3
311+
312+
- name: Set up Docker Buildx
313+
uses: docker/setup-buildx-action@v3
314+
315+
- name: Build (no push)
316+
uses: docker/build-push-action@v6
317+
with:
318+
context: .
319+
platforms: linux/amd64,linux/arm64
320+
push: false
321+
cache-from: type=gha
322+
cache-to: type=gha,mode=max
323+
257324
# Dry-run summary (manual dispatch with dry_run=true)
258325
dry-run-summary:
259326
name: Dry Run Summary
260-
needs: build
327+
needs: [build, docker-dry-run]
261328
if: github.event_name == 'workflow_dispatch' && inputs.dry_run
262329
runs-on: ubuntu-latest
263330
steps:

0 commit comments

Comments
 (0)