diff --git a/.gitlab-ci.yml b/.gitlab-ci.yml index a99622b60a0fc5de6105d2845a71ffa5a0a2de8b..558112172e00efa33d70f7ee9ca36c3c202a8a49 100644 --- a/.gitlab-ci.yml +++ b/.gitlab-ci.yml @@ -1,24 +1,45 @@ -image: docker:20 -services: - - docker:20-dind - stages: - build - release - - deploy -variables: - CONTAINER_BASE_IMAGE: $CI_REGISTRY_IMAGE:$CI_COMMIT_REF_SLUG +services: + - docker:dind before_script: - docker login -u $CI_REGISTRY_USER -p $CI_REGISTRY_PASSWORD $CI_REGISTRY build: + image: docker:dind stage: build + only: + refs: + - main + - develop + - rc + # This matches maintenance branches + - /^(([0-9]+)\.)?([0-9]+)\.x/ + # This matches pre-releases + - /^([0-9]+)\.([0-9]+)\.([0-9]+)(?:-([0-9A-Za-z-]+(?:\.[0-9A-Za-z-]+)*))?(?:\+[0-9A-Za-z-]+)?$/ script: - - docker build -t $CONTAINER_BASE_IMAGE ./api - - docker push $CONTAINER_BASE_IMAGE + - docker build -t $CI_REGISTRY/$CI_PROJECT_PATH:pipeline-$CI_PIPELINE_ID ./api + - docker push $CI_REGISTRY/$CI_PROJECT_PATH:pipeline-$CI_PIPELINE_ID + +release: + image: docker:dind + stage: release only: + refs: - main - develop - - /^release-.*$/ + - rc + # This matches maintenance branches + - /^(([0-9]+)\.)?([0-9]+)\.x/ + # This matches pre-releases + - /^([0-9]+)\.([0-9]+)\.([0-9]+)(?:-([0-9A-Za-z-]+(?:\.[0-9A-Za-z-]+)*))?(?:\+[0-9A-Za-z-]+)?$/ + script: + - apk add --no-cache nodejs npm py3-pip python2 git + - docker pull $CI_REGISTRY/$CI_PROJECT_PATH:pipeline-$CI_PIPELINE_ID + - docker tag $CI_REGISTRY/$CI_PROJECT_PATH:pipeline-$CI_PIPELINE_ID gateway-semantic:latest + - cd ./api + - npm install @semantic-release/gitlab @semantic-release/changelog @eclass/semantic-release-docker + - npx semantic-release \ No newline at end of file