Add gitlab CI

This commit is contained in:
video-prize-ranch 2022-01-20 16:25:40 -05:00
parent 10ace75c19
commit 29e3895a88
No known key found for this signature in database
GPG Key ID: D8EAA4C5B12A7281
1 changed files with 57 additions and 0 deletions

57
gitlab-ci.yml Normal file
View File

@ -0,0 +1,57 @@
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 .