-
Notifications
You must be signed in to change notification settings - Fork 32
157 lines (150 loc) · 4.58 KB
/
ci.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
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
name: Build
on:
push:
branches:
- master
tags:
- v*
pull_request:
env:
DEBIAN_FRONTEND: noninteractive
jobs:
lint:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v3
- uses: actions/setup-go@v4
with:
go-version-file: go.mod
- uses: golangci/golangci-lint-action@v3
test:
strategy:
matrix:
os: ["ubuntu-latest", "macos-latest", "windows-latest"]
runs-on: ${{ matrix.os }}
steps:
- uses: actions/checkout@v3
- uses: actions/cache@v3
with:
path: ~/go/pkg/mod
key: ${{ runner.os }}-go-${{ hashFiles('**/go.sum') }}
restore-keys: |
${{ runner.os }}-go-
- uses: actions/setup-go@v4
with:
go-version: 1.19.x
- run: |
go test -race -covermode atomic -coverprofile=profile.cov ./...
shell: bash
- uses: shogo82148/actions-goveralls@v1
with:
github-token: ${{ secrets.GITHUB_TOKEN }}
path-to-profile: profile.cov
parallel: true
flag-name: Go-${{ matrix.os }}
finish:
needs: test
runs-on: ubuntu-latest
steps:
- uses: shogo82148/actions-goveralls@v1
with:
github-token: ${{ secrets.GITHUB_TOKEN }}
parallel-finished: true
build:
needs: [lint, test]
runs-on: ubuntu-latest
if: github.ref == 'refs/heads/master' || startsWith(github.ref, 'refs/tags/v')
steps:
- run: |
sudo apt-get update
sudo apt-get install -y \
rpm devscripts debhelper fakeroot \
crossbuild-essential-arm64 crossbuild-essential-armhf
mkdir -p ~/rpmbuild/{BUILD,BUILDROOT,RPMS,SOURCES,SPECS,SRPMS}
- uses: actions/cache@v3
with:
path: ~/go/pkg/mod
key: ${{ runner.os }}-go-${{ hashFiles('**/go.sum') }}
restore-keys: |
${{ runner.os }}-go-
- uses: actions/setup-go@v4
with:
go-version: 1.19.x
- uses: actions/checkout@v3
- run: make all
- uses: actions/upload-artifact@v3
with:
name: linux-build-artifacts
path: |
~/rpmbuild/RPMS/*/*.rpm
packaging/*.deb
snapshot/*.zip
snapshot/*.tar.gz
build/*.tar.gz
release:
needs: build
runs-on: ubuntu-latest
if: github.ref == 'refs/heads/master' || startsWith(github.ref, 'refs/tags/v')
steps:
- uses: actions/download-artifact@v3
with:
name: linux-build-artifacts
path: artifacts/
- uses: mackerelio/staging-release-update-action@main
if: github.ref == 'refs/heads/master'
with:
directory: artifacts/
github-token: ${{ secrets.GITHUB_TOKEN }}
tag: staging
- uses: mackerelio/create-release-action@main
if: startsWith(github.ref, 'refs/tags/v')
with:
directory: artifacts/
github-token: ${{ secrets.GITHUB_TOKEN }}
tag-prefix: "refs/tags/v"
bump-up-branch-prefix: "bump-version-"
- name: update homebrew-mackerel-agent
if: startsWith(github.ref, 'refs/tags/v')
uses: peter-evans/repository-dispatch@v2
with:
token: ${{ secrets.MACKERELBOT_GITHUB_TOKEN }}
event-type: release
client-payload: '{"product": "mkr"}'
repository: mackerelio/homebrew-mackerel-agent
- uses: 8398a7/action-slack@v3
with:
status: ${{ job.status }}
fields: repo,message,commit,action,eventName,ref,workflow,job,took
username: mkr-release
env:
SLACK_WEBHOOK_URL: ${{ secrets.MACKEREL_SLACK_WEBHOOK_URL }}
build_images_and_push:
if: startsWith(github.ref, 'refs/tags/v')
needs: release
runs-on: ubuntu-latest
steps:
- name: Checkout
uses: actions/checkout@v3
- name: Set up QEMU
uses: docker/setup-qemu-action@v2
- name: Set up Docker Buildx
uses: docker/setup-buildx-action@v2
- name: Login to Docker Hub
uses: docker/login-action@v2
with:
username: ${{ secrets.DOCKERHUB_USERNAME }}
password: ${{ secrets.DOCKERHUB_TOKEN }}
- name: Get tag
id: get_tag
run: echo "::set-output name=tag::${GITHUB_REF##*/}"
- name: Build and push
uses: docker/build-push-action@v5
with:
context: .
platforms: |
linux/amd64
linux/arm64
push: true
tags: |
mackerel/mkr:latest
mackerel/mkr:${{ steps.get_tag.outputs.tag }}