-
Notifications
You must be signed in to change notification settings - Fork 1
79 lines (66 loc) · 2.04 KB
/
release-docker-images.yaml
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
name: Build Docker image
on:
release:
types: [created]
workflow_dispatch:
inputs:
release:
description: 'Release tag where to create the binaries (as SemVer vX.X.X)'
required: true
default: v0.1.0
permissions:
contents: write
packages: write
jobs:
build:
runs-on: ubuntu-latest
steps:
- id: read_tag
name: Read release tag name (mostly vx.x.x)
run: |
if [ "${{ github.event_name }}" = "release" ]; then
export TAG="${{ github.ref_name }}"
elif [ "${{ github.event_name }}" = "workflow_dispatch" ]; then
export TAG="${{ inputs.release }}"
fi
echo "release_tag=${TAG}" >> "$GITHUB_OUTPUT"
- name: Checkout
uses: actions/checkout@v4
with:
ref: ${{ steps.read_tag.outputs.release_tag }}
- name: Read Go version from go.mod
id: read_go_version
run: |
go_version_raw=$(grep "^go " go.mod | awk '{print $2}')
echo "go_version=${go_version_raw}" >> "$GITHUB_OUTPUT"
- name: Set up Go
uses: actions/setup-go@v5
with:
go-version: '${{ steps.read_go_version.outputs.go_version }}'
- name: Set up QEMU
id: qemu
uses: docker/setup-qemu-action@v3
with:
image: tonistiigi/binfmt:latest
platforms: all
- name: Set up Docker Buildx
id: buildx
uses: docker/setup-buildx-action@v3
- name: Docker Login
uses: docker/login-action@v3
with:
registry: ghcr.io
username: ${{ github.actor }}
password: ${{ secrets.GITHUB_TOKEN }}
- id: build
name: Build and push Docker images
env:
RELEASE_TAG: ${{ steps.read_tag.outputs.release_tag }}
run: |
export IMG="ghcr.io/$GITHUB_REPOSITORY:$RELEASE_TAG"
if grep -q '^docker-buildx:' Makefile; then
make docker-buildx
else
make docker-build
make docker-push
fi