diff --git a/templates/monthlymerge.yml b/templates/monthlymerge.yml index ec0dd5e8ae4cd37b2c34efa11a664719c6811e51..46ed967c54632cbfc25239feb46d5a4842abeb59 100644 --- a/templates/monthlymerge.yml +++ b/templates/monthlymerge.yml @@ -1,5 +1,6 @@ include: - local: '/templates/shared/stages.yml' + - local: '/templates/release/calver.yml' release_merge_and_tag:on-schedule: stage: release @@ -53,26 +54,3 @@ release_merge_and_tag:on-schedule: # 5. Tag this version. - git tag -a "${version}" -m "Automated tag of ${version}." - git push origin ${version} - -release_gitlab: - stage: release - image: ${CI_AWE_IMAGE_BASE}/ci-tools:${CI_AWE_IMAGE_TAG} - variables: - GIT_DEPTH: 0 - rules: - - if: $CI_COMMIT_TAG =~ /^\d{4}\.\d{2}\.\d+/ - script: - # Determine the previous tag. This is a bit brittle because we're sorting lexicographically by tag name - # instead of topographically by commits in the git tree. But since we're restricting to YYYY.MM.PATCH - # tags, this should be ok. - - PREVIOUS_TAG=$(git tag --merged ${CI_COMMIT_SHA} | grep -P '^\d{4}.\d{2}.\d+$' | sort | tail -n 2 | head -n 1) - - | - if [ -z "$PREVIOUS_TAG" ] || [ "$PREVIOUS_TAG" = "$CI_COMMIT_TAG" ]; then - echo "Could not find previous tag, exiting" - false - fi - - echo "Found previous tag ${PREVIOUS_TAG}" - - PREVIOUS_TAG_SHA=$(git rev-parse "${PREVIOUS_TAG}") - - CHANGES=$(git log-mr --output markdown --pretty oneline --target "$CI_DEFAULT_BRANCH" "$PREVIOUS_TAG_SHA..$CI_COMMIT_SHA" | sort --ignore-case) - - DESCRIPTION='##### Changes'$'\n'$'\n'"$CHANGES" - - release-cli create --name "$CI_COMMIT_TAG" --description "$DESCRIPTION" --tag-name "$CI_COMMIT_TAG" diff --git a/templates/release/_shared.yml b/templates/release/_shared.yml new file mode 100644 index 0000000000000000000000000000000000000000..525ec2a4c7fe8d5b0591975da25472c7fa90c03e --- /dev/null +++ b/templates/release/_shared.yml @@ -0,0 +1,23 @@ +include: + - local: '/templates/shared/all.yml' + +.release_gitlab: + stage: release + image: ${CI_AWE_IMAGE_BASE}/ci-tools:${CI_AWE_IMAGE_TAG} + variables: + GIT_DEPTH: 0 + script: + # Determine the previous tag. This is a bit brittle because we're sorting lexicographically by tag name + # instead of topographically by commits in the git tree. But since we're restricting to YYYY.MM.PATCH + # tags, this should be ok. + - PREVIOUS_TAG=$(git topotag ${CI_COMMIT_SHA} | grep -P "${TAG_PATTERN}" | head -n 2 | tail -n 1) + - | + if [ -z "$PREVIOUS_TAG" ] || [ "$PREVIOUS_TAG" = "$CI_COMMIT_TAG" ]; then + echo "Could not find previous tag, exiting" + false + fi + - echo "Found previous tag ${PREVIOUS_TAG}" + - PREVIOUS_TAG_SHA=$(git rev-parse "${PREVIOUS_TAG}") + - CHANGES=$(git log-mr --output markdown --pretty oneline --target "$CI_DEFAULT_BRANCH" "$PREVIOUS_TAG_SHA..$CI_COMMIT_SHA" | sort --ignore-case) + - DESCRIPTION='##### Changes'$'\n'$'\n'"$CHANGES" + - release-cli create --name "$CI_COMMIT_TAG" --description "$DESCRIPTION" --tag-name "$CI_COMMIT_TAG" diff --git a/templates/release/calver.yml b/templates/release/calver.yml new file mode 100644 index 0000000000000000000000000000000000000000..1122851561895e979a073fa3bcacb7e6b6206419 --- /dev/null +++ b/templates/release/calver.yml @@ -0,0 +1,9 @@ +include: + - local: '/templates/release/_shared.yml' + +.release_gitlab_calver: + extends: .release_gitlab + variables: + TAG_PATTERN: '^\d{4}\.\d{2}\.\d+$' + rules: + - if: $CI_COMMIT_TAG =~ /^\d{4}\.\d{2}\.\d+$/ diff --git a/templates/release/semver.yml b/templates/release/semver.yml new file mode 100644 index 0000000000000000000000000000000000000000..83545ab45765149dd209d26de35b62399b868c36 --- /dev/null +++ b/templates/release/semver.yml @@ -0,0 +1,9 @@ +include: + - local: '/templates/release/_shared.yml' + +.release_gitlab_semver: + extends: .release_gitlab + variables: + TAG_PATTERN: '^\d+\.\d+\.\d+$' + rules: + - if: $CI_COMMIT_TAG =~ /^\d+\.\d+\.\d+$/