1
+ name : CI
2
+
3
+ on : [push, pull_request, workflow_dispatch]
4
+
5
+ env :
6
+ BINARY_PREFIX : " disrecall_"
7
+ BINARY_SUFFIX : " "
8
+ COMMIT_ID : " ${{ github.sha }}"
9
+ PR_PROMPT : " ::warning:: Build artifact will not be uploaded due to the workflow is trigged by pull request."
10
+
11
+ jobs :
12
+ build :
13
+ name : Build binary CI
14
+ runs-on : ubuntu-latest
15
+ strategy :
16
+ matrix :
17
+ # build and publish in parallel: linux/386, linux/amd64, windows/386, windows/amd64, darwin/amd64, darwin/arm64
18
+ goos : [linux, windows, darwin]
19
+ goarch : ["386", amd64, arm, arm64]
20
+ exclude :
21
+ - goos : darwin
22
+ goarch : arm
23
+ - goos : darwin
24
+ goarch : " 386"
25
+ fail-fast : true
26
+ steps :
27
+ - uses : actions/checkout@v3
28
+
29
+ - name : Setup Go environment
30
+ uses : actions/setup-go@v3
31
+ with :
32
+ cache : true
33
+ go-version : ' 1.21.4'
34
+
35
+ - name : Build binary file
36
+ env :
37
+ GOOS : ${{ matrix.goos }}
38
+ IS_PR : ${{ !!github.head_ref }}
39
+ BINARY_NAME : ${{ env.BINARY_PREFIX }}${{ matrix.goos }}_${{ matrix.goarch }}${{ env.BINARY_SUFFIX }}
40
+ LD_FLAGS : " -w -s -X github.com/IUnlimit/perpetua/internal/conf.Version=${{ env.COMMIT_ID }}"
41
+ run : |
42
+ if [ $GOOS = "windows" ]; then export BINARY_SUFFIX="$BINARY_SUFFIX.exe"; fi
43
+ if $IS_PR ; then echo $PR_PROMPT; fi
44
+ export CGO_ENABLED=0
45
+ go build -o "output/$BINARY_NAME" -trimpath -ldflags "$LD_FLAGS" .
46
+
47
+ - name : Upload artifact
48
+ uses : actions/upload-artifact@v3
49
+ if : ${{ !github.head_ref }}
50
+ with :
51
+ name : ${{ matrix.goos }}_${{ matrix.goarch }}
52
+ path : output/
0 commit comments