From 5c720522582ce3653054fb87a46dc91ac8b91e58 Mon Sep 17 00:00:00 2001 From: Thomas Parisot Date: Wed, 13 Jan 2021 09:05:39 +0100 Subject: [PATCH] Publish Docker images when tagged on main repo --- .gitlab-ci.yml | 34 ++++++++++++++++++++-------------- 1 file changed, 20 insertions(+), 14 deletions(-) diff --git a/.gitlab-ci.yml b/.gitlab-ci.yml index 5db7d9c8e..c976eaa3f 100644 --- a/.gitlab-ci.yml +++ b/.gitlab-ci.yml @@ -26,10 +26,11 @@ variables: MOBILIZON_INSTANCE_REGISTRATIONS_OPEN: "true" # Release elements PACKAGE_REGISTRY_URL: "${CI_API_V4_URL}/projects/${CI_PROJECT_ID}/packages/generic/${CI_PROJECT_NAME}" + ARCH: "amd64" cache: - key: "${CI_COMMIT_REF_SLUG}" + key: "${CI_COMMIT_REF_SLUG}-${CI_COMMIT_SHORT_SHA}" paths: - ~/.cache/Cypress - cache/Cypress @@ -152,8 +153,8 @@ jest: # # - mv doc public/backend # #- yarn run --cwd "js" styleguide:build # #- mv js/styleguide public/frontend -# only: -# - master +# rules: +# - if: '$CI_COMMIT_BRANCH == "master"' # artifacts: # expire_in: 1 hour # paths: @@ -173,15 +174,19 @@ jest: build-docker-master: <<: *docker - only: - - schedules + rules: + - if: '$CI_PROJECT_NAMESPACE != "framasoft"' + when: never + - if: '$CI_PIPELINE_SOURCE == "schedule"' variables: DOCKER_IMAGE_NAME: framasoft/mobilizon:master build-docker-tag: <<: *docker - only: - - tags + rules: + - if: '$CI_PROJECT_NAMESPACE != "framasoft"' + when: never + - if: $CI_COMMIT_TAG variables: DOCKER_IMAGE_NAME: framasoft/mobilizon:$CI_COMMIT_TAG @@ -206,11 +211,11 @@ package-app: release-upload: stage: upload image: curlimages/curl:latest - # rules: - # - if: $CI_COMMIT_TAG + rules: + - if: $CI_COMMIT_TAG script: | - APP_VERSION="${CI_COMMIT_TAG:-0.0.0}" - APP_ASSET="${CI_PROJECT_NAME}-standalone-${APP_VERSION}.tar.gz" + APP_VERSION="${CI_COMMIT_TAG}" + APP_ASSET="${CI_PROJECT_NAME}_${APP_VERSION}_${ARCH}.tar.gz" echo "Artifact: ${APP_ASSET}" tar czf ${APP_ASSET} -C _build/prod/rel mobilizon @@ -221,7 +226,7 @@ release-upload: expire_in: 1 day when: on_success paths: - - ${APP_ASSET} + - mobilizon_*.tar.gz release-create: stage: deploy @@ -229,11 +234,12 @@ release-create: rules: - if: $CI_COMMIT_TAG dependencies: [] + cache: {} script: | APP_VERSION="${CI_COMMIT_TAG}" - APP_ASSET="${CI_PROJECT_NAME}-standalone-${APP_VERSION}.tar.gz" + APP_ASSET="${CI_PROJECT_NAME}_${APP_VERSION}_${ARCH}.tar.gz" - release-cli create --name "Release $CI_COMMIT_SHA" \ + release-cli create --name "$CI_PROJECT_TITLE v$CI_COMMIT_TAG" \ --tag-name "$CI_COMMIT_TAG" \ --assets-link "{\"name\":\"${APP_ASSET}\",\"url\":\"${PACKAGE_REGISTRY_URL}/${APP_VERSION}/${APP_ASSET}\"}"