mirror of
https://gitlab.com/psuapp/psu.git
synced 2024-08-30 18:12:34 +00:00
Replace 'master' by 'main' git branch name in scripts
To keep compatibility a $CI_MAIN_BRANCH variable CI is set to 'master' for the whole psuapp group Reference: https://about.gitlab.com/blog/2021/03/10/new-git-default-branch-name/
This commit is contained in:
parent
539f2b2a4a
commit
4709863f1f
@ -150,7 +150,7 @@ generate-docs:
|
|||||||
- bash scripts/push-to-gitlab-pages.sh
|
- bash scripts/push-to-gitlab-pages.sh
|
||||||
only:
|
only:
|
||||||
variables:
|
variables:
|
||||||
- $CI_COMMIT_REF_NAME == "master" || $CI_COMMIT_REF_NAME =~ /^.+-stable$/ && $CI_COMMIT_REF_PROTECTED == "true"
|
- (($CI_MAIN_BRANCH && $CI_COMMIT_REF_NAME == $CI_MAIN_BRANCH) || $CI_COMMIT_REF_NAME == "main" || $CI_COMMIT_REF_NAME =~ /^.+-stable$/) && $CI_COMMIT_REF_PROTECTED == "true"
|
||||||
except:
|
except:
|
||||||
variables:
|
variables:
|
||||||
- $CI_PIPELINE_SOURCE == "schedule"
|
- $CI_PIPELINE_SOURCE == "schedule"
|
||||||
|
@ -16,6 +16,7 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
|
|||||||
- Upgrade Operating System of Docker based images, with [Alpine 3.15](https://hub.docker.com/_/alpine)
|
- Upgrade Operating System of Docker based images, with [Alpine 3.15](https://hub.docker.com/_/alpine)
|
||||||
- Use Docker [Compose 2.1.1](https://github.com/docker/compose/releases/tag/v2.1.1) instead of Docker [Compose 1.x](https://github.com/docker/compose/releases/tag/1.28.0)
|
- Use Docker [Compose 2.1.1](https://github.com/docker/compose/releases/tag/v2.1.1) instead of Docker [Compose 1.x](https://github.com/docker/compose/releases/tag/1.28.0)
|
||||||
- Reduce Docker images size, based on Alpine and Debian, again
|
- Reduce Docker images size, based on Alpine and Debian, again
|
||||||
|
- Replace `master` by `main` git branch name in scripts. Reference: [New git default branch name](https://about.gitlab.com/blog/2021/03/10/new-git-default-branch-name/)
|
||||||
|
|
||||||
### Fixed
|
### Fixed
|
||||||
- Fix documentation scrolling between pages, with the [`auto2top`](https://docsify.js.org/#/configuration?id=auto2top) option of [docsify](https://docsify.js.org)
|
- Fix documentation scrolling between pages, with the [`auto2top`](https://docsify.js.org/#/configuration?id=auto2top) option of [docsify](https://docsify.js.org)
|
||||||
|
@ -46,7 +46,7 @@ function setup_docker_multi_arch() {
|
|||||||
|
|
||||||
function git_tag_on_success() {
|
function git_tag_on_success() {
|
||||||
local git_tag="${1:-dev}"
|
local git_tag="${1:-dev}"
|
||||||
local target_branch="${2:-master}"
|
local target_branch="${2:-${CI_MAIN_BRANCH:-main}}"
|
||||||
|
|
||||||
if (
|
if (
|
||||||
[ "$CI_COMMIT_REF_NAME" == "$target_branch" ] &&
|
[ "$CI_COMMIT_REF_NAME" == "$target_branch" ] &&
|
||||||
@ -73,7 +73,7 @@ function git_tag_on_success() {
|
|||||||
function registry_tag_on_success() {
|
function registry_tag_on_success() {
|
||||||
local current_registry_tag="${1:-$CI_COMMIT_SHA}"
|
local current_registry_tag="${1:-$CI_COMMIT_SHA}"
|
||||||
local target_registry_tag="${2:-dev}"
|
local target_registry_tag="${2:-dev}"
|
||||||
local target_branch="${3:-master}"
|
local target_branch="${3:-${CI_MAIN_BRANCH:-main}}"
|
||||||
local current_registry_image="${4:-$CI_REGISTRY_IMAGE/builds}"
|
local current_registry_image="${4:-$CI_REGISTRY_IMAGE/builds}"
|
||||||
local target_registry_image="${5:-$CI_REGISTRY_IMAGE}"
|
local target_registry_image="${5:-$CI_REGISTRY_IMAGE}"
|
||||||
local target_external_registry_image="${6:-$DOCKER_REGISTRY_IMAGE}"
|
local target_external_registry_image="${6:-$DOCKER_REGISTRY_IMAGE}"
|
||||||
@ -134,7 +134,7 @@ function get_git_last_stable_tag() {
|
|||||||
|
|
||||||
# Useful for updating Docker images, on release/stable branches, but not the psu code
|
# Useful for updating Docker images, on release/stable branches, but not the psu code
|
||||||
# See: https://docs.gitlab.com/ce/workflow/gitlab_flow.html#release-branches-with-gitlab-flow
|
# See: https://docs.gitlab.com/ce/workflow/gitlab_flow.html#release-branches-with-gitlab-flow
|
||||||
# You can create a scheduled pipeline with a targeted git branch ("master", "1-0-stable", ...)
|
# You can create a scheduled pipeline with a targeted git branch ("main", "1-0-stable", ...)
|
||||||
# and the CI variables below:
|
# and the CI variables below:
|
||||||
# "GIT_RESET_LAST_STABLE_TAG=true"
|
# "GIT_RESET_LAST_STABLE_TAG=true"
|
||||||
# "DOCKER_CACHE_DISABLED=true"
|
# "DOCKER_CACHE_DISABLED=true"
|
||||||
|
@ -41,19 +41,19 @@ if (
|
|||||||
# see: https://semver.org
|
# see: https://semver.org
|
||||||
if [[ "$target_registry_tag" =~ ^[0-9]+\.[0-9]+\.[0-9]+$ ]]; then
|
if [[ "$target_registry_tag" =~ ^[0-9]+\.[0-9]+\.[0-9]+$ ]]; then
|
||||||
git fetch --all
|
git fetch --all
|
||||||
# e.g. " origin/master"
|
# e.g. " origin/main"
|
||||||
master_branch="$(git branch --no-color --remotes --list 'origin/master')"
|
main_branch="$(git branch --no-color --remotes --list "origin/${CI_MAIN_BRANCH:-main}")"
|
||||||
|
|
||||||
# e.g. " origin/1-0-stable
|
# e.g. " origin/1-0-stable
|
||||||
# > origin/1-1-stable
|
# > origin/1-1-stable
|
||||||
# > origin/2-0-stable
|
# > origin/2-0-stable
|
||||||
# > origin/master"
|
# > origin/main"
|
||||||
commit_in_branches="$(git branch --no-color --remotes --contains $CI_COMMIT_SHA | grep -w ' origin/master\| origin/.*-stable')"
|
commit_in_branches="$(git branch --no-color --remotes --contains $CI_COMMIT_SHA | grep -w " origin/${CI_MAIN_BRANCH:-main}\| origin/.*-stable")"
|
||||||
|
|
||||||
# e.g. " origin/2-0-stable
|
# e.g. " origin/2-0-stable
|
||||||
# > origin/1-1-stable
|
# > origin/1-1-stable
|
||||||
# > origin/1-0-stable"
|
# > origin/1-0-stable"
|
||||||
stable_branches="$(echo "$commit_in_branches" | grep -vw ' origin/master' | sort -rV)"
|
stable_branches="$(echo "$commit_in_branches" | grep -vw " origin/${CI_MAIN_BRANCH:-main}" | sort -rV)"
|
||||||
|
|
||||||
# Extract the MAJOR and MAJOR.MINOR versions
|
# Extract the MAJOR and MAJOR.MINOR versions
|
||||||
# Then tag and push them to Docker registry.
|
# Then tag and push them to Docker registry.
|
||||||
@ -71,7 +71,7 @@ if (
|
|||||||
# e.g. "1-1-stable"
|
# e.g. "1-1-stable"
|
||||||
latest_major_branch="$(echo "$stable_branches"| grep -E "^ origin/$major_registry_tag-[0-9]+-stable$" | head -n 1 | sed -E 's/^ origin\/(.+)$/\1/')"
|
latest_major_branch="$(echo "$stable_branches"| grep -E "^ origin/$major_registry_tag-[0-9]+-stable$" | head -n 1 | sed -E 's/^ origin\/(.+)$/\1/')"
|
||||||
|
|
||||||
# If the git tag is only contained in master branch
|
# If the git tag is only contained in the "main" branch
|
||||||
# or if it's contained in the latest stable branch who has the same MAJOR version
|
# or if it's contained in the latest stable branch who has the same MAJOR version
|
||||||
# e.g. when there is 2 stable branches "1-0-stable" and "1-1-stable".
|
# e.g. when there is 2 stable branches "1-0-stable" and "1-1-stable".
|
||||||
# If git tag is "v1.0.1", the MAJOR registry tag "1" is NOT written.
|
# If git tag is "v1.0.1", the MAJOR registry tag "1" is NOT written.
|
||||||
@ -80,7 +80,7 @@ if (
|
|||||||
# If git tag is "v1.1.3", the MAJOR registry tag "1" is written.
|
# If git tag is "v1.1.3", the MAJOR registry tag "1" is written.
|
||||||
# Because the lastet stable branch is "1-1-stable".
|
# Because the lastet stable branch is "1-1-stable".
|
||||||
if (
|
if (
|
||||||
([ -n "$master_branch" ] && [ "$master_branch" == "$commit_in_branches" ]) ||
|
([ -n "$main_branch" ] && [ "$main_branch" == "$commit_in_branches" ]) ||
|
||||||
[ "$latest_major_branch" == "$target_stable_branch" ]
|
[ "$latest_major_branch" == "$target_stable_branch" ]
|
||||||
); then
|
); then
|
||||||
registry_tag_on_success $CI_COMMIT_SHA $major_registry_tag $CI_COMMIT_REF_NAME
|
registry_tag_on_success $CI_COMMIT_SHA $major_registry_tag $CI_COMMIT_REF_NAME
|
||||||
@ -89,7 +89,7 @@ if (
|
|||||||
registry_tag_on_success $CI_COMMIT_SHA $major_minor_registry_tag $CI_COMMIT_REF_NAME
|
registry_tag_on_success $CI_COMMIT_SHA $major_minor_registry_tag $CI_COMMIT_REF_NAME
|
||||||
for variant in $variants; do
|
for variant in $variants; do
|
||||||
if (
|
if (
|
||||||
([ -n "$master_branch" ] && [ "$master_branch" == "$commit_in_branches" ]) ||
|
([ -n "$main_branch" ] && [ "$main_branch" == "$commit_in_branches" ]) ||
|
||||||
[ "$latest_major_branch" == "$target_stable_branch" ]
|
[ "$latest_major_branch" == "$target_stable_branch" ]
|
||||||
); then
|
); then
|
||||||
registry_tag_on_success "${variant}-${CI_COMMIT_SHA}" "${major_registry_tag}-${variant}" $CI_COMMIT_REF_NAME
|
registry_tag_on_success "${variant}-${CI_COMMIT_SHA}" "${major_registry_tag}-${variant}" $CI_COMMIT_REF_NAME
|
||||||
@ -98,12 +98,12 @@ if (
|
|||||||
registry_tag_on_success "${variant}-${CI_COMMIT_SHA}" "${major_minor_registry_tag}-${variant}" $CI_COMMIT_REF_NAME
|
registry_tag_on_success "${variant}-${CI_COMMIT_SHA}" "${major_minor_registry_tag}-${variant}" $CI_COMMIT_REF_NAME
|
||||||
done
|
done
|
||||||
|
|
||||||
# The latest stable semantic versioning git tag on the "master" branch
|
# The latest stable semantic versioning git tag on the "main" branch
|
||||||
# is considered as the "latest" registry tag.
|
# is considered as the "latest" registry tag.
|
||||||
# Check if the current git commit is only present in the "master" branch
|
# Check if the current git commit is only present in the "main" branch
|
||||||
# and not in stable branches (e.g. "1-0-stable").
|
# and not in stable branches (e.g. "1-0-stable").
|
||||||
# Non stable branches are skipped (e.g. "feature-better-performance").
|
# Non stable branches are skipped (e.g. "feature-better-performance").
|
||||||
if [ -n "$master_branch" ] && [ "$master_branch" == "$commit_in_branches" ]; then
|
if [ -n "$main_branch" ] && [ "$main_branch" == "$commit_in_branches" ]; then
|
||||||
registry_tag_on_success $CI_COMMIT_SHA "latest" $CI_COMMIT_REF_NAME
|
registry_tag_on_success $CI_COMMIT_SHA "latest" $CI_COMMIT_REF_NAME
|
||||||
for variant in $variants; do
|
for variant in $variants; do
|
||||||
registry_tag_on_success "${variant}-${CI_COMMIT_SHA}" "${variant}" $CI_COMMIT_REF_NAME
|
registry_tag_on_success "${variant}-${CI_COMMIT_SHA}" "${variant}" $CI_COMMIT_REF_NAME
|
||||||
|
Loading…
Reference in New Issue
Block a user