修改ci
This commit is contained in:
parent
01981b4d96
commit
7131a95a8b
|
@ -29,11 +29,30 @@ jobs:
|
|||
goarch: arm
|
||||
fail-fast: true
|
||||
steps:
|
||||
- uses: actions/checkout@v2
|
||||
- name: Setup Go environment
|
||||
uses: actions/setup-go@v2.1.3
|
||||
- name: Checkout
|
||||
uses: actions/checkout@v3
|
||||
with:
|
||||
fetch-depth: 0
|
||||
- name: Fetch all tags
|
||||
run: git fetch --force --tags
|
||||
- name: Set up Go
|
||||
uses: actions/setup-go@v3
|
||||
with:
|
||||
go-version: 1.18
|
||||
- name: Cache Go modules
|
||||
uses: actions/cache@v3
|
||||
with:
|
||||
path: |
|
||||
~/.cache/go-build
|
||||
~/go/pkg/mod
|
||||
key: ${{ runner.os }}-go-${{ hashFiles('**/go.sum') }}
|
||||
restore-keys: |
|
||||
${{ runner.os }}-go-
|
||||
- name: Check snapshot
|
||||
if: "!startsWith(github.ref, 'refs/tags/')"
|
||||
id: snapshot
|
||||
run: echo '::set-output name=ARG::--snapshot'
|
||||
|
||||
- name: Build binary file
|
||||
env:
|
||||
GOOS: ${{ matrix.goos }}
|
||||
|
@ -41,11 +60,11 @@ jobs:
|
|||
IS_PR: ${{ !!github.head_ref }}
|
||||
CGO_ENABLED: 0
|
||||
run: |
|
||||
echo $COMMIT_ID
|
||||
echo ${steps.snapshot.outputs.ARG}
|
||||
if [ $GOOS = "windows" ]; then export BINARY_SUFFIX="$BINARY_SUFFIX.exe"; fi
|
||||
if $IS_PR ; then echo $PR_PROMPT; fi
|
||||
export BINARY_NAME="$BINARY_PREFIX$GOOS_$GOARCH$BINARY_SUFFIX"
|
||||
export LD_FLAGS="-w -s -X main.VERSION=${COMMIT_ID::7}"
|
||||
export LD_FLAGS="-w -s -X main.VERSION=${steps.snapshot.outputs.ARG}"
|
||||
go mod tidy
|
||||
go build -o "output/$BINARY_NAME" -trimpath -ldflags "$LD_FLAGS" ./
|
||||
- name: Upload artifact
|
||||
|
|
Loading…
Reference in New Issue