-
-
Notifications
You must be signed in to change notification settings - Fork 2
60 lines (56 loc) · 1.96 KB
/
build.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
name: Golang Build
on: [push]
jobs:
build:
strategy:
matrix:
go: ['1.16']
goos: ['linux']
goarch: ['amd64', 'arm64']
runs-on: ubuntu-20.04
steps:
- uses: actions/checkout@v2
- name: Install Go
uses: actions/setup-go@v2
with:
go-version: ${{ matrix.go }}
- name: Cache Go Modules
uses: actions/cache@v2
with:
path: |
~/go/pkg/mod
~/.cache/go-build
'%LocalAppData%\go-build'
key: ${{ runner.os }}-go${{ matrix.go }}-${{ matrix.goos }}-${{ matrix.goarch }}-${{ hashFiles('**/go.sum') }}
restore-keys: |
${{ runner.os }}-go${{ matrix.go }}-${{ matrix.goos }}-${{ matrix.goarch }}
- name: Prepare Build
id: prepare
run: |
GO_PKG=`head -n 1 go.mod | awk '{print $2}'`
VERSION=`git rev-parse --short HEAD`
TAG=`git tag --points-at HEAD`
BUILD_FLAGS="-s -w -X ${GO_PKG}/autodns/cmd.sha1ver=${VERSION} -X ${GO_PKG}/autodns/cmd.gitTag=${TAG}"
BUILD_ARGS="-v -trimpath -ldflags=\"${BUILD_FLAGS}\""
echo ::set-output name=build_args::${BUILD_ARGS}
echo ::set-output name=tag::${TAG}
mkdir build
- name: Build
env:
CGO_ENABLED: 0
GOOS: ${{ matrix.goos }}
GOARCH: ${{ matrix.goarch }}
run: go build ${{ steps.prepare.outputs.build_args }} -o ./build/autodns-${{ matrix.goos }}-${{ matrix.goarch }} ./autodns
- name: Upload Binary
uses: actions/upload-artifact@v2
with:
name: autodns-go${{ matrix.go }}-${{ matrix.goos }}-${{ matrix.goarch }}
path: ./build/*
- name: Release
if: startsWith(github.ref, 'refs/tags/')
uses: softprops/action-gh-release@v1
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
with:
name: AutoDNS ${{ steps.prepare.outputs.tag }}
files: ./build/*