Update .gitlab-ci.yml file to build statically for multi-arch and platforms

This commit is contained in:
Diego Fernando Carrión 2023-10-23 10:55:46 +00:00
parent 7487560275
commit 2320206d10

View File

@ -24,9 +24,18 @@ build-job: # This job runs in the build stage, which runs first.
stage: build
image: golang:1.21
script:
- echo "Compiling the code..."
- go build
- echo "Compiling..."
- GOOS=linux GOARCH=amd64 CGO_ENABLED=0 go build -ldflags="-extldflags=-static" -o spry.linux.amd64
- GOOS=linux GOARCH=arm64 CGO_ENABLED=0 go build -ldflags="-extldflags=-static" -o spry.linux.arm64
- GOOS=darwin GOARCH=amd64 CGO_ENABLED=0 go build -ldflags="-extldflags=-static" -o spry.darwin.amd64
- GOOS=darwin GOARCH=arm64 CGO_ENABLED=0 go build -ldflags="-extldflags=-static" -o spry.darwin.arm64
- echo "Compile complete."
artifacts:
untracked: false
when: on_success
expire_in: never
paths:
- "spry.*.*"
#unit-test-job: # This job runs in the test stage.
# stage: test # It only starts when the job in the build stage completes successfully.