-
-
Notifications
You must be signed in to change notification settings - Fork 6
78 lines (68 loc) · 1.96 KB
/
pr-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
70
71
72
73
74
75
76
77
78
---
name: Review Code Changes
on:
pull_request:
paths:
- cmd/**.go
- client/**.go
- server/**.go
- ldap/**.go
- server/**.go
- version/**.go
- types/**.go
- go.mod
- go.sum
- main.go
jobs:
build:
name: Build project
runs-on: ubuntu-latest
strategy:
matrix:
go:
- "1.20"
if: ${{ github.actor != 'dependabot[bot]' }}
steps:
- name: Checkout
uses: actions/checkout@v3
- name: Set up Go
uses: actions/setup-go@v2
with:
go-version: ${{ matrix.go }}
- name: Prepare
id: prep
run: |-
echo ::set-output name=buildtime::$(date -u +'%FT%TZ%:z')
echo ::set-output name=go-version::$(go version | sed -r 's/go version go(.+)\s.+/\1/')
- name: Cache
id: 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: Install Dependencies
if: steps.cache.outputs.cache-hit != 'true'
run: |-
go mod download
- name: Build
run: |-
go build \
-trimpath \
-buildmode=pie \
-mod=readonly \
-modcacherw \
-o ${{ secrets.APP_NAME }} \
-ldflags "\
-X ${{ github.repository }}/version.APPNAME=${{ secrets.APP_NAME }} \
-X ${{ github.repository }}/version.VERSION=latest \
-X ${{ github.repository }}/version.GOVERSION=${{ steps.prep.outputs.go-version }} \
-X ${{ github.repository }}/version.BUILDTIME=${{ steps.prep.outputs.buildtime }} \
-X ${{ github.repository }}/version.COMMITHASH=${{ github.sha }} \
-s -w"
- name: Verify
run: |-
./${{ secrets.APP_NAME }} --version