Skip to content

Commit 4a2e9ae

Browse files
committed
feat: add GHCR Docker image build to release workflow
1 parent 23c693c commit 4a2e9ae

2 files changed

Lines changed: 52 additions & 1 deletion

File tree

.github/workflows/release.yml

Lines changed: 51 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,7 @@ on:
1313

1414
permissions:
1515
contents: write
16+
packages: write
1617

1718
jobs:
1819
test:
@@ -140,3 +141,53 @@ jobs:
140141
body: ${{ steps.notes.outputs.notes }}
141142
files: dist/*
142143
generate_release_notes: false
144+
145+
docker-image:
146+
name: Docker image
147+
needs: test
148+
runs-on: ubuntu-latest
149+
steps:
150+
- name: Resolve tag
151+
id: tag
152+
run: |
153+
if [ "${{ github.event_name }}" = "workflow_dispatch" ]; then
154+
echo "version=${{ github.event.inputs.tag }}" >> $GITHUB_OUTPUT
155+
else
156+
echo "version=${GITHUB_REF_NAME}" >> $GITHUB_OUTPUT
157+
fi
158+
159+
- uses: actions/checkout@v4
160+
with:
161+
ref: ${{ steps.tag.outputs.version }}
162+
163+
- uses: docker/setup-buildx-action@v3
164+
165+
- name: Log in to GHCR
166+
uses: docker/login-action@v3
167+
with:
168+
registry: ghcr.io
169+
username: ${{ github.actor }}
170+
password: ${{ secrets.GITHUB_TOKEN }}
171+
172+
- name: Extract metadata
173+
id: meta
174+
uses: docker/metadata-action@v5
175+
with:
176+
images: ghcr.io/${{ github.repository }}
177+
tags: |
178+
type=semver,pattern={{version}}
179+
type=semver,pattern={{major}}.{{minor}}
180+
type=raw,value=latest
181+
182+
- name: Build and push
183+
uses: docker/build-push-action@v6
184+
with:
185+
context: .
186+
push: true
187+
platforms: linux/amd64,linux/arm64
188+
tags: ${{ steps.meta.outputs.tags }}
189+
labels: ${{ steps.meta.outputs.labels }}
190+
build-args: |
191+
VERSION=${{ steps.tag.outputs.version }}
192+
cache-from: type=gha
193+
cache-to: type=gha,mode=max

Dockerfile

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
FROM golang:1.23-alpine AS builder
1+
FROM golang:1.25-alpine AS builder
22

33
WORKDIR /app
44

0 commit comments

Comments
 (0)