ci: add multi-dist build step
This commit is contained in:
parent
27df322a50
commit
4468a70870
2 changed files with 34 additions and 2 deletions
22
.github/workflows/ci.yaml
vendored
22
.github/workflows/ci.yaml
vendored
|
@ -10,7 +10,7 @@ env:
|
|||
GO_VERSION: '1.21'
|
||||
|
||||
jobs:
|
||||
tests:
|
||||
test:
|
||||
name: "Tests"
|
||||
runs-on: ubuntu-latest
|
||||
steps:
|
||||
|
@ -39,3 +39,23 @@ jobs:
|
|||
with:
|
||||
go-version: ${{ env.GO_VERSION }}
|
||||
- run: . integration/install_specific_version.sh
|
||||
build:
|
||||
name: "Build"
|
||||
runs-on: ubuntu-latest
|
||||
needs: [test,format,integration-tests]
|
||||
strategy:
|
||||
matrix:
|
||||
dist: ["darwin_amd64", "darwin_arm64", "linux_amd64"]
|
||||
steps:
|
||||
- uses: actions/checkout@v4
|
||||
- uses: actions/setup-go@v4
|
||||
with:
|
||||
go-version: ${{ env.GO_VERSION }}
|
||||
- run: PROD=$PROD GOOS=${DIST%_*} GOARCH=${DIST#*_} . script/build.sh
|
||||
env:
|
||||
DIST: ${{ matrix.dist }}
|
||||
PROD: ${{ github.ref == 'refs/heads/main' && '1' || '' }}
|
||||
- uses: actions/upload-artifact@v4
|
||||
with:
|
||||
name: build-${{matrix.dist}}
|
||||
path: ./build/**/*
|
||||
|
|
|
@ -1,3 +1,15 @@
|
|||
#!/usr/bin/bash
|
||||
|
||||
go build .
|
||||
OS=$(GOOS=$GOOS go env GOOS)
|
||||
ARCH=$(GOARCH=$GOARCH go env GOARCH)
|
||||
|
||||
if [[ -z "$PROD" ]]; then
|
||||
CURRENT_COMMIT=$(git rev-parse HEAD)
|
||||
BUILD_PATH="build/$OS-$ARCH-$CURRENT_COMMIT"
|
||||
mkdir -p $BUILD_PATH
|
||||
GOOS=$OS GOARCH=$ARCH go build -o $BUILD_PATH -v -x .
|
||||
else
|
||||
BUILD_PATH="build/$OS-$ARCH"
|
||||
mkdir -p $BUILD_PATH .
|
||||
GOOS=$OS GOARCH=$ARCH go build -o $BUILD_PATH -ldflags "-w -s" .
|
||||
fi
|
||||
|
|
Loading…
Reference in a new issue