github.com/Mrs4s/go-cqhttp@v1.2.0/.github/workflows/ci.yml (about)

     1  name: CI
     2  
     3  on: [push, pull_request,workflow_dispatch]
     4  
     5  env:
     6    BINARY_PREFIX: "go-cqhttp_"
     7    BINARY_SUFFIX: ""
     8    COMMIT_ID: "${{ github.sha }}"
     9    PR_PROMPT: "::warning:: Build artifact will not be uploaded due to the workflow is trigged by pull request."
    10  
    11  jobs:
    12    build:
    13      name: Build binary CI
    14      runs-on: ubuntu-latest
    15      strategy:
    16        matrix:
    17          # build and publish in parallel: linux/386, linux/amd64, windows/386, windows/amd64, darwin/amd64, darwin/arm64
    18          goos: [linux, windows, darwin]
    19          goarch: ["386", amd64, arm, arm64]
    20          exclude:
    21            - goos: darwin
    22              goarch: arm
    23            - goos: darwin
    24              goarch: "386"
    25        fail-fast: true
    26      steps:
    27        - uses: actions/checkout@v3
    28        - name: Setup Go environment
    29          uses: actions/setup-go@v3
    30          with:
    31            cache: true
    32            go-version: '1.20'
    33        - name: Build binary file
    34          env:
    35            GOOS: ${{ matrix.goos }}
    36            GOARCH: ${{ matrix.goarch }}
    37            IS_PR: ${{ !!github.head_ref }}
    38          run: |
    39            if [ $GOOS = "windows" ]; then export BINARY_SUFFIX="$BINARY_SUFFIX.exe"; fi
    40            if $IS_PR ; then echo $PR_PROMPT; fi
    41            export BINARY_NAME="$BINARY_PREFIX"$GOOS"_$GOARCH$BINARY_SUFFIX"
    42            export CGO_ENABLED=0
    43            export LD_FLAGS="-w -s -X github.com/Mrs4s/go-cqhttp/internal/base.Version=${COMMIT_ID::7}"
    44            go build -o "output/$BINARY_NAME" -trimpath -ldflags "$LD_FLAGS" .
    45        - name: Upload artifact
    46          uses: actions/upload-artifact@v3
    47          if: ${{ !github.head_ref }}
    48          with:
    49            name: ${{ matrix.goos }}_${{ matrix.goarch }}
    50            path: output/