Skip to content

Commit fdf0526

Browse files
WF Upd
1 parent db32b9d commit fdf0526

File tree

1 file changed

+15
-12
lines changed

1 file changed

+15
-12
lines changed

.github/workflows/release.yml

Lines changed: 15 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -19,14 +19,13 @@ on:
1919
jobs:
2020
release:
2121
runs-on: ubuntu-latest
22-
# Define outputs for this job
2322
outputs:
2423
new_release_version: ${{ steps.get_new_version.outputs.new_release_version }}
2524
steps:
2625
- name: Checkout code
2726
uses: actions/checkout@v4
2827
with:
29-
fetch-depth: 0
28+
fetch-depth: 0 # Essential for getting full history to capture all PRs
3029

3130
- name: Get latest release version and calculate new version
3231
id: get_new_version
@@ -62,7 +61,7 @@ jobs:
6261
6362
echo "New calculated version: v$new_version"
6463
echo "new_release_version=v$new_version" >> "$GITHUB_OUTPUT"
65-
# Also output the latest_tag for the changelog builder
64+
# For the changelog builder, ensure we pass '' if no previous tag, to get all history
6665
echo "latest_existing_tag=$latest_tag" >> "$GITHUB_OUTPUT"
6766
6867
- name: Create Git Tag
@@ -79,14 +78,19 @@ jobs:
7978
id: generate_changelog
8079
uses: mikepenz/release-changelog-builder-action@v5
8180
with:
81+
# If 'latest_existing_tag' is 'v0.0.0', fromTag becomes '',
82+
# instructing the action to build the changelog from the very first commit.
83+
# Otherwise, it builds from the last official release tag.
8284
fromTag: ${{ steps.get_new_version.outputs.latest_existing_tag == 'v0.0.0' && '' || steps.get_new_version.outputs.latest_existing_tag }}
8385
toTag: ${{ steps.get_new_version.outputs.new_release_version }}
8486
configurationJson: |
85-
{
86-
"template": "# Changes\n\n{{CHANGELOG}}",
87-
"exclude_labels": ["skip-changelog", "duplicate", "wip"],
88-
"commit_mode": false
89-
}
87+
{
88+
"template": "# Changes\n\n{{CHANGELOG}}",
89+
"exclude_labels": ["skip-changelog", "duplicate", "wip"],
90+
"commit_mode": false # Explicitly set to false to ONLY capture PRs. This is the default,
91+
# but being explicit ensures clarity.
92+
# Do NOT set to true or "HYBRID" if you only want PRs.
93+
}
9094
env:
9195
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
9296

@@ -104,8 +108,8 @@ jobs:
104108

105109
cleanup_on_failure:
106110
runs-on: ubuntu-latest
107-
needs: release # This job depends on the 'release' job
108-
if: ${{ always() && (needs.release.result == 'failure' || needs.release.result == 'cancelled') }} # Run if release job failed or was cancelled
111+
needs: release
112+
if: ${{ always() && (needs.release.result == 'failure' || needs.release.result == 'cancelled') }}
109113
steps:
110114
- name: Checkout code (for tag deletion)
111115
uses: actions/checkout@v4
@@ -114,13 +118,12 @@ jobs:
114118

115119
- name: Delete Git Tag on Failure
116120
run: |
117-
# Access the output from the 'release' job using needs.release.outputs
118121
TAG_TO_DELETE="${{ needs.release.outputs.new_release_version }}"
119122
if [ -n "$TAG_TO_DELETE" ]; then
120123
echo "Deleting tag: $TAG_TO_DELETE due to workflow failure/cancellation."
121124
git config user.name "GitHub Actions"
122125
git config user.email "[email protected]"
123-
git push origin --delete "$TAG_TO_DELETE" || true # Use || true to prevent the step from failing if tag doesn't exist
126+
git push origin --delete "$TAG_TO_DELETE" || true
124127
else
125128
echo "No tag to delete or new_release_version not set from previous job."
126129
fi

0 commit comments

Comments
 (0)