Skip to content

Use precise commit ranges for git-cliff changelog generation#5

Merged
Itsusinn merged 6 commits into
mainfrom
copilot/generate-changelog-using-commits
Jan 31, 2026
Merged

Use precise commit ranges for git-cliff changelog generation#5
Itsusinn merged 6 commits into
mainfrom
copilot/generate-changelog-using-commits

Conversation

Copy link
Copy Markdown
Contributor

Copilot AI commented Jan 30, 2026

The changelog generation was using --latest flag, which doesn't provide control over commit ranges. This changes it to calculate precise ranges based on event type.

Changes

  • Added commit range detection step that determines the appropriate range:

    • Release (v* tag): previous_v_tag..current_v_tag
    • Prerelease (push to main): latest_v_tag..HEAD
    • First release: current_tag or HEAD if no tags exist
  • Modified git-cliff invocation to consume the calculated range instead of --latest

Implementation

- name: Determine commit range for changelog
  run: |
    if [[ $GITHUB_REF == refs/tags/v* ]]; then
      CURRENT_TAG="${GITHUB_REF#refs/tags/}"
      PREVIOUS_TAG=$(git tag -l "v*" --sort=-version:refname | grep -F -x -v "${CURRENT_TAG}" | head -n 1)
      echo "args=${PREVIOUS_TAG:+$PREVIOUS_TAG..}${CURRENT_TAG}" >> $GITHUB_OUTPUT
    else
      LATEST_TAG=$(git tag -l "v*" --sort=-version:refname | head -n 1)
      echo "args=${LATEST_TAG:+$LATEST_TAG..}HEAD" >> $GITHUB_OUTPUT
    fi

- name: Generate a changelog
  with:
    args: ${{ steps.commit-range.outputs.args }} --strip header

Uses grep -F -x -v for exact string matching to handle version tags with special characters (e.g., dots in v1.0.1).


💬 We'd love your input! Share your thoughts on Copilot coding agent in our 2 minute survey.

Copilot AI and others added 5 commits January 30, 2026 23:58
Co-authored-by: Itsusinn <30529002+Itsusinn@users.noreply.github.com>
Co-authored-by: Itsusinn <30529002+Itsusinn@users.noreply.github.com>
Co-authored-by: Itsusinn <30529002+Itsusinn@users.noreply.github.com>
Co-authored-by: Itsusinn <30529002+Itsusinn@users.noreply.github.com>
Co-authored-by: Itsusinn <30529002+Itsusinn@users.noreply.github.com>
Copilot AI changed the title [WIP] Add changelog generation using commit ranges Use precise commit ranges for git-cliff changelog generation Jan 31, 2026
Copilot AI requested a review from Itsusinn January 31, 2026 00:03
@Itsusinn Itsusinn marked this pull request as ready for review January 31, 2026 01:04
@Itsusinn Itsusinn merged commit 44d74c4 into main Jan 31, 2026
1 check passed
@Itsusinn Itsusinn deleted the copilot/generate-changelog-using-commits branch January 31, 2026 02:48
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants