-
Notifications
You must be signed in to change notification settings - Fork 15
144 lines (123 loc) · 3.69 KB
/
server-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
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
name: test/build/publish
env:
GO_VERSION: "^1.22.5"
GIT_TAG: ${{github.ref_name}}
on:
push:
branches: [ master, develop ]
tags:
- 'v[0-9]+.[0-9]+.[0-9]+'
- 'v[0-9]+.[0-9]+.[0-9]+.rc[0-9]+'
pull_request:
branches: [ master ]
jobs:
lint:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v3
- name: Setup Go
uses: actions/setup-go@v5
with:
go-version: ${{env.GO_VERSION}}
- name: golangci-lint
uses: golangci/golangci-lint-action@v3
with:
version: v1.59.1
working-directory: cmd
skip-cache: true
args: --timeout=5m
test:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v3
- name: Setup Go
uses: actions/setup-go@v5
with:
go-version: ${{env.GO_VERSION}}
- name: Go tests
run: go test -v ./...
build:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v3
- name: Setup Go
uses: actions/setup-go@v5
with:
go-version: ${{env.GO_VERSION}}
- name: Build Linux
working-directory: ${{env.working-directory}}
run: make build
release:
runs-on: ubuntu-latest
if: startsWith(github.ref, 'refs/tags/v')
needs:
- build
- test
- lint
steps:
- uses: actions/checkout@v3
- name: Build Linux x86
working-directory: ${{env.working-directory}}
run: make build-arch
env:
GOOS: linux
GOARCH: amd64
- name: Build Darwin x86
working-directory: ${{env.working-directory}}
run: make build-arch
env:
GOOS: darwin
GOARCH: amd64
- name: Create Release
uses: actions/create-release@v1
id: create_release
with:
draft: ${{ contains( env.GIT_TAG, '.rc' ) }} #todo: is there no regex match?
prerelease: false
release_name: ${{ env.GIT_TAG }}
tag_name: ${{ env.GIT_TAG }}
env:
GITHUB_TOKEN: ${{ github.token }}
- name: Upload linux x86 artifact
uses: actions/upload-release-asset@v1
env:
GITHUB_TOKEN: ${{ github.token }}
with:
upload_url: ${{ steps.create_release.outputs.upload_url }}
asset_path: ./bin/prometheus-aggregate-exporter-linux-amd64
asset_name: prometheus-aggregate-exporter-linux-amd64
asset_content_type: application/octet-stream
- name: upload darwin x86 artifact
uses: actions/upload-release-asset@v1
env:
GITHUB_TOKEN: ${{ github.token }}
with:
upload_url: ${{ steps.create_release.outputs.upload_url }}
asset_path: ./bin/prometheus-aggregate-exporter-darwin-amd64
asset_name: prometheus-aggregate-exporter-darwin-amd64
asset_content_type: application/octet-stream
publish:
runs-on: ubuntu-latest
if: startsWith(github.ref, 'refs/tags/v') && !contains(github.ref_name, '.rc')
needs:
- build
- test
- lint
env:
working-directory: ./server
steps:
- name: Set up QEMU
uses: docker/setup-qemu-action@v2
- name: Set up Docker Buildx
uses: docker/setup-buildx-action@v2
- name: Login to DockerHub
uses: docker/login-action@v2
with:
username: ${{secrets.DOCKERHUB_USERNAME}}
password: ${{secrets.DOCKERHUB_TOKEN}}
- name: Build and push server
uses: docker/build-push-action@v4
with:
build-args: GIT_TAG=${{env.GIT_TAG}}
push: true
tags: warmans/prometheus-aggregate-exporter:latest,warmans/prometheus-aggregate-exporter:${{env.GIT_TAG}}