study_xxqg/.github/workflows/ci.yml

52 lines
1.5 KiB
YAML
Raw Normal View History

2021-11-12 07:46:33 +00:00
name: CI
on: [push, pull_request]
env:
BINARY_PREFIX: "study_xxqg_"
BINARY_SUFFIX: ""
PR_PROMPT: "::warning:: Build artifact will not be uploaded due to the workflow is trigged by pull request."
LD_FLAGS: "-w -s"
jobs:
build:
name: Build binary CI
runs-on: ubuntu-latest
strategy:
matrix:
# build and publish in parallel: linux/386, linux/amd64, windows/386, windows/amd64, darwin/amd64, darwin/arm64
2021-12-06 05:54:52 +00:00
goos: [linux, windows, darwin]
goarch: ["386", amd64, arm, arm64]
2021-11-12 07:46:33 +00:00
exclude:
- goos: darwin
goarch: arm
- goos: darwin
goarch: "386"
- goos: windows
goarch: arm64
fail-fast: true
steps:
- uses: actions/checkout@v2
- name: Setup Go environment
uses: actions/setup-go@v2.1.3
with:
go-version: 1.17
- name: Build binary file
env:
GOOS: ${{ matrix.goos }}
GOARCH: ${{ matrix.goarch }}
IS_PR: ${{ !!github.head_ref }}
2022-03-18 02:24:35 +00:00
CGO_ENABLED: 0
2021-11-12 07:46:33 +00:00
run: |
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"
2022-03-18 02:24:35 +00:00
go build -o "output/$BINARY_NAME" ./
2021-11-12 07:46:33 +00:00
- name: Upload artifact
uses: actions/upload-artifact@v2
if: ${{ !github.head_ref }}
with:
name: ${{ matrix.goos }}_${{ matrix.goarch }}
path: output/