-
Notifications
You must be signed in to change notification settings - Fork 0
99 lines (77 loc) · 3.09 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
96
97
98
99
# This workflow will build a golang project
# For more information see: https://docs.github.com/en/actions/automating-builds-and-tests/building-and-testing-go
name: Go
on:
push:
branches: [ "main" ]
tags:
- v*
pull_request:
branches: [ "main" ]
jobs:
test:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v3
- name: Print Github Build Environment
run: echo "$GITHUB_VARS"
shell: bash
env:
GITHUB_VARS: ${{ toJson(github) }}
- name: Set up Go
uses: actions/setup-go@v4
with:
go-version-file: go.mod
- name: Verify dependencies
run: go mod verify
- name: Vet
run: go vet $(go list ./... | grep -v /vendor/)
- name: Install staticcheck
run: go install honnef.co/go/tools/cmd/staticcheck@latest
- name: Run staticcheck
run: staticcheck $(go list ./... | grep -v /vendor/)
- name: Install golint
run: go install golang.org/x/lint/golint@latest
- name: Run golint
run: golint $(go list ./... | grep -v /vendor/)
- name: Compile
run: go build -v ./...
- name: Test
run: go test -v ./...
release:
runs-on: ubuntu-latest
needs:
- test
permissions:
contents: write
if: startsWith(github.ref, 'refs/tags/')
steps:
- uses: actions/checkout@v3
- name: Print Github Build Environment
run: echo "$GITHUB_VARS"
shell: bash
env:
GITHUB_VARS: ${{ toJson(github) }}
- name: Set up Go
uses: actions/setup-go@v4
with:
go-version-file: go.mod
- name: Build Darwin amd64
run: GOOS=darwin GOARCH=amd64 go build -v -ldflags="-X github.com/${{ github.repository }}/version.version=${{ github.ref_name }}" -o ./bin/${{ github.event.repository.name }}-amd64-darwin
- name: Build Darwin arm64
run: GOOS=darwin GOARCH=arm64 go build -v -ldflags="-X github.com/${{ github.repository }}/version.version=${{ github.ref_name }}" -o ./bin/${{ github.event.repository.name }}-arm64-darwin
- name: Build Linux amd64
run: GOOS=linux GOARCH=amd64 go build -v -ldflags="-X github.com/${{ github.repository }}/version.version=${{ github.ref_name }}" -o ./bin/${{ github.event.repository.name }}-amd64-linux
- name: Build Linux arm64
run: GOOS=linux GOARCH=arm64 go build -v -ldflags="-X github.com/${{ github.repository }}/version.version=${{ github.ref_name }}" -o ./bin/${{ github.event.repository.name }}-arm64-linux
- name: Build Windows amd64
run: GOOS=windows GOARCH=amd64 go build -v -ldflags="-X github.com/${{ github.repository }}/version.version=${{ github.ref_name }}" -o ./bin/${{ github.event.repository.name }}-amd64-windows.exe
- name: Release
uses: softprops/action-gh-release@v1
with:
files: |
./bin/${{ github.event.repository.name }}-amd64-darwin
./bin/${{ github.event.repository.name }}-arm64-darwin
./bin/${{ github.event.repository.name }}-amd64-linux
./bin/${{ github.event.repository.name }}-arm64-linux
./bin/${{ github.event.repository.name }}-amd64-windows.exe