-
Notifications
You must be signed in to change notification settings - Fork 1
64 lines (54 loc) · 2.01 KB
/
build.yaml
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
name: Build
on:
pull_request:
branches: [ main ]
paths:
- '**.go'
- 'go.mod'
- 'go.sum'
jobs:
test:
name: test
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v3
- name: Set up Go
uses: actions/setup-go@v4
with:
go-version: '1.21'
- name: test
run: go test -v ./...
build:
needs: test
name: Build and Publish Package
runs-on: ubuntu-latest
permissions:
packages: write
steps:
- uses: actions/checkout@v3
- name: Set up Go
uses: actions/setup-go@v4
with:
go-version: '1.21'
- name: Get short SHA
id: sha
run: echo "sha=$(git rev-parse --short HEAD)" >> $GITHUB_OUTPUT
- name: Build binaries
run: |
mkdir -p release
GOOS=linux GOARCH=amd64 go build -tags "netgo osusergo" -o release/evm-exporter-linux-amd64-${{ steps.sha.outputs.sha }} ./cmd/exporter
GOOS=darwin GOARCH=amd64 go build -tags "netgo osusergo" -o release/evm-exporter-darwin-amd64-${{ steps.sha.outputs.sha }} ./cmd/exporter
GOOS=darwin GOARCH=arm64 go build -tags "netgo osusergo" -o release/evm-exporter-darwin-arm64-${{ steps.sha.outputs.sha }} ./cmd/exporter
GOOS=windows GOARCH=amd64 go build -tags "netgo osusergo" -o release/evm-exporter-windows-amd64-${{ steps.sha.outputs.sha }}.exe ./cmd/exporter
- name: Create package archive
run: |
cd release && tar czf ../evm-exporter-${{ steps.sha.outputs.sha }}.tar.gz \
evm-exporter-linux-amd64-${{ steps.sha.outputs.sha }} \
evm-exporter-darwin-amd64-${{ steps.sha.outputs.sha }} \
evm-exporter-darwin-arm64-${{ steps.sha.outputs.sha }} \
evm-exporter-windows-amd64-${{ steps.sha.outputs.sha }}.exe
- name: Upload artifact
uses: actions/upload-artifact@v4
with:
name: evm-exporter-${{ steps.sha.outputs.sha }}
path: evm-exporter-${{ steps.sha.outputs.sha }}.tar.gz