57 lines
1.7 KiB
YAML
57 lines
1.7 KiB
YAML
variables:
|
|
REPO_NAME: codeberg.org/librarian/librarian
|
|
DOCKER_HOST: tcp://docker:2375
|
|
|
|
stages:
|
|
- build
|
|
- buildx
|
|
- deploy
|
|
|
|
bin:
|
|
stage: build
|
|
needs: []
|
|
image: golang:latest
|
|
script:
|
|
- mkdir -p $GOPATH/src/$(dirname $REPO_NAME)
|
|
- ln -svf $CI_PROJECT_DIR $GOPATH/src/$REPO_NAME
|
|
- cd $GOPATH/src/$REPO_NAME
|
|
- go build -ldflags "-extldflags '-static'" -o $CI_PROJECT_DIR/librarian-linux-amd64
|
|
- GOARCH=arm64 GOOS=linux go build -ldflags "-extldflags '-static'" -o $CI_PROJECT_DIR/librarian-linux-arm64
|
|
- GOARCH=amd64 GOOS=openbsd go build -ldflags "-extldflags '-static'" -o $CI_PROJECT_DIR/librarian-openbsd-amd64
|
|
artifacts:
|
|
paths:
|
|
- librarian-linux-amd64
|
|
- librarian-linux-arm64
|
|
- librarian-openbsd-amd64
|
|
|
|
buildx:
|
|
image: docker:20-git
|
|
stage: buildx
|
|
variables:
|
|
GIT_STRATEGY: none
|
|
artifacts:
|
|
paths:
|
|
- buildx
|
|
expire_in: 1 hour
|
|
services:
|
|
- docker:20-dind
|
|
script:
|
|
- export DOCKER_BUILDKIT=1
|
|
- git clone git://github.com/docker/buildx ./docker-buildx
|
|
- docker build --platform=local -o . ./docker-buildx
|
|
|
|
deploy:
|
|
image: docker:20
|
|
stage: deploy
|
|
services:
|
|
- name: docker:20-dind
|
|
command: ["--experimental"]
|
|
before_script:
|
|
- mkdir -p ~/.docker/cli-plugins
|
|
- mv buildx ~/.docker/cli-plugins/docker-buildx
|
|
- docker run --rm --privileged multiarch/qemu-user-static --reset -p yes
|
|
script:
|
|
- docker login -u $DOCKER_USERNAME -p $DOCKER_ACCESS_TOKEN
|
|
- docker context create mybuilder
|
|
- docker buildx create --use --name mybuilder mybuilder
|
|
- docker buildx build --platform linux/amd64,linux/arm64 --push -t nineteengladespool/librarian:latest . |