Skip to content

Commit 06c4ff3

Browse files
committed
ci: Add release workflow for Docker image push
1 parent 287c8f0 commit 06c4ff3

File tree

1 file changed

+75
-0
lines changed

1 file changed

+75
-0
lines changed

.github/workflows/release.yml

+75
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,75 @@
1+
permissions:
2+
contents: write
3+
4+
name: release
5+
on:
6+
push:
7+
tags:
8+
- v*.*.*
9+
- '!v*.*.*-**'
10+
11+
env:
12+
REGISTRY: ghcr.io
13+
IMAGE_NAME: ${{ github.repository }}
14+
15+
jobs:
16+
goreleaser:
17+
runs-on: ubuntu-latest
18+
steps:
19+
- name: Checkout
20+
uses: actions/checkout@v2
21+
- name: Unshallow clone
22+
run: git fetch --prune --unshallow
23+
- name: Install Go 1.21
24+
uses: actions/setup-go@v2
25+
with:
26+
go-version: '1.23.x'
27+
- name: Run GoReleaser
28+
uses: goreleaser/goreleaser-action@v3
29+
with:
30+
args: release --clean
31+
version: latest
32+
env:
33+
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
34+
docker:
35+
runs-on: ubuntu-latest
36+
needs: goreleaser
37+
permissions:
38+
contents: read
39+
packages: write
40+
attestations: write
41+
id-token: write
42+
steps:
43+
- name: Checkout
44+
uses: actions/checkout@v2
45+
- name: Unshallow clone
46+
run: git fetch --prune --unshallow
47+
- name: Install Go 1.19
48+
uses: actions/setup-go@v2
49+
with:
50+
go-version: '1.23.x'
51+
- name: Log in to the Container registry
52+
id: login
53+
uses: docker/[email protected]
54+
with:
55+
registry: ${{ env.REGISTRY }}
56+
username: ${{ github.actor }}
57+
password: ${{ secrets.GITHUB_TOKEN }}
58+
- name: Set image metadata
59+
id: metadata
60+
uses: docker/metadata-action@v5
61+
with:
62+
images: ${{ steps.login.outputs.registry }}/${{ env.IMAGE_NAME}}
63+
tags: |
64+
type=raw,value=latest,enable=true
65+
type=raw,value={{sha}}
66+
type=semver,pattern={{version}}
67+
type=semver,pattern={{raw}}
68+
- name: Build and push Docker image
69+
id: push
70+
uses: docker/[email protected]
71+
with:
72+
context: .
73+
push: true
74+
tags: ${{ steps.metadata.outputs.tags }}
75+
labels: ${{ steps.metadata.outputs.labels }}

0 commit comments

Comments
 (0)