Publish Docker images when tagged on main repo

This commit is contained in:
Thomas Parisot 2021-01-13 09:05:39 +01:00
parent 49acf2784d
commit 5c72052258

View file

@ -26,10 +26,11 @@ variables:
MOBILIZON_INSTANCE_REGISTRATIONS_OPEN: "true" MOBILIZON_INSTANCE_REGISTRATIONS_OPEN: "true"
# Release elements # Release elements
PACKAGE_REGISTRY_URL: "${CI_API_V4_URL}/projects/${CI_PROJECT_ID}/packages/generic/${CI_PROJECT_NAME}" PACKAGE_REGISTRY_URL: "${CI_API_V4_URL}/projects/${CI_PROJECT_ID}/packages/generic/${CI_PROJECT_NAME}"
ARCH: "amd64"
cache: cache:
key: "${CI_COMMIT_REF_SLUG}" key: "${CI_COMMIT_REF_SLUG}-${CI_COMMIT_SHORT_SHA}"
paths: paths:
- ~/.cache/Cypress - ~/.cache/Cypress
- cache/Cypress - cache/Cypress
@ -152,8 +153,8 @@ jest:
# # - mv doc public/backend # # - mv doc public/backend
# #- yarn run --cwd "js" styleguide:build # #- yarn run --cwd "js" styleguide:build
# #- mv js/styleguide public/frontend # #- mv js/styleguide public/frontend
# only: # rules:
# - master # - if: '$CI_COMMIT_BRANCH == "master"'
# artifacts: # artifacts:
# expire_in: 1 hour # expire_in: 1 hour
# paths: # paths:
@ -173,15 +174,19 @@ jest:
build-docker-master: build-docker-master:
<<: *docker <<: *docker
only: rules:
- schedules - if: '$CI_PROJECT_NAMESPACE != "framasoft"'
when: never
- if: '$CI_PIPELINE_SOURCE == "schedule"'
variables: variables:
DOCKER_IMAGE_NAME: framasoft/mobilizon:master DOCKER_IMAGE_NAME: framasoft/mobilizon:master
build-docker-tag: build-docker-tag:
<<: *docker <<: *docker
only: rules:
- tags - if: '$CI_PROJECT_NAMESPACE != "framasoft"'
when: never
- if: $CI_COMMIT_TAG
variables: variables:
DOCKER_IMAGE_NAME: framasoft/mobilizon:$CI_COMMIT_TAG DOCKER_IMAGE_NAME: framasoft/mobilizon:$CI_COMMIT_TAG
@ -206,11 +211,11 @@ package-app:
release-upload: release-upload:
stage: upload stage: upload
image: curlimages/curl:latest image: curlimages/curl:latest
# rules: rules:
# - if: $CI_COMMIT_TAG - if: $CI_COMMIT_TAG
script: | script: |
APP_VERSION="${CI_COMMIT_TAG:-0.0.0}" 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"
echo "Artifact: ${APP_ASSET}" echo "Artifact: ${APP_ASSET}"
tar czf ${APP_ASSET} -C _build/prod/rel mobilizon tar czf ${APP_ASSET} -C _build/prod/rel mobilizon
@ -221,7 +226,7 @@ release-upload:
expire_in: 1 day expire_in: 1 day
when: on_success when: on_success
paths: paths:
- ${APP_ASSET} - mobilizon_*.tar.gz
release-create: release-create:
stage: deploy stage: deploy
@ -229,11 +234,12 @@ release-create:
rules: rules:
- if: $CI_COMMIT_TAG - if: $CI_COMMIT_TAG
dependencies: [] dependencies: []
cache: {}
script: | script: |
APP_VERSION="${CI_COMMIT_TAG}" 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" \ --tag-name "$CI_COMMIT_TAG" \
--assets-link "{\"name\":\"${APP_ASSET}\",\"url\":\"${PACKAGE_REGISTRY_URL}/${APP_VERSION}/${APP_ASSET}\"}" --assets-link "{\"name\":\"${APP_ASSET}\",\"url\":\"${PACKAGE_REGISTRY_URL}/${APP_VERSION}/${APP_ASSET}\"}"