Skip to content

Commit f92f512

Browse files
committed
fix: include unreleased conventional commits on new releases
1 parent 8e942de commit f92f512

2 files changed

Lines changed: 20 additions & 17 deletions

File tree

.github/workflows/release.yml

Lines changed: 16 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -120,14 +120,29 @@ jobs:
120120
git config user.name "github-actions[bot]"
121121
git config user.email "github-actions[bot]@users.noreply.github.com"
122122
123+
- name: Determine last published release tag
124+
id: last-published
125+
env:
126+
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
127+
run: |
128+
# Find the most recent non-draft, non-prerelease published release tag
129+
BASE_TAG=$(gh release list --limit 20 --json tagName,isDraft,isPrerelease \
130+
--jq '[.[] | select(.isDraft == false and .isPrerelease == false)] | .[0].tagName // empty')
131+
if [ -z "$BASE_TAG" ]; then
132+
# Fallback: most recent git tag (first release in the repo)
133+
BASE_TAG=$(git tag --sort=-v:refname | head -1)
134+
fi
135+
echo "tag=${BASE_TAG}" >> "$GITHUB_OUTPUT"
136+
echo "Base tag for release: ${BASE_TAG}"
137+
123138
- name: Run NX Release (version + changelog + commit + tag)
124139
id: release
125140
env:
126141
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
127142
CI: "true"
128143
run: |
129144
OLD_VERSION=$(node -p "require('./package.json').version")
130-
node scripts/release.mjs
145+
node scripts/release.mjs --from="${{ steps.last-published.outputs.tag }}"
131146
NEW_VERSION=$(node -p "require('./package.json').version")
132147
echo "version=$NEW_VERSION" >> "$GITHUB_OUTPUT"
133148
if [ "$OLD_VERSION" != "$NEW_VERSION" ]; then
@@ -159,22 +174,6 @@ jobs:
159174
if: steps.release.outputs.changed == 'true'
160175
run: npm install -g @github/copilot
161176

162-
- name: Determine last published release tag
163-
if: steps.release.outputs.changed == 'true'
164-
id: last-published
165-
env:
166-
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
167-
run: |
168-
# Find the most recent non-draft, non-prerelease published release tag
169-
BASE_TAG=$(gh release list --limit 20 --json tagName,isDraft,isPrerelease \
170-
--jq '[.[] | select(.isDraft == false and .isPrerelease == false)] | .[0].tagName // empty')
171-
if [ -z "$BASE_TAG" ]; then
172-
# Fallback: second-latest git tag if no published release exists
173-
BASE_TAG=$(git tag --sort=-v:refname | head -2 | tail -1)
174-
fi
175-
echo "tag=${BASE_TAG}" >> "$GITHUB_OUTPUT"
176-
echo "Base tag for release summary: ${BASE_TAG}"
177-
178177
- name: Generate release summary
179178
if: steps.release.outputs.changed == 'true'
180179
env:

scripts/release.mjs

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -24,12 +24,15 @@ import { fileURLToPath } from 'node:url';
2424
const __dirname = dirname(fileURLToPath(import.meta.url));
2525
const ROOT = resolve(__dirname, '..');
2626
const DRY_RUN = process.argv.includes('--dry-run');
27+
const FROM_ARG = process.argv.find(a => a.startsWith('--from='));
28+
const FROM_TAG = FROM_ARG ? FROM_ARG.slice('--from='.length) : undefined;
2729

2830
// ── 1. Version determination via NX Release ──────────────────────────────────
2931

3032
const { workspaceVersion, projectsVersionData } = await releaseVersion({
3133
dryRun: DRY_RUN,
3234
verbose: false,
35+
...(FROM_TAG ? { from: FROM_TAG } : {}),
3336
});
3437

3538
if (workspaceVersion === null || workspaceVersion === undefined) {
@@ -70,6 +73,7 @@ await releaseChangelog({
7073
versionData: projectsVersionData,
7174
gitPush: false,
7275
createRelease: false,
76+
...(FROM_TAG ? { from: FROM_TAG } : {}),
7377
});
7478

7579
console.log('\n✓ Release preparation complete.');

0 commit comments

Comments
 (0)