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"
# 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}\"}"