Skip to content

Commit b066449

Browse files
committed
fix(ci): build check
1 parent 65336db commit b066449

File tree

3 files changed

+31
-10
lines changed

3 files changed

+31
-10
lines changed
Lines changed: 17 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -1,22 +1,24 @@
1-
name: 最新版
1+
name: Build Library
22

33
on:
4-
workflow_run:
5-
workflows: [PushLint, PullLint]
6-
types:
7-
- completed
4+
workflow_call:
5+
inputs:
6+
prefix:
7+
type: string
8+
required: true
9+
upload_artifact:
10+
type: boolean
11+
required: true
812

913
env:
10-
BINARY_PREFIX: "zbp_"
11-
BINARY_SUFFIX: ""
14+
BINARY_SUFFIX: "${{ inputs.prefix }}"
1215
PR_PROMPT: "::warning:: Build artifact will not be uploaded due to the workflow is trigged by pull request."
1316
LD_FLAGS: "-w -s"
1417

1518
jobs:
1619
build:
1720
name: Build binary CI
1821
runs-on: ubuntu-latest
19-
if: ${{ github.event.workflow_run.conclusion == 'success' }}
2022
strategy:
2123
matrix:
2224
# build and publish in parallel: linux/386, linux/amd64, windows/386, windows/amd64, darwin/amd64, darwin/arm64
@@ -34,10 +36,12 @@ jobs:
3436
- uses: actions/checkout@master
3537
with:
3638
fetch-depth: 0
39+
3740
- name: Setup Go environment
3841
uses: actions/setup-go@master
3942
with:
4043
go-version: '^1.25'
44+
4145
- name: Cache downloaded module
4246
uses: actions/cache@master
4347
continue-on-error: true
@@ -46,21 +50,24 @@ jobs:
4650
~/.cache/go-build
4751
~/go/pkg/mod
4852
key: ${{ runner.os }}-go-${{ matrix.goos }}-${{ matrix.goarch }}-${{ hashFiles('**/go.sum') }}
53+
4954
- name: Build binary file
5055
env:
5156
GOOS: ${{ matrix.goos }}
5257
GOARCH: ${{ matrix.goarch }}
53-
IS_PR: ${{ !!github.head_ref }}
58+
IS_PR: ${{ !inputs.upload_artifact }}
59+
BINARY_PREFIX: ${{ inputs.BINARY_PREFIX }}
5460
run: |
5561
GOOS= GOARCH= go generate ./...
5662
if [ $GOOS = "windows" ]; then export BINARY_SUFFIX="$BINARY_SUFFIX.exe"; fi
5763
if $IS_PR ; then echo $PR_PROMPT; fi
5864
export BINARY_NAME="$BINARY_PREFIX$GOOS_$GOARCH$BINARY_SUFFIX"
5965
export CGO_ENABLED=0
6066
go build -o "output/$BINARY_NAME" -trimpath -ldflags "$LD_FLAGS" .
67+
6168
- name: Upload artifact
6269
uses: actions/upload-artifact@master
63-
if: ${{ !github.head_ref }}
70+
if: ${{ inputs.upload_artifact }}
6471
with:
6572
name: ${{ matrix.goos }}_${{ matrix.goarch }}
6673
path: output/

.github/workflows/pull.yml

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -33,3 +33,10 @@ jobs:
3333
uses: ./.github/workflows/lib_run.yml
3434
with:
3535
ref: ${{ github.event.pull_request.head.sha }}
36+
37+
build:
38+
needs: [runmain]
39+
uses: ./.github/workflows/lib_build.yml
40+
with:
41+
prefix: "zbp_"
42+
upload_artifact: false

.github/workflows/push.yml

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -18,3 +18,10 @@ jobs:
1818
uses: ./.github/workflows/lib_run.yml
1919
with:
2020
ref: master
21+
22+
build:
23+
needs: [runmain]
24+
uses: ./.github/workflows/lib_build.yml
25+
with:
26+
prefix: "zbp_"
27+
upload_artifact: true

0 commit comments

Comments
 (0)