Added release binary build

This commit is contained in:
Phil 2022-01-23 21:41:40 +01:00
parent 51b72aef8c
commit 1907a5e29a

View file

@ -4,7 +4,8 @@ variables:
stages: stages:
- test - test
- build - build-binary
- build-docker
check-format: check-format:
image: golang:latest image: golang:latest
@ -33,9 +34,100 @@ check-gosec:
only: only:
- merge_requests - merge_requests
release-prod-linux-amd64:
image: golang:alpine
stage: build-binary
variables:
GOOS: "linux"
GOARCH: "amd64"
CGO_ENABLED: 0
before_script:
- go get -d -v ./...
- apk add curl
script:
- go build -a -installsuffix cgo -ldflags="-X $I_PACKAGE.CI_COMMIT_SHORT_SHA=$CI_COMMIT_SHORT_SHA -X $I_PACKAGE.CI_COMMIT_BRANCH=$CI_COMMIT_BRANCH -X $I_PACKAGE.CI_COMMIT_TAG=$CI_COMMIT_TAG" -o linux-amd64 .
- 'curl --header "JOB-TOKEN: $CI_JOB_TOKEN" --upload-file linux-amd64 "${CI_API_V4_URL}/projects/${CI_PROJECT_ID}/packages/generic/release/${CI_COMMIT_TAG}/linux-amd64"'
- rm linux-amd64
only:
- tags
except:
- branches
release-prod-linux-arm64:
image: golang:alpine
stage: build-binary
variables:
GOOS: "linux"
GOARCH: "arm64"
CGO_ENABLED: 0
before_script:
- go get -d -v ./...
script:
- go build -a -installsuffix cgo -ldflags="-X $I_PACKAGE.CI_COMMIT_SHORT_SHA=$CI_COMMIT_SHORT_SHA -X $I_PACKAGE.CI_COMMIT_BRANCH=$CI_COMMIT_BRANCH -X $I_PACKAGE.CI_COMMIT_TAG=$CI_COMMIT_TAG" -o linux-arm64 .
- 'curl --header "JOB-TOKEN: $CI_JOB_TOKEN" --upload-file linux-arm64 "${CI_API_V4_URL}/projects/${CI_PROJECT_ID}/packages/generic/release/${CI_COMMIT_TAG}/linux-arm64"'
- rm linux-arm64
only:
- tags
except:
- branches
release-prod-darwin-amd64:
image: golang:alpine
stage: build-binary
variables:
GOOS: "darwin"
GOARCH: "amd64"
CGO_ENABLED: 0
before_script:
- go get -d -v ./...
script:
- go build -a -installsuffix cgo -ldflags="-X $I_PACKAGE.CI_COMMIT_SHORT_SHA=$CI_COMMIT_SHORT_SHA -X $I_PACKAGE.CI_COMMIT_BRANCH=$CI_COMMIT_BRANCH -X $I_PACKAGE.CI_COMMIT_TAG=$CI_COMMIT_TAG" -o darwin-amd64 .
- 'curl --header "JOB-TOKEN: $CI_JOB_TOKEN" --upload-file darwin-amd64 "${CI_API_V4_URL}/projects/${CI_PROJECT_ID}/packages/generic/release/${CI_COMMIT_TAG}/darwin-amd64"'
- rm darwin-amd64
only:
- tags
except:
- branches
release-prod-darwin-arm64:
image: golang:alpine
stage: build-binary
variables:
GOOS: "darwin"
GOARCH: "arm64"
CGO_ENABLED: 0
before_script:
- go get -d -v ./...
script:
- go build -a -installsuffix cgo -ldflags="-X $I_PACKAGE.CI_COMMIT_SHORT_SHA=$CI_COMMIT_SHORT_SHA -X $I_PACKAGE.CI_COMMIT_BRANCH=$CI_COMMIT_BRANCH -X $I_PACKAGE.CI_COMMIT_TAG=$CI_COMMIT_TAG" -o darwin-arm64 .
- 'curl --header "JOB-TOKEN: $CI_JOB_TOKEN" --upload-file darwin-arm64 "${CI_API_V4_URL}/projects/${CI_PROJECT_ID}/packages/generic/release/${CI_COMMIT_TAG}/darwin-arm64"'
- rm darwin-arm64
only:
- tags
except:
- branches
release-prod-windows-amd64:
image: golang:alpine
stage: build-binary
variables:
GOOS: "windows"
GOARCH: "amd64"
CGO_ENABLED: 0
before_script:
- go get -d -v ./...
script:
- go build -a -installsuffix cgo -ldflags="-X $I_PACKAGE.CI_COMMIT_SHORT_SHA=$CI_COMMIT_SHORT_SHA -X $I_PACKAGE.CI_COMMIT_BRANCH=$CI_COMMIT_BRANCH -X $I_PACKAGE.CI_COMMIT_TAG=$CI_COMMIT_TAG" -o windows-amd64.exe .
- 'curl --header "JOB-TOKEN: $CI_JOB_TOKEN" --upload-file windows-amd64.exe "${CI_API_V4_URL}/projects/${CI_PROJECT_ID}/packages/generic/release/${CI_COMMIT_TAG}/windows-amd64.exe"'
- rm windows-amd64.exe
only:
- tags
except:
- branches
docker-build-prod-latest: docker-build-prod-latest:
image: ezkrg/buildx image: ezkrg/buildx
stage: build stage: build-docker
services: services:
- docker:dind - docker:dind
before_script: before_script:
@ -56,7 +148,7 @@ docker-build-prod-latest:
docker-build-prod-tagged: docker-build-prod-tagged:
image: ezkrg/buildx image: ezkrg/buildx
stage: build stage: build-docker
services: services:
- docker:dind - docker:dind
before_script: before_script:
@ -79,7 +171,7 @@ docker-build-prod-tagged:
docker-build-dry-run: docker-build-dry-run:
image: docker:latest image: docker:latest
stage: build stage: build-docker
services: services:
- docker:dind - docker:dind
script: script: