This repository has been archived by the owner on Mar 26, 2024. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 0
70 lines (60 loc) · 1.63 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
61
62
63
64
65
66
67
68
69
name: Build
on:
- push
- pull_request
env:
GOVER: ^1.18
NAME: format-changelog
jobs:
build:
name: build
runs-on: ubuntu-latest
strategy:
matrix:
GOOS: [ windows, linux, darwin ]
GOARCH: [ amd64, 386, arm, arm64 ]
exclude:
- GOOS: windows
GOARCH: arm
- GOOS: darwin
GOARCH: 386
- GOOS: darwin
GOARCH: arm
steps:
- name: Checkout repo
uses: actions/checkout@v3
- name: Cache
uses: actions/cache@v2
with:
path: |
~/.cache/go-build
~/go/pkg/mod
key: ${{ runner.os }}-go-${{ hashFiles('**/go.sum') }}
restore-keys: |
${{ runner.os }}-go-
- name: Setup Go
uses: actions/setup-go@v2
with:
go-version: ${{ env.GOVER }}
- name: Build
env:
GOOS: ${{ matrix.GOOS }}
GOARCH: ${{ matrix.GOARCH }}
run: go build -ldflags="-s -w" -o dist/$NAME-$GOOS-$GOARCH
- name: Rename binaries (Windows)
if: matrix.GOOS == 'windows'
run: for x in dist/$NAME-windows-*; do mv $x $x.exe; done
- name: Compress binary
if: matrix.GOOS != 'windows' || matrix.GOARCH != 'arm64'
uses: crazy-max/ghaction-upx@v1
with:
version: latest
files: |
./dist/*
args: -fq --best --lzma
- name: Upload binary
uses: actions/upload-artifact@v3
with:
name: ${{env.NAME}}-${{ matrix.GOOS }}-${{ matrix.GOARCH }}-${{github.sha}}
path: dist/*
retention-days: 90