Skip to content

Commit d697bb8

Browse files
committed
ci workflow
1 parent 0add670 commit d697bb8

File tree

2 files changed

+59
-3
lines changed

2 files changed

+59
-3
lines changed

.github/workflows/ci.yml

+55
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,55 @@
1+
name: CI
2+
3+
on:
4+
push:
5+
paths:
6+
- '**.go'
7+
pull_request:
8+
workflow_dispatch:
9+
10+
env:
11+
BINARY_PREFIX: "Go-NCMDump_"
12+
BINARY_SUFFIX: ""
13+
COMMIT_ID: "${{ github.sha }}"
14+
PR_PROMPT: "::warning:: Build artifact will not be uploaded due to the workflow is trigged by pull request."
15+
16+
jobs:
17+
build:
18+
name: Build CI
19+
runs-on: ubuntu-latest
20+
strategy:
21+
matrix:
22+
goos: [linux, windows, darwin]
23+
goarch: [amd64, arm64]
24+
fail-fast: true
25+
26+
steps:
27+
- name: Checkout
28+
uses: actions/checkout@v4
29+
with:
30+
submodules: recursive
31+
32+
- name: Setup
33+
uses: actions/setup-go@v5
34+
with:
35+
go-version: '1.22'
36+
37+
- name: Build
38+
env:
39+
GOOS: ${{ matrix.goos }}
40+
GOARCH: ${{ matrix.goarch }}
41+
IS_PR: ${{ !!github.head_ref }}
42+
run: |
43+
if [ $GOOS = "windows" ]; then export BINARY_SUFFIX="$BINARY_SUFFIX.exe"; fi
44+
if $IS_PR ; then echo $PR_PROMPT; fi
45+
export BINARY_NAME="$BINARY_PREFIX"$GOOS"_$GOARCH$BINARY_SUFFIX"
46+
export CGO_ENABLED=0
47+
export LD_FLAGS="-w -s"
48+
go build -o "output/$BINARY_NAME" -trimpath -ldflags "$LD_FLAGS" .
49+
50+
- name: Upload
51+
uses: actions/upload-artifact@v4
52+
if: ${{ !github.head_ref }}
53+
with:
54+
name: ${{ matrix.goos }}_${{ matrix.goarch }}
55+
path: output/

.github/workflows/release.yml

+4-3
Original file line numberDiff line numberDiff line change
@@ -8,19 +8,20 @@ on:
88
jobs:
99
goreleaser:
1010
runs-on: ubuntu-latest
11+
1112
steps:
1213
- name: Checkout
13-
uses: actions/checkout@v2
14+
uses: actions/checkout@v4
1415
with:
1516
submodules: recursive
1617

1718
- name: Set up Go
18-
uses: actions/setup-go@v3
19+
uses: actions/setup-go@v5
1920
with:
2021
go-version: '1.22'
2122

2223
- name: Run GoReleaser
23-
uses: goreleaser/goreleaser-action@v4
24+
uses: goreleaser/goreleaser-action@v5
2425
with:
2526
version: latest
2627
args: release --clean

0 commit comments

Comments
 (0)