修改ci
This commit is contained in:
parent
01981b4d96
commit
7131a95a8b
|
@ -29,11 +29,30 @@ jobs:
|
||||||
goarch: arm
|
goarch: arm
|
||||||
fail-fast: true
|
fail-fast: true
|
||||||
steps:
|
steps:
|
||||||
- uses: actions/checkout@v2
|
- name: Checkout
|
||||||
- name: Setup Go environment
|
uses: actions/checkout@v3
|
||||||
uses: actions/setup-go@v2.1.3
|
with:
|
||||||
|
fetch-depth: 0
|
||||||
|
- name: Fetch all tags
|
||||||
|
run: git fetch --force --tags
|
||||||
|
- name: Set up Go
|
||||||
|
uses: actions/setup-go@v3
|
||||||
with:
|
with:
|
||||||
go-version: 1.18
|
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
|
- name: Build binary file
|
||||||
env:
|
env:
|
||||||
GOOS: ${{ matrix.goos }}
|
GOOS: ${{ matrix.goos }}
|
||||||
|
@ -41,11 +60,11 @@ jobs:
|
||||||
IS_PR: ${{ !!github.head_ref }}
|
IS_PR: ${{ !!github.head_ref }}
|
||||||
CGO_ENABLED: 0
|
CGO_ENABLED: 0
|
||||||
run: |
|
run: |
|
||||||
echo $COMMIT_ID
|
echo ${steps.snapshot.outputs.ARG}
|
||||||
if [ $GOOS = "windows" ]; then export BINARY_SUFFIX="$BINARY_SUFFIX.exe"; fi
|
if [ $GOOS = "windows" ]; then export BINARY_SUFFIX="$BINARY_SUFFIX.exe"; fi
|
||||||
if $IS_PR ; then echo $PR_PROMPT; fi
|
if $IS_PR ; then echo $PR_PROMPT; fi
|
||||||
export BINARY_NAME="$BINARY_PREFIX$GOOS_$GOARCH$BINARY_SUFFIX"
|
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 mod tidy
|
||||||
go build -o "output/$BINARY_NAME" -trimpath -ldflags "$LD_FLAGS" ./
|
go build -o "output/$BINARY_NAME" -trimpath -ldflags "$LD_FLAGS" ./
|
||||||
- name: Upload artifact
|
- name: Upload artifact
|
||||||
|
|
Loading…
Reference in New Issue