Re-introduces the automatic creation of Release Candidates (RCs) into the release workflow. Add a new 'release:rc' that runs on the same schedule as the final release jobs. It is designed to be mutually exclusive with the `version:bump` job: - On non-final-release days, it creates an RC release (e.g., 2025.07-rc1) - On final release days, it skips its run, allowing the existing two-step version bump and final release process to proceed. Also tag the release, with a 'c' prefix. Signed-off-by: Simon Glass <sjg@chromium.org>
92 lines
3.6 KiB
YAML
92 lines
3.6 KiB
YAML
# .gitlab-ci-release.yml
|
|
|
|
version:update_and_commit:
|
|
stage: version_bump
|
|
image: alpine:3.18
|
|
rules:
|
|
# Run only on scheduled pipelines targeting the 'master' branch.
|
|
- if: '$CI_PIPELINE_SOURCE == "schedule" && $CI_COMMIT_REF_NAME == "master"'
|
|
script:
|
|
- |
|
|
echo "Determining release type and updating Makefile..."
|
|
|
|
apk add --no-cache git
|
|
git config --global user.name "GitLab CI"
|
|
git config --global user.email "gitlab-ci@${CI_SERVER_HOST}"
|
|
|
|
MONTH=$(date +%-m)
|
|
DAY_OF_WEEK=$(date +%-u)
|
|
DAY_OF_MONTH=$(date +%-d)
|
|
NEW_VERSION=$(date +%Y)
|
|
NEW_PATCHLEVEL=$(printf "%02d" $MONTH)
|
|
|
|
if [ $((MONTH % 2)) -eq 0 ] && [ "$DAY_OF_WEEK" -eq 1 ] && [ "$DAY_OF_MONTH" -le 7 ]; then
|
|
# This is a Final Release
|
|
TAG_NAME="$NEW_VERSION.$NEW_PATCHLEVEL"
|
|
COMMIT_MESSAGE="chore: Bump version for final release $TAG_NAME"
|
|
echo "✅ This is a Final Release: $TAG_NAME"
|
|
|
|
# --- Update Makefile for a FINAL release ---
|
|
sed -i "s/^VERSION = .*/VERSION = $NEW_VERSION/" Makefile
|
|
sed -i "s/^PATCHLEVEL = .*/PATCHLEVEL = $NEW_PATCHLEVEL/" Makefile
|
|
sed -i "s/^SUBLEVEL = .*/SUBLEVEL =/" Makefile
|
|
sed -i "s/^EXTRAVERSION = .*/EXTRAVERSION =/" Makefile # EXTRAVERSION is blank for final
|
|
|
|
else
|
|
# This is a Release Candidate
|
|
RC_INDEX=$(( (DAY_OF_MONTH - 1) / 14 + 1 ))
|
|
TAG_NAME="$NEW_VERSION.$NEW_PATCHLEVEL-rc${RC_INDEX}"
|
|
COMMIT_MESSAGE="chore: Bump version for release candidate $TAG_NAME"
|
|
echo "✅ This is a Release Candidate: $TAG_NAME"
|
|
|
|
# --- Update Makefile for an RC release ---
|
|
EXTRA_VERSION_VAL="-rc${RC_INDEX}"
|
|
sed -i "s/^VERSION = .*/VERSION = $NEW_VERSION/" Makefile
|
|
sed -i "s/^PATCHLEVEL = .*/PATCHLEVEL = $NEW_PATCHLEVEL/" Makefile
|
|
sed -i "s/^SUBLEVEL = .*/SUBLEVEL =/" Makefile
|
|
sed -i "s/^EXTRAVERSION = .*/EXTRAVERSION = $EXTRA_VERSION_VAL/" Makefile # Set EXTRAVERSION to -rcX
|
|
fi
|
|
|
|
if git diff --quiet Makefile; then
|
|
echo "Makefile is already up-to-date for version $TAG_NAME."
|
|
exit 0
|
|
fi
|
|
|
|
echo "Pushing version bump to master branch..."
|
|
git add Makefile
|
|
git commit -m "$COMMIT_MESSAGE"
|
|
git push "https://gitlab-ci-token:${GIT_WRITE_TOKEN}@${CI_SERVER_HOST}/${CI_PROJECT_PATH}.git" HEAD:master
|
|
|
|
release:create_tag:
|
|
stage: release
|
|
image: registry.gitlab.com/gitlab-org/release-cli:latest
|
|
rules:
|
|
- if: '$CI_COMMIT_BRANCH == "master" && $CI_COMMIT_MESSAGE =~ /^chore: Bump version for/'
|
|
script:
|
|
- |
|
|
echo "🚀 Release commit detected. Creating GitLab Release..."
|
|
|
|
TAG_NAME=$(echo "$CI_COMMIT_MESSAGE" | awk '{print $NF}')
|
|
RELEASE_TITLE=$(echo "$CI_COMMIT_MESSAGE" | sed -e 's/chore: Bump version for/Release/' -e "s/$TAG_NAME//")
|
|
|
|
echo "Extracted Tag Name: $TAG_NAME"
|
|
echo "Generated Release Title: $RELEASE_TITLE"
|
|
|
|
release-cli create \
|
|
--name "$RELEASE_TITLE" \
|
|
--tag-name "$TAG_NAME" \
|
|
--description "Automated release created by GitLab CI for commit $CI_COMMIT_SHORT_SHA." \
|
|
--ref "$CI_COMMIT_SHA"
|
|
|
|
echo "🔧 Creating secondary 'c'-prefixed tag..."
|
|
apk add --no-cache git
|
|
git config --global user.name "GitLab CI"
|
|
git config --global user.email "gitlab-ci@${CI_SERVER_HOST}"
|
|
|
|
C_TAG_NAME="c${TAG_NAME}"
|
|
echo "Secondary tag name is: $C_TAG_NAME"
|
|
|
|
git tag "$C_TAG_NAME" "$CI_COMMIT_SHA"
|
|
git push "https://gitlab-ci-token:${GIT_WRITE_TOKEN}@${CI_SERVER_HOST}/${CI_PROJECT_PATH}.git" "$C_TAG_NAME"
|
|
echo "✅ Successfully pushed secondary tag."
|