Having two separate jobs is harder to maintain. Tagging and creating a release should happen at the same time as updating the Makefile, so do everything in one job. Rename it to be more general. Co-developed-by: Claude <noreply@anthropic.com> Signed-off-by: Simon Glass <sjg@chromium.org>
92 lines
3.4 KiB
YAML
92 lines
3.4 KiB
YAML
# .gitlab-ci-release.yml
|
|
|
|
version:process_release:
|
|
stage: version_bump
|
|
image: registry.gitlab.com/gitlab-org/release-cli:latest
|
|
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 python3
|
|
git config --global user.name "GitLab CI"
|
|
git config --global user.email "gitlab-ci@${CI_SERVER_HOST}"
|
|
|
|
# Use Python script to calculate release version and set shell variables
|
|
# Sets: IS_FINAL, VERSION, YEAR, MONTH, RC_NUMBER (RCs only),
|
|
# WEEKS_UNTIL_FINAL (RCs only)
|
|
# Or: IS_DEAD_PERIOD, WEEKS_UNTIL_FINAL, NEXT_RELEASE_YEAR,
|
|
# NEXT_RELEASE_MONTH (dead period)
|
|
eval $(python3 scripts/release_version.py)
|
|
|
|
# Check if we're in a dead period (too early for any RC)
|
|
if [ "$IS_DEAD_PERIOD" = "true" ]; then
|
|
echo "📅 Dead period: $WEEKS_UNTIL_FINAL weeks until next release cycle begins"
|
|
echo "Next release will be $NEXT_RELEASE_YEAR.$NEXT_RELEASE_MONTH"
|
|
echo "No version bump needed - exiting"
|
|
exit 0
|
|
fi
|
|
|
|
echo "Release calculated: VERSION=$VERSION, IS_FINAL=$IS_FINAL"
|
|
|
|
if [ "$IS_FINAL" = "true" ]; then
|
|
COMMIT_MESSAGE="chore: Bump version for final release $VERSION"
|
|
echo "✅ This is a Final Release: $VERSION"
|
|
else
|
|
COMMIT_MESSAGE="chore: Bump version for release candidate $VERSION"
|
|
echo "✅ This is a Release Candidate: $VERSION ($WEEKS_UNTIL_FINAL weeks until release)"
|
|
fi
|
|
|
|
# Update Makefile using Python script
|
|
if python3 scripts/release_version.py --update-makefile; then
|
|
echo "Makefile updated for version $VERSION"
|
|
else
|
|
echo "Makefile is already up-to-date for version $VERSION."
|
|
exit 0
|
|
fi
|
|
|
|
echo "Pushing version bump to master branch..."
|
|
git add Makefile
|
|
git commit -m "$COMMIT_MESSAGE"
|
|
|
|
# Get the commit SHA that will be created
|
|
COMMIT_SHA=$(git rev-parse HEAD)
|
|
echo "Version bump commit SHA: $COMMIT_SHA"
|
|
|
|
git push "https://gitlab-ci-token:${GIT_WRITE_TOKEN}@${CI_SERVER_HOST}/${CI_PROJECT_PATH}.git" HEAD:master
|
|
|
|
# Update release documentation with the commit SHA
|
|
echo "Updating release documentation..."
|
|
if python3 scripts/release_version.py --update-release-docs --commit-sha "$COMMIT_SHA"; then
|
|
echo "Release documentation updated for version $VERSION"
|
|
git add doc/develop/concept_releases.rst
|
|
git commit -m "docs: Add $VERSION to release history"
|
|
git push "https://gitlab-ci-token:${GIT_WRITE_TOKEN}@${CI_SERVER_HOST}/${CI_PROJECT_PATH}.git" HEAD:master
|
|
else
|
|
echo "Release documentation already up-to-date or no changes needed"
|
|
fi
|
|
|
|
# Create GitLab release and tags
|
|
echo "🚀 Creating GitLab Release..."
|
|
|
|
C_TAG_NAME="c${VERSION}"
|
|
|
|
if [ "$IS_FINAL" = "true" ]; then
|
|
RELEASE_TITLE="Release final release"
|
|
else
|
|
RELEASE_TITLE="Release release candidate"
|
|
fi
|
|
|
|
echo "Creating release: $RELEASE_TITLE $VERSION"
|
|
echo "Tag name: $C_TAG_NAME"
|
|
|
|
release-cli create \
|
|
--name "$RELEASE_TITLE $VERSION" \
|
|
--tag-name "$C_TAG_NAME" \
|
|
--description "Automated release created by GitLab CI for commit $COMMIT_SHA." \
|
|
--ref "$COMMIT_SHA"
|
|
|
|
echo "✅ Successfully created release with tag $C_TAG_NAME."
|