-
Notifications
You must be signed in to change notification settings - Fork 0
57 lines (53 loc) · 1.4 KB
/
golang.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
name: Go Module
on:
push:
branches:
- master
pull_request:
types: [opened, synchronize, reopened, closed]
branches:
- master
permissions:
contents: write
actions: write
jobs:
plan_job:
if: github.event_name == 'pull_request' && github.event.action != 'closed'
runs-on: ubuntu-latest
name: "Test go module"
steps:
- name: Checkout
uses: actions/checkout@v4
- name: Setup Go
uses: actions/setup-go@v5.0.0
with:
go-version: "1.21.3"
- name: Install dependencies
run: go get .
- name: Test with Go
run: go test -v
close_pull_request_job:
if: github.event_name == 'push'
runs-on: ubuntu-latest
name: "Publish go module"
steps:
- name: Checkout
uses: actions/checkout@v4
- name: Setup Go
uses: actions/setup-go@v5.0.0
with:
go-version: "1.22.1"
- name: Install dependencies
run: go get .
- name: Semantic Release
uses: go-semantic-release/action@v1.23.0
with:
hooks: goreleaser
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
- name: Publish Module
run: |
git fetch --tags
latest_tag=$(git describe --tags $(git rev-list --tags --max-count=1))
go mod tidy
GOPROXY=proxy.golang.org go list -m github.com/$GITHUB_REPOSITORY@$latest_tag