Skip to content

Commit

Permalink
fix: add range to git cliff-action
Browse files Browse the repository at this point in the history
  • Loading branch information
DerTiedemann committed Jan 21, 2025
1 parent 3fbf1e5 commit 9991738
Show file tree
Hide file tree
Showing 2 changed files with 32 additions and 13 deletions.
21 changes: 19 additions & 2 deletions actions/changelog-generate/action.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,10 @@ inputs:
description: Version after bump
required: true
# optional inputs
range:
description: "The range of commits to include in the changelog. (by default from last tagged commit that is not HEAD to HEAD) accepts any git revision range."
required: false
default: ""
changelog-file:
description: Path to the changelog file in the GitHub repository
required: false
Expand All @@ -29,6 +33,9 @@ outputs:
single-changelog:
description: "Only the latest changelog."
value: ${{ steps.git-cliff-latest.outputs.content }}
ranged-changelog:
description: "Only the changelog for the specified range. (by default from last tagged commit that is not HEAD to HEAD)"
value: ${{ steps.git-cliff-latest.outputs.content }}

runs:
using: "composite"
Expand All @@ -48,13 +55,23 @@ runs:
else
cp $DEFAULT_PATH tmp_cliff.toml
fi
echo "default_commit_range=$(git describe --tags --exclude=$(git tag --points-at HEAD) --abbrev=0)..HEAD" >> $GITHUB_OUTPUT
shell: bash
- name: Generate range only changelog
uses: orhun/git-cliff-action@v3
id: git-cliff-range
with:
config: tmp_cliff.toml
args: ${{ inputs.range == '' && steps.get-config-path.outputs.default_commit_range || inputs.range }}
env:
GITHUB_REPO: ${{ github.repository }}
GITHUB_TOKEN: ${{ inputs.github-token }}
- name: Generate latest only changelog
uses: orhun/git-cliff-action@v3
id: git-cliff-latest
with:
config: tmp_cliff.toml
args: "--unreleased --tag ${{ inputs.tag }} --verbose"
args: "--unreleased --tag ${{ inputs.tag }}"
env:
GITHUB_REPO: ${{ github.repository }}
GITHUB_TOKEN: ${{ inputs.github-token }}
Expand All @@ -63,7 +80,7 @@ runs:
id: git-cliff
with:
config: tmp_cliff.toml
args: "--tag ${{ inputs.tag }} --verbose"
args: "--tag ${{ inputs.tag }}"
env:
OUTPUT: ${{ inputs.changelog-file }}
GITHUB_REPO: ${{ github.repository }}
Expand Down
24 changes: 13 additions & 11 deletions docs/actions/changelog-generate/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -86,24 +86,26 @@ steps:
<!-- AUTO-DOC-INPUT:START - Do not remove or modify this section -->
| INPUT | TYPE | REQUIRED | DEFAULT | DESCRIPTION |
| -------------- | ------ | -------- | ---------------- | --------------------------------------------------- |
| changelog-file | string | false | `"CHANGELOG.md"` | Path to the changelog file in the GitHub repository |
| checkout | string | false | `"false"` | Whether to checkout the repository or not. |
| clean | string | false | `"false"` | Clean the repository before running the action. |
| github-token | string | true | | The GitHub token for committing the changes. |
| tag | string | true | | Version after bump |
| INPUT | TYPE | REQUIRED | DEFAULT | DESCRIPTION |
| -------------- | ------ | -------- | ---------------- | ----------------------------------------------------------------------------------------------------------------------------------------------- |
| changelog-file | string | false | `"CHANGELOG.md"` | Path to the changelog file in the GitHub repository |
| checkout | string | false | `"false"` | Whether to checkout the repository or not. |
| clean | string | false | `"false"` | Clean the repository before running the action. |
| github-token | string | true | | The GitHub token for committing the changes. |
| range | string | false | | The range of commits to include in the changelog. (by default from last tagged commit that is not HEAD to HEAD) accepts any git revision range. |
| tag | string | true | | Version after bump |
<!-- AUTO-DOC-INPUT:END -->
### Outputs
<!-- AUTO-DOC-OUTPUT:START - Do not remove or modify this section -->
| OUTPUT | TYPE | DESCRIPTION |
| ---------------- | ------ | -------------------------- |
| merged-changelog | string | All changelogs combined. |
| single-changelog | string | Only the latest changelog. |
| OUTPUT | TYPE | DESCRIPTION |
| ---------------- | ------ | --------------------------------------------------------------------------------------------------------- |
| merged-changelog | string | All changelogs combined. |
| ranged-changelog | string | Only the changelog for the specified range. (by default from last tagged commit that is not HEAD to HEAD) |
| single-changelog | string | Only the latest changelog. |
<!-- AUTO-DOC-OUTPUT:END -->
Expand Down

0 comments on commit 9991738

Please sign in to comment.