Skip to content

Commit 213b838

Browse files
committed
GH actions
1 parent db89a11 commit 213b838

File tree

4 files changed

+133
-45
lines changed

4 files changed

+133
-45
lines changed

.github/workflows/build.yaml

Lines changed: 41 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,41 @@
1+
name: build
2+
3+
on:
4+
push:
5+
branches:
6+
- '**'
7+
8+
jobs:
9+
build:
10+
runs-on: ubuntu-latest
11+
steps:
12+
- name: Checkout
13+
uses: actions/checkout@v3
14+
- name: Setup go
15+
uses: actions/setup-go@v4
16+
with:
17+
go-version: '1.20'
18+
check-latest: true
19+
- run: go version
20+
- name: Run build
21+
run: make clean build
22+
- name: Run test
23+
run: make test.race
24+
- name: Set up QEMU
25+
uses: docker/setup-qemu-action@v2
26+
- name: Set up Docker Buildx
27+
uses: docker/setup-buildx-action@v2
28+
- name: Docker build base
29+
uses: docker/build-push-action@v4
30+
with:
31+
context: .
32+
push: false
33+
build-args: |
34+
MAKE_TARGET=test build
35+
- name: Docker build all
36+
uses: docker/build-push-action@v4
37+
with:
38+
context: .
39+
push: false
40+
build-args: |
41+
MAKE_TARGET=all

.github/workflows/release.yaml

Lines changed: 87 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,87 @@
1+
name: release
2+
3+
on:
4+
push:
5+
tags:
6+
- '*'
7+
8+
permissions:
9+
contents: write
10+
11+
jobs:
12+
build-and-release:
13+
runs-on: ubuntu-latest
14+
steps:
15+
- name: Checkout
16+
uses: actions/checkout@v3
17+
- name: Setup go
18+
uses: actions/setup-go@v4
19+
with:
20+
go-version: '1.20'
21+
check-latest: true
22+
- run: go version
23+
- name: Run build and test
24+
run: make clean build test
25+
- name: Docker meta
26+
id: meta
27+
uses: docker/metadata-action@v4
28+
with:
29+
images: |
30+
grepplabs/mqtt-proxy
31+
tags: |
32+
type=ref,event=branch
33+
type=ref,event=pr
34+
type=semver,pattern={{version}}
35+
type=semver,pattern={{major}}.{{minor}}
36+
type=semver,pattern={{major}}
37+
type=sha
38+
- name: Docker meta - all
39+
id: meta-all
40+
uses: docker/metadata-action@v4
41+
with:
42+
images: |
43+
grepplabs/mqtt-proxy
44+
flavor: |
45+
suffix=-all
46+
tags: |
47+
type=ref,event=branch
48+
type=ref,event=pr
49+
type=semver,pattern={{version}}
50+
type=semver,pattern={{major}}.{{minor}}
51+
type=semver,pattern={{major}}
52+
type=sha
53+
- name: Set up QEMU
54+
uses: docker/setup-qemu-action@v2
55+
- name: Set up Docker Buildx
56+
uses: docker/setup-buildx-action@v2
57+
- name: Login to DockerHub
58+
uses: docker/login-action@v2
59+
with:
60+
username: ${{ secrets.DOCKERHUB_USERNAME }}
61+
password: ${{ secrets.DOCKERHUB_TOKEN }}
62+
- name: Docker build and push
63+
uses: docker/build-push-action@v4
64+
with:
65+
context: .
66+
push: false
67+
build-args: |
68+
MAKE_TARGET=test build
69+
tags: ${{ steps.meta.outputs.tags }}
70+
labels: ${{ steps.meta.outputs.labels }}
71+
- name: Docker build and push - all
72+
uses: docker/build-push-action@v4
73+
with:
74+
context: .
75+
push: false
76+
build-args: |
77+
MAKE_TARGET=all
78+
tags: ${{ steps.meta-all.outputs.tags }}
79+
labels: ${{ steps.meta-all.outputs.labels }}
80+
- name: Run GoReleaser
81+
uses: goreleaser/goreleaser-action@v4
82+
if: startsWith(github.ref, 'refs/tags/')
83+
with:
84+
version: latest
85+
args: release --clean
86+
env:
87+
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}

.travis.yml

Lines changed: 0 additions & 41 deletions
This file was deleted.

Makefile

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -24,10 +24,10 @@ PROTOC := $(PROTOC_BIN_DIR)/protoc
2424
default: build
2525

2626
test.race:
27-
go test -v -race -count=1 `go list ./...`
27+
go test -v -race -count=1 -mod=vendor `go list ./...`
2828

2929
test:
30-
go test -v -count=1 `go list ./...`
30+
go test -v -count=1 -mod=vendor `go list ./...`
3131

3232
fmt:
3333
go fmt $(GOPKGS)
@@ -36,11 +36,12 @@ check:
3636
golint $(GOPKGS)
3737
go vet $(GOPKGS)
3838

39-
39+
.PHONY: build
4040
build: build/$(BINARY)
4141

42+
.PHONY: build/$(BINARY)
4243
build/$(BINARY): $(SOURCES)
43-
GOOS=$(GOOS) GOARCH=$(GOARCH) CGO_ENABLED=0 go build -o build/$(BINARY) $(BUILD_FLAGS) -ldflags "$(LDFLAGS)" .
44+
GOOS=$(GOOS) GOARCH=$(GOARCH) CGO_ENABLED=0 go build -mod=vendor -o build/$(BINARY) $(BUILD_FLAGS) -ldflags "$(LDFLAGS)" .
4445

4546
tag:
4647
git tag $(TAG)

0 commit comments

Comments
 (0)