From f70398342e8534bc25b3276011a689a4e8171861 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 15:48:47 +0800 Subject: [PATCH 1/6] Exclude build for darwin_arm --- .github/workflows/release.yml | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/.github/workflows/release.yml b/.github/workflows/release.yml index 4b0d29c..dd12bb7 100644 --- a/.github/workflows/release.yml +++ b/.github/workflows/release.yml @@ -11,6 +11,10 @@ jobs: # build and publish in parallel: linux/386, linux/amd64, windows/386, windows/amd64, darwin/386, darwin/amd64 goos: [linux, windows, darwin] goarch: ["386", amd64, arm] + exclude: + - goos: darwin + goarch: arm + steps: - uses: actions/checkout@v2 - uses: wangyoucao577/go-release-action@master From fe8b0fabc419c1ac4e06cacd169fb14f9e9e6a55 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:08:21 +0800 Subject: [PATCH 2/6] Add ci.yml to automatic build binary --- .github/workflows/ci.yml | 30 ++++++++++++++++++++++++++++++ 1 file changed, 30 insertions(+) create mode 100644 .github/workflows/ci.yml diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml new file mode 100644 index 0000000..47593da --- /dev/null +++ b/.github/workflows/ci.yml @@ -0,0 +1,30 @@ +name: CI + +on: [push, pull_request] + +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/386, darwin/amd64 + goos: [linux, windows, darwin] + goarch: ["386", amd64, arm] + exclude: + - goos: darwin + goarch: arm + + steps: + - uses: actions/checkout@v2 + + - name: Setup Go environment + uses: actions/setup-go@v2.1.1 + with: + go-version: 1.14 + + - name: Build binary file + run: | + echo ::warning:: Build on ${{ matrix.goos }} - ${{ matrix.goarch }} is not implentmented + + From b93a3c14b5440c118c9fd055fc5fd46a092e991c 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:09:52 +0800 Subject: [PATCH 3/6] Fix syntax error in ci.yml --- .github/workflows/ci.yml | 14 +++++++------- 1 file changed, 7 insertions(+), 7 deletions(-) diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index 47593da..cdbcfc9 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -7,13 +7,13 @@ jobs: name: Build binary CI runs-on: ubuntu-latest strategy: - matrix: - # build and publish in parallel: linux/386, linux/amd64, windows/386, windows/amd64, darwin/386, darwin/amd64 - goos: [linux, windows, darwin] - goarch: ["386", amd64, arm] - exclude: - - goos: darwin - goarch: arm + matrix: + # build and publish in parallel: linux/386, linux/amd64, windows/386, windows/amd64, darwin/386, darwin/amd64 + goos: [linux, windows, darwin] + goarch: ["386", amd64, arm] + exclude: + - goos: darwin + goarch: arm steps: - uses: actions/checkout@v2 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 4/6] 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/ From ff09c0da3eeabeeddd07db1aabb6be67d794c912 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:51:51 +0800 Subject: [PATCH 5/6] Fix artifact uploads are disabled unconditionally --- .github/workflows/ci.yml | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index faa2a8c..a05aa29 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -6,7 +6,6 @@ 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: @@ -35,6 +34,7 @@ jobs: env: GOOS: ${{ matrix.goos }} GOARCH: ${{ matrix.goarch }} + IS_PR: ${{ !!github.head_ref }} run: | if [ $GOOS = "windows" ]; then export BINARY_SUFFIX="$BINARY_SUFFIX.exe"; fi if $IS_PR ; then echo $PR_PROMPT; fi @@ -43,7 +43,7 @@ jobs: - name: Upload artifact uses: actions/upload-artifact@v2 - if: ${{ !env.IS_PR }} + if: ${{ !!github.head_ref }} with: name: ${{ matrix.goos }}_${{ matrix.goarch }} path: output/ From 94ebee6afe6a782df5617be55d855bf811bd25f9 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:55:06 +0800 Subject: [PATCH 6/6] Fix a stupid logical bug --- .github/workflows/ci.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index a05aa29..8094c86 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -43,7 +43,7 @@ jobs: - name: Upload artifact uses: actions/upload-artifact@v2 - if: ${{ !!github.head_ref }} + if: ${{ !github.head_ref }} with: name: ${{ matrix.goos }}_${{ matrix.goarch }} path: output/