-
Notifications
You must be signed in to change notification settings - Fork 2
67 lines (65 loc) · 2.05 KB
/
build.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
name: Build
on:
push:
branches:
- master
- fix/dependencies
tags:
- v*
jobs:
build:
runs-on: ubuntu-latest
strategy:
fail-fast: false
matrix:
binary: ["mystique-server", "ttn-mqtt"]
go: ["^1.19"]
name: Build and Push Docker Image for ${{ matrix.binary }}
steps:
- name: Checkout
uses: actions/checkout@v2
- name: Go Setup
uses: actions/setup-go@v2
with:
go-version: ${{ matrix.go }}
stable: '!contains(${{ matrix.go }}, "beta") && !contains(${{ matrix.go }}, "rc")'
- name: Go Module Cache
uses: actions/cache@v2
with:
path: ~/go/pkg/mod
key: ${{ runner.os }}-go-${{ hashFiles('**/go.sum') }}
restore-keys: |
${{ runner.os }}-go-
- name: Go Dependencies
run: make deps
- name: Build Go Binaries
run: |
GOOS=linux GOARCH=amd64 make release/${{ matrix.binary }}-linux-amd64
GOOS=linux GOARCH=arm64 make release/${{ matrix.binary }}-linux-arm64
- name: Docker meta
id: docker_meta
uses: docker/metadata-action@v3
with:
images: thethingsindustries/${{ matrix.binary }}
tags: |
type=semver,pattern={{version}}
type=semver,pattern={{major}}.{{minor}}
type=raw,value={{date 'YYYYMMDDHHMM'}}
- name: Set up QEMU
uses: docker/setup-qemu-action@v1
- name: Set up Docker Buildx
uses: docker/setup-buildx-action@v1
- name: Login to DockerHub
uses: docker/login-action@v1
with:
username: ${{ secrets.DOCKERHUB_USERNAME }}
password: ${{ secrets.DOCKERHUB_PASSWORD }}
- name: Build and Push Docker Image
uses: docker/build-push-action@v2
with:
context: .
build-args: bin_name=${{ matrix.binary }}
platforms: linux/amd64,linux/arm64
push: true
tags: ${{ steps.docker_meta.outputs.tags }}
labels: ${{ steps.docker_meta.outputs.labels }}