-
Notifications
You must be signed in to change notification settings - Fork 0
95 lines (95 loc) · 3.31 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
83
84
85
86
87
88
89
90
91
92
93
94
95
name: Build
on: [push]
jobs:
compile:
runs-on: ubuntu-latest
strategy:
matrix:
arch: [amd64, arm64, mips]
os: [darwin, linux]
exclude:
- arch: mips
os: darwin
steps:
- uses: actions/checkout@v3
- name: Set up Go
uses: actions/setup-go@v4
with:
go-version: '1.21'
- name: Build
run: GOOS=${{ matrix.os }} GOARCH=${{ matrix.arch }} go build -tags netgo,osusergo
- name: Upload binary
uses: actions/upload-artifact@v4
with:
name: binary-${{ matrix.os }}-${{ matrix.arch }}
path: mdns2mqtt
if-no-files-found: error
- name: Debian package
if: ${{ matrix.os == 'linux' }}
uses: bpicode/github-action-fpm@master
with:
fpm_opts: -s dir -t deb -n mdns2mqtt -a ${{ matrix.arch }} -v 0.0.0 mdns2mqtt=/usr/bin/mdns2mqtt
- name: Upload .deb package
uses: actions/upload-artifact@v4
if: ${{ matrix.os == 'linux' }}
with:
name: debian-${{ matrix.os }}-${{ matrix.arch }}
path: "*.deb"
if-no-files-found: error
- name: Set up QEMU
if: ${{ matrix.os == 'linux' }}
uses: docker/setup-qemu-action@v3
- name: Set up Docker Buildx
if: ${{ matrix.os == 'linux' }}
uses: docker/setup-buildx-action@v3
- name: Build and load
if: ${{ matrix.os == 'linux' }}
uses: docker/build-push-action@v5
with:
context: .
platforms: ${{ matrix.os }}/${{ matrix.arch }}
outputs: type=docker,dest=/tmp/image-${{ matrix.arch }}.tar
tags: invlid/mdns2mqtt:latest-${{ matrix.arch }}
- name: Upload Docker image
if: ${{ matrix.os == 'linux' }}
uses: actions/upload-artifact@v4
with:
name: docker-image-${{ matrix.arch }}
path: /tmp/image-${{ matrix.arch }}.tar
if-no-files-found: error
lint:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v3
- name: Set up Go
uses: actions/setup-go@v4
with:
go-version: '1.21'
- name: Lint
run: test -z $(gofmt -l .) || (gofmt -d . && exit 1)
publish:
needs: compile
if: github.ref == 'refs/heads/master'
runs-on: ubuntu-latest
steps:
- name: Download artifact
uses: actions/download-artifact@v4
with:
merge-multiple: true
pattern: docker-image-*
path: /tmp
- name: Set up Crane
uses: imjasonh/[email protected]
- name: Log in to Docker registry
run: |
crane auth login -u ${{ secrets.DOCKER_USER }} -p ${{ secrets.DOCKER_PASSWORD }} docker.io
- name: Push images
run: |
crane push /tmp/image-amd64.tar docker.io/invlid/mdns2mqtt:latest-amd64
crane push /tmp/image-arm64.tar docker.io/invlid/mdns2mqtt:latest-arm64
crane push /tmp/image-mips.tar docker.io/invlid/mdns2mqtt:latest-mips
crane index append \
-m docker.io/invlid/mdns2mqtt@$(crane digest --tarball /tmp/image-amd64.tar) \
-m docker.io/invlid/mdns2mqtt@$(crane digest --tarball /tmp/image-arm64.tar) \
-m docker.io/invlid/mdns2mqtt@$(crane digest --tarball /tmp/image-mips.tar) \
-t docker.io/invlid/mdns2mqtt:latest