From c36640c1d8a99a9423c81ba452ff1c7224b01e60 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E8=80=97=E5=AD=90?= Date: Sun, 25 Jun 2023 00:04:58 +0800 Subject: [PATCH] feat: optimize build workflow --- .github/workflows/build.yml | 67 ++++++++----------------------------- 1 file changed, 14 insertions(+), 53 deletions(-) diff --git a/.github/workflows/build.yml b/.github/workflows/build.yml index 95aa5b0f..4b4a09e4 100644 --- a/.github/workflows/build.yml +++ b/.github/workflows/build.yml @@ -5,67 +5,28 @@ on: - main pull_request: jobs: - build-amd64: + build: runs-on: ubuntu-latest + strategy: + matrix: + goarch: [ amd64, arm64, s390x, loong64 ] + fail-fast: true steps: - uses: actions/checkout@v3 - uses: actions/setup-go@v4 with: + cache: true go-version: 'stable' - name: Install dependencies run: go mod tidy - - name: Build - run: CGO_ENABLED=0 GOOS=linux GOARCH=amd64 go build -ldflags '-s -w --extldflags "-static -fpic"' -o panel-amd64 + - name: Build ${{ matrix.goarch }} + env: + CGO_ENABLED: 0 + GOOS: linux + GOARCH: ${{ matrix.goarch }} + run: go build -ldflags '-s -w --extldflags "-static -fpic"' -o panel-${{ matrix.goarch }} - name: Upload artifact uses: actions/upload-artifact@v3 with: - name: panel-amd64 - path: panel-amd64 - build-arm64: - runs-on: ubuntu-latest - steps: - - uses: actions/checkout@v3 - - uses: actions/setup-go@v4 - with: - go-version: 'stable' - - name: Install dependencies - run: go mod tidy - - name: Build - run: CGO_ENABLED=0 GOOS=linux GOARCH=arm64 go build -ldflags '-s -w --extldflags "-static -fpic"' -o panel-arm64 - - name: Upload artifact - uses: actions/upload-artifact@v3 - with: - name: panel-arm64 - path: panel-arm64 - build-s390x: - runs-on: ubuntu-latest - steps: - - uses: actions/checkout@v3 - - uses: actions/setup-go@v4 - with: - go-version: 'stable' - - name: Install dependencies - run: go mod tidy - - name: Build - run: CGO_ENABLED=0 GOOS=linux GOARCH=s390x go build -ldflags '-s -w --extldflags "-static -fpic"' -o panel-s390x - - name: Upload artifact - uses: actions/upload-artifact@v3 - with: - name: panel-s390x - path: panel-s390x - build-loong64: - runs-on: ubuntu-latest - steps: - - uses: actions/checkout@v3 - - uses: actions/setup-go@v4 - with: - go-version: 'stable' - - name: Install dependencies - run: go mod tidy - - name: Build - run: CGO_ENABLED=0 GOOS=linux GOARCH=loong64 go build -ldflags '-s -w --extldflags "-static -fpic"' -o panel-loong64 - - name: Upload artifact - uses: actions/upload-artifact@v3 - with: - name: panel-loong64 - path: panel-loong64 + name: panel-${{ matrix.goarch }} + path: panel-${{ matrix.goarch }}