-
Notifications
You must be signed in to change notification settings - Fork 0
70 lines (68 loc) · 2.16 KB
/
release.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
name: Release
on:
push:
tags:
- 'v[0-9]+.[0-9]+.[0-9]+*'
jobs:
test:
runs-on: ubuntu-22.04
strategy:
matrix:
goos: ["linux", "darwin"]
goarch: ["amd64", "arm64"]
steps:
- name: Check out code
uses: actions/checkout@v4
with:
fetch-depth: 0 # ensure all history and tags are fetched
- name: Install Go toolchain
uses: actions/setup-go@v5
with:
go-version: "1.22.4"
- name: Get latest Git tag
run: echo "VERSION=$(git describe --tags --abbrev=0)" >> $GITHUB_ENV
- name: Build
run: |
mkdir dist
env GOOS=${{ matrix.goos }} GOARCH=${{ matrix.goarch }} go build -ldflags="-s -w -X 'github.com/rjuer/cidr/cmd.version=$VERSION'" -o dist/
- name: Test
run: |
mkdir tmp
make vet
make test
release:
needs: test
permissions:
contents: write
runs-on: ubuntu-22.04
strategy:
matrix:
goos: ["linux", "darwin"]
goarch: ["amd64", "arm64"]
steps:
- name: Check out code
uses: actions/checkout@v4
with:
fetch-depth: 0 # ensure all history and tags are fetched
- name: Install Go toolchain
uses: actions/setup-go@v5
with:
go-version: "1.22.4"
- name: Get latest Git tag
run: echo "VERSION=$(git describe --tags --abbrev=0)" >> $GITHUB_ENV
- name: Build
run: |
mkdir dist
env GOOS=${{ matrix.goos }} GOARCH=${{ matrix.goarch }} go build -ldflags="-s -w -X 'github.com/rjuer/cidr/cmd.version=$VERSION'" -o dist/cidr-${{ matrix.goos }}-${{ matrix.goarch }}
chmod +x dist/cidr-${{ matrix.goos }}-${{ matrix.goarch }}
- name: Upload artifact
uses: actions/upload-artifact@v4
with:
name: cidr-${{ matrix.goos }}-${{ matrix.goarch }}
path: dist/cidr-${{ matrix.goos }}-${{ matrix.goarch }}
if-no-files-found: error
- name: Release
uses: softprops/action-gh-release@v2
with:
token: ${{ secrets.GITHUB_TOKEN }}
files: dist/cidr-${{ matrix.goos }}-${{ matrix.goarch }}