-
Notifications
You must be signed in to change notification settings - Fork 7
46 lines (40 loc) · 1.13 KB
/
go.test-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
name: "Go: Attempt build"
on:
push:
paths:
- .github/workflows/go.test-build.yml
- "**/*.go"
jobs:
prepare:
runs-on: ubuntu-latest
steps:
- name: Checkout
uses: actions/checkout@v4
- name: Set target tags
id: set-tags-matrix
run: echo "::set-output name=matrix::$(ls cmd | jq -cnR '[inputs | select(length>0)]')"
- name: Go version
id: go_version
run: echo "::set-output name=version::$(sed -n '3p' go.mod | grep -Eo '\d.\d+')"
outputs:
go_version: ${{ steps.go_version.outputs.version }}
matrix: ${{ steps.set-tags-matrix.outputs.matrix }}
build:
runs-on: ubuntu-latest
needs: [prepare]
strategy:
matrix:
dir: ${{fromJson(needs.prepare.outputs.matrix)}}
steps:
- name: Checkout
uses: actions/checkout@v4
- name: Set up Go 1.22
uses: actions/setup-go@v5
with:
go-version: 1.22
- name: Go Modules
run: go mod download
- name: Attempt build
run: go build -ldflags="-s -w" -buildvcs=false ./cmd/${{ matrix.dir }}
env:
CGO_ENABLED: 0