From d3f91c11661a053cb5121721741998af5082a139 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E6=B7=B7=E6=B7=86?= <32300164+mnixry@users.noreply.github.com> Date: Mon, 3 Aug 2020 20:46:21 +0800 Subject: [PATCH] Add build and upload workflow --- .github/workflows/ci.yml | 23 ++++++++++++++++++++++- 1 file changed, 22 insertions(+), 1 deletion(-) diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index cdbcfc9..faa2a8c 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -2,6 +2,13 @@ name: CI on: [push, pull_request] +env: + BINARY_PREFIX: "go-cqhttp_" + BINARY_SUFFIX: "" + PR_PROMPT: "::warning:: Build artifact will not be uploaded due to the workflow is trigged by pull request." + IS_PR: ${{ !!github.head_ref }} + LD_FLAGS: "-w -s" + jobs: build: name: Build binary CI @@ -14,6 +21,7 @@ jobs: exclude: - goos: darwin goarch: arm + fail-fast: true steps: - uses: actions/checkout@v2 @@ -24,7 +32,20 @@ jobs: go-version: 1.14 - name: Build binary file + env: + GOOS: ${{ matrix.goos }} + GOARCH: ${{ matrix.goarch }} run: | - echo ::warning:: Build on ${{ matrix.goos }} - ${{ matrix.goarch }} is not implentmented + 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" + go build -o "output/$BINARY_NAME" -ldflags "$LD_FLAGS" . + + - name: Upload artifact + uses: actions/upload-artifact@v2 + if: ${{ !env.IS_PR }} + with: + name: ${{ matrix.goos }}_${{ matrix.goarch }} + path: output/