-
Notifications
You must be signed in to change notification settings - Fork 0
85 lines (74 loc) · 2.52 KB
/
test-build-publish.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
83
84
85
name: Test, build and publish Golang services
on:
push:
branches: [main]
tags:
- "v*.*.*"
env:
DOCKER_HUB_REPO: jenswbe/github-backup
DOCKER_HUB_USER: jenswbebot
PLATFORMS: linux/amd64,linux/arm/v6,linux/arm/v7,linux/arm64
jobs:
build-services:
runs-on: ubuntu-latest
steps:
- name: Checkout
uses: actions/checkout@v4
- name: Derive docker_tag
id: vars
shell: python
run: |
import os, re, sys
tag = os.environ['GITHUB_REF'].split('/').pop()
print(f"Tag: {tag}")
tags = []
semverRegex = r"^v\d+\.\d+\.\d+$"
if tag == 'main':
tags = ['latest']
elif re.match(semverRegex, tag):
tag_parts = tag.split(".")
tags = ['stable', tag, tag_parts[0], f"{tag_parts[0]}.{tag_parts[1]}"]
else:
sys.exit(f"Invalid tag {tag}. Must be main or a semver tag")
images = []
image_base = os.environ['DOCKER_HUB_REPO']
images = [f"{image_base}:{t}" for t in tags]
images_list = ",".join(images)
print(f"Images: {images_list}")
with open(os.environ['GITHUB_OUTPUT'], 'a') as output:
output.write(f"images={images_list}{os.linesep}")
- uses: actions/setup-go@v5
with:
go-version: "1.20"
check-latest: true
- name: Pull common linter configs
run: wget -O .golangci.yml https://raw.githubusercontent.com/JenswBE/setup/main/programming_configs/golang/.golangci.yml
- name: Lint service
uses: golangci/golangci-lint-action@v3
with:
version: latest
args: >-
--timeout=5m
--disable goerr113
- name: Set up QEMU
uses: docker/setup-qemu-action@v3
- name: Set up Docker Buildx
uses: docker/setup-buildx-action@v3
- name: Login to DockerHub
uses: docker/login-action@v3
with:
username: ${{ env.DOCKER_HUB_USER }}
password: ${{ secrets.DOCKER_HUB_PASSWORD }}
- name: Build and push
uses: docker/build-push-action@v5
with:
file: build/package/Dockerfile
platforms: ${{ env.PLATFORMS }}
push: true
tags: ${{ steps.vars.outputs.images }}
- name: Update repo description
uses: peter-evans/dockerhub-description@v4
with:
username: ${{ env.DOCKER_HUB_USER }}
password: ${{ secrets.DOCKER_HUB_PASSWORD }}
repository: ${{ env.DOCKER_HUB_REPO }}