-
Notifications
You must be signed in to change notification settings - Fork 1
103 lines (87 loc) · 2.82 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
100
101
102
103
name: Go
on:
push:
branches:
- 'main'
- 'feature/**'
tags:
- 'v*.*.*'
pull_request:
branches: [ main ]
jobs:
build:
name: Build
runs-on: ubuntu-latest
strategy:
matrix:
gover: ["1.19", "1.20", "1.21"]
env:
RELEASE_GO_VER: "1.21"
steps:
- name: "Set up Go ${{ matrix.gover }}"
uses: actions/setup-go@v4
with:
go-version: "${{ matrix.gover }}"
check-latest: true
id: go
- name: Check out code
uses: actions/checkout@v3
- name: Get dependencies
run: |
go get -v -t -d ./...
- name: Verify go fmt
run: test -z "$(go fmt ./...)"
- name: Verify go vet
run: test -z "$(go vet ./...)"
- name: Test
env:
GITHUB_TOKEN: ${{ secrets.GH_RO_TOKEN }}
run: make test
- name: Linting
if: matrix.gover == env.RELEASE_GO_VER
run: make lint
- name: Build artifacts
if: startsWith( github.ref, 'refs/tags/v' ) || github.ref == 'refs/heads/main'
run: make artifacts
- name: Gather release details
if: startsWith( github.ref, 'refs/tags/v' ) && github.repository_owner == 'sudo-bmitch' && matrix.gover == env.RELEASE_GO_VER
id: release_details
run: |
VERSION=${GITHUB_REF#refs/tags/}
VALID_RELEASE=false
if [ -f "release.md" ] && grep -q "Release $VERSION" release.md; then
VALID_RELEASE=true
fi
RELEASE_NOTES=$(cat release.md || echo release notes unavailable)
# escape % and linefeeds
RELEASE_NOTES="${RELEASE_NOTES//'%'/'%25'}"
RELEASE_NOTES="${RELEASE_NOTES//$'\n'/'%0A'}"
RELEASE_NOTES="${RELEASE_NOTES//$'\r'/'%0D'}"
echo ::set-output name=version::${VERSION}
echo ::set-output name=valid::${VALID_RELEASE}
echo ::set-output name=release_notes::${RELEASE_NOTES}
- name: Create release
if: steps.release_details.outputs.valid == 'true' && matrix.gover == env.RELEASE_GO_VER
id: release_create
uses: softprops/action-gh-release@v1
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
with:
tag_name: ${{ steps.release_details.outputs.version }}
body: ${{ steps.release_details.outputs.release_notes }}
draft: false
prerelease: false
files: |
./artifacts/version-bump-darwin-amd64
./artifacts/version-bump-linux-amd64
./artifacts/version-bump-linux-arm64
./artifacts/version-bump-linux-ppc64le
./artifacts/version-bump-linux-s390x
./artifacts/version-bump-windows-amd64.exe
- name: Save artifacts
if: github.ref == 'refs/heads/main' && matrix.gover == env.RELEASE_GO_VER
uses: actions/upload-artifact@v3
with:
name: binaries
path: ./artifacts/
retention-days: 7