From 08dab37c40e5f8f3698ec16f5779d1315798fe74 Mon Sep 17 00:00:00 2001 From: genofire Date: Mon, 1 Aug 2022 21:13:26 +0200 Subject: [PATCH] feat(ci): versioning --- .gitlab-ci.yml | 30 ++++++++++++++++++++++++++---- 1 file changed, 26 insertions(+), 4 deletions(-) diff --git a/.gitlab-ci.yml b/.gitlab-ci.yml index 98131a1..bf19265 100644 --- a/.gitlab-ci.yml +++ b/.gitlab-ci.yml @@ -1,7 +1,6 @@ image: "golang:latest" variables: - DOCKER_IMAGE_TAG: $CI_REGISTRY_IMAGE:$CI_COMMIT_REF_SLUG # Tell 'docker:dind' to enable TLS (recommended) # and generate certificates in the specified directory. DOCKER_TLS_CERTDIR: "/certs" @@ -33,15 +32,38 @@ build-linux: - config_example.toml - "$CI_PROJECT_NAME" -build-docker: +build-docker-latest: stage: build image: docker:latest services: - docker:dind + only: + - main + - master script: - docker login -u $CI_REGISTRY_USER -p $CI_REGISTRY_PASSWORD $CI_REGISTRY - - docker build -t $DOCKER_IMAGE_TAG --build-arg VERSION=$CI_COMMIT_REF_SLUG . - - docker push $DOCKER_IMAGE_TAG + - docker build --build-arg VERSION=$CI_COMMIT_TAG + -t $CI_REGISTRY_IMAGE:latest + . + - docker push $CI_REGISTRY_IMAGE:latest + +build-docker-release: + stage: build + image: docker:latest + services: + - docker:dind + only: + - tags + script: + - docker login -u $CI_REGISTRY_USER -p $CI_REGISTRY_PASSWORD $CI_REGISTRY + - docker build --build-arg VERSION=$CI_COMMIT_TAG + -t $CI_REGISTRY_IMAGE:$CI_COMMIT_TAG + -t $CI_REGISTRY_IMAGE:${CI_COMMIT_TAG%\.[0-9]*} + -t $CI_REGISTRY_IMAGE:${CI_COMMIT_TAG%\.[0-9]*\.[0-9]*} + . + - docker push $CI_REGISTRY_IMAGE:$CI_COMMIT_TAG + - docker push $CI_REGISTRY_IMAGE:${CI_COMMIT_TAG%\.[0-9]*} + - docker push $CI_REGISTRY_IMAGE:${CI_COMMIT_TAG%\.[0-9]*\.[0-9]*} build-release: stage: build