-
Notifications
You must be signed in to change notification settings - Fork 0
79 lines (67 loc) · 2.21 KB
/
build-and-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
name: Build and publish
on:
push:
branches: [main]
tags:
- "*"
pull_request:
env:
GO_VERSION: "1.22" # Also update Dockerfile when bumping
DOCKER_HUB_USER: jenswbebot
DOCKER_HUB_REPO: jenswbe/encrypted-paper
PLATFORMS: linux/amd64,linux/arm64
jobs:
build-and-publish:
runs-on: ubuntu-latest
steps:
- name: Checkout
uses: actions/checkout@v4
- name: Derive docker_tag
id: vars
shell: python
run: |
import os
tag = os.environ['GITHUB_REF'].split('/').pop()
if tag == 'main':
tag = 'latest'
with open(os.environ['GITHUB_OUTPUT'], 'a') as output:
output.write(f"docker_tag={tag}{os.linesep}")
- name: Setup Go
uses: actions/setup-go@v5
with:
check-latest: true
go-version: ${{ env.GO_VERSION }}
- name: Pull common linter configs
run: wget -O .golangci.yml https://raw.githubusercontent.com/JenswBE/setup/main/programming_configs/golang/.golangci.yml
- name: golangci-lint
uses: golangci/golangci-lint-action@v4
with:
version: latest
args: >-
--timeout=5m
--disable gochecknoinits,goerr113,forbidigo,wrapcheck
- name: Run unit tests
run: go test ./...
- 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
if: github.event_name == 'push'
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:
platforms: ${{ env.PLATFORMS }}
push: ${{ github.event_name == 'push' }}
tags: ${{ env.DOCKER_HUB_REPO }}:${{ steps.vars.outputs.docker_tag }}
- name: Update repo description
if: github.event_name == 'push'
uses: peter-evans/dockerhub-description@v4
with:
username: ${{ env.DOCKER_HUB_USER }}
password: ${{ secrets.DOCKER_HUB_PASSWORD }}
repository: ${{ env.DOCKER_HUB_REPO }}