-
Notifications
You must be signed in to change notification settings - Fork 0
82 lines (71 loc) · 2.18 KB
/
go.yml
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
80
81
82
name: Go
on:
push:
branches: [master]
pull_request:
branches: [master]
create:
tags:
- v*
jobs:
build:
name: Build
runs-on: ubuntu-latest
steps:
- name: Set up Go 1.x
uses: actions/setup-go@v5
with:
go-version: ^1.20
id: go
- name: Check out code into the Go module directory
uses: actions/checkout@v4
with:
fetch-depth: 0
- name: Get dependencies
run: |
go get -v -t -d ./...
- name: Build
run: |
go build -v .
go clean
- name: Run GoReleaser
uses: goreleaser/goreleaser-action@v6
if: startsWith(github.ref, 'refs/tags/')
with:
version: latest
args: release --clean
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
- name: Set release version
if: startsWith(github.ref, 'refs/tags/')
run: |
echo "RELEASE_VERSION=${GITHUB_REF#refs/*/}" >> $GITHUB_ENV
echo "RELEASE_VERSION_WITHOUT_V=${GITHUB_REF#refs/*/v}" >> $GITHUB_ENV
- name: Set up QEMU
if: startsWith(github.ref, 'refs/tags/')
uses: docker/setup-qemu-action@v3
- name: Set up Docker Buildx
if: startsWith(github.ref, 'refs/tags/')
uses: docker/setup-buildx-action@v3
- name: Login to GHCR
if: startsWith(github.ref, 'refs/tags/')
uses: docker/login-action@v3
with:
registry: ghcr.io
username: ${{ github.repository_owner }}
password: ${{ secrets.GITHUB_TOKEN }}
- name: Build and push Docker image
if: startsWith(github.ref, 'refs/tags/')
uses: docker/build-push-action@v6
with:
context: .
file: ./Dockerfile
platforms: linux/amd64,linux/arm64
push: true
build-args: |
BUILD_VERSION=${{ env.RELEASE_VERSION_WITHOUT_V }}
labels: |
org.opencontainers.image.source=https://github.com/${{ github.repository }}
tags: |
ghcr.io/${{ github.repository }}:latest
ghcr.io/${{ github.repository }}:${{ env.RELEASE_VERSION_WITHOUT_V }}