Improve Release Notes Generation in CI Pipeline
-
Please check this box if this contribution uses AI-generated content (including content generated by GitLab Duo features) as outlined in the GitLab DCO & CLA. As a benefit of being a GitLab Community Contributor, you receive complimentary access to GitLab Duo.
Note
MR description was created with AI input.
This MR enhances the release notes generation process in our CI pipeline, particularly fixing issues when running in fork scenarios. The changes ensure proper version detection by improving Git tag handling and making the pipeline more robust.
Key Improvements
-
Better tag handling for forks: Added logic to fetch upstream tags when running in a fork's pipeline, ensuring correct version determination.
-
Robust version detection: Switched from manually parsing Git tags to using
git describe --tags --match 'v*'
, providing more reliable versioning. -
Increased Git depth: Set
GIT_DEPTH: 400
to ensure tag history is accessible, fixing the "No tags can describe" error that was silently failing before. -
Cross-project API integration: When running in a merge request pipeline, the changes now properly generate release notes using the target project's API.
-
Code cleanup: Removed debugging code (
set -x
/set +x
) and improved logging for better maintainability.
Why This Matters
Without these changes, contributors working in forks experienced silent failures during release notes generation that were difficult to debug. The error occurred because:
- Shallow clones (depth 20) didn't include the commit history needed for tag access
- Tags may be missing in the source repo and weren't being fetched from the upstream repository
- The API calls were targeting the fork project instead of the upstream project when running on the fork; if the fork doesn't have any tags, which call will fail with HTTP 422 "Unprocessable Entity"
These issues combined to make contributing more difficult than necessary, especially for new contributors who might not understand the underlying Git mechanics.
Technical Implementation
The solution implements proper tag fetching with adequate depth, more robust version detection using native Git commands, and ensures API calls target the correct project regardless of where the pipeline runs.