mirror of
https://github.com/elyby/chrly.git
synced 2024-11-20 04:03:11 +05:30
80fa307915
Исправлен вызов компилятора для "зашивания" версии при сборке
97 lines
2.5 KiB
YAML
97 lines
2.5 KiB
YAML
# Предполагается, что между работой "build docker container" и этапом push
|
||
# построенные docker images остаются статичными и никуда не пропадают
|
||
#
|
||
# В противном случае их нужно после каждого этапа билда пушить в registry
|
||
|
||
stages:
|
||
- test
|
||
- build
|
||
- build_docker_image
|
||
- push
|
||
- cleanup
|
||
|
||
variables:
|
||
CONTAINER_IMAGE: registry.ely.by/elyby/skinsystem
|
||
|
||
.golang_template: &setup_go_environment
|
||
image: golang:1.9.0-alpine3.6
|
||
before_script:
|
||
- apk add --no-cache git
|
||
- mkdir -p $GOPATH/src/$CI_PROJECT_NAMESPACE
|
||
- cp -r $(pwd) $GOPATH/src/$CI_PROJECT_PATH
|
||
- cd $GOPATH/src/$CI_PROJECT_PATH
|
||
- go get -u github.com/golang/dep/cmd/dep
|
||
- $GOPATH/bin/dep ensure
|
||
|
||
.docker_template: &setup_docker_environment
|
||
image: docker:latest
|
||
before_script:
|
||
- docker login -u gitlab-ci -p $CI_JOB_TOKEN registry.ely.by
|
||
- export TEMP_IMAGE_NAME="$CONTAINER_IMAGE:$CI_PIPELINE_ID"
|
||
|
||
test:
|
||
<<: *setup_go_environment
|
||
stage: test
|
||
script:
|
||
- ./script/coverage
|
||
|
||
build executable:
|
||
<<: *setup_go_environment
|
||
stage: build
|
||
script:
|
||
- export VERSION="${CI_COMMIT_TAG:-dev-$CI_COMMIT_REF_NAME-${CI_COMMIT_SHA:0:8}+build-$CI_JOB_ID}"
|
||
- >
|
||
env GOOS=linux
|
||
go build
|
||
-o $CI_PROJECT_DIR/minecraft-skinsystem
|
||
-ldflags "-X ${CI_PROJECT_PATH}/bootstrap.version=${VERSION}"
|
||
main.go
|
||
artifacts:
|
||
name: "${CI_JOB_STAGE} executable"
|
||
paths:
|
||
- $CI_PROJECT_DIR/minecraft-skinsystem
|
||
expire_in: 1 day
|
||
|
||
build docker image:
|
||
<<: *setup_docker_environment
|
||
stage: build_docker_image
|
||
script:
|
||
- docker build -t $TEMP_IMAGE_NAME -f docker/Dockerfile .
|
||
only:
|
||
- tags
|
||
- develop
|
||
|
||
push dev:
|
||
<<: *setup_docker_environment
|
||
stage: push
|
||
variables:
|
||
GIT_STRATEGY: none
|
||
script:
|
||
- export IMAGE_NAME="$CONTAINER_IMAGE:dev"
|
||
- docker tag $TEMP_IMAGE_NAME $IMAGE_NAME
|
||
- docker push $IMAGE_NAME
|
||
only:
|
||
- develop
|
||
|
||
push tag:
|
||
<<: *setup_docker_environment
|
||
stage: push
|
||
variables:
|
||
GIT_STRATEGY: none
|
||
script:
|
||
- export IMAGE_NAME="$CONTAINER_IMAGE:$CI_COMMIT_TAG"
|
||
- export LATEST_IMAGE_NAME="$CONTAINER_IMAGE:latest"
|
||
- docker tag $TEMP_IMAGE_NAME $IMAGE_NAME
|
||
- docker tag $TEMP_IMAGE_NAME $LATEST_IMAGE_NAME
|
||
- docker push $IMAGE_NAME
|
||
- docker push $LATEST_IMAGE_NAME
|
||
only:
|
||
- tags
|
||
|
||
cleanup temp image:
|
||
<<: *setup_docker_environment
|
||
stage: cleanup
|
||
when: always
|
||
script:
|
||
- docker rmi $TEMP_IMAGE_NAME || true
|