Skip to content
This repository was archived by the owner on Mar 17, 2025. It is now read-only.

Commit b6af318

Browse files
committed
Merge branch 'feat/breaking-scalar' into develop
2 parents 52ad4fa + fb875b1 commit b6af318

File tree

6 files changed

+78
-21
lines changed

6 files changed

+78
-21
lines changed

.github/workflows/generate-changeset.yml

Lines changed: 21 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -103,13 +103,15 @@ jobs:
103103
"https://api.github.com/repos/${{ github.repository }}/pulls/${PR_NUMBER}")
104104
105105
PR_TITLE=$(echo "$PR_DATA" | jq -r '.title')
106-
PR_BODY=$(echo "$PR_DATA" | jq -r '.body')
107106
PR_AUTHOR=$(echo "$PR_DATA" | jq -r '.user.login')
108107
108+
# Use base64 encoding to avoid issues with special characters in PR body
109+
PR_BODY_BASE64=$(echo "$PR_DATA" | jq -r '.body' | base64 -w 0)
110+
109111
echo "pr_number=${PR_NUMBER}" >> $GITHUB_OUTPUT
110112
echo "pr_title=${PR_TITLE}" >> $GITHUB_OUTPUT
111113
echo "pr_author=${PR_AUTHOR}" >> $GITHUB_OUTPUT
112-
echo "pr_body=${PR_BODY}" >> $GITHUB_OUTPUT
114+
echo "pr_body_base64=${PR_BODY_BASE64}" >> $GITHUB_OUTPUT
113115
114116
- name: Determine target branch
115117
id: target_branch
@@ -134,13 +136,28 @@ jobs:
134136
135137
- name: Generate changeset for current PR
136138
run: |
139+
# Decode the PR body from base64
140+
PR_BODY=$(echo "${{ steps.pr_info.outputs.pr_body_base64 }}" | base64 --decode)
141+
142+
# Determine source branch (head) and target branch (base)
143+
if [[ "${{ github.event_name }}" == "workflow_dispatch" ]]; then
144+
# For workflow_dispatch, we don't have direct access to source branch
145+
SOURCE_BRANCH=""
146+
TARGET_BRANCH="${{ steps.target_branch.outputs.name }}"
147+
else
148+
SOURCE_BRANCH="${{ github.event.pull_request.head.ref }}"
149+
TARGET_BRANCH="${{ github.event.pull_request.base.ref }}"
150+
fi
151+
137152
# Generate a changeset for the current PR
138153
node scripts/generate-changeset.js \
139154
--pr="${{ steps.pr_info.outputs.pr_number }}" \
140155
--title="${{ steps.pr_info.outputs.pr_title }}" \
141156
--author="${{ steps.pr_info.outputs.pr_author }}" \
142-
--body="${{ steps.pr_info.outputs.pr_body }}" \
143-
--branch="${{ steps.target_branch.outputs.name }}"
157+
--body="${PR_BODY}" \
158+
--branch="${{ steps.target_branch.outputs.name }}" \
159+
--source="${SOURCE_BRANCH}" \
160+
--target="${TARGET_BRANCH}"
144161
145162
# Commit and push the changeset
146163
git config --global user.name "GitHub Actions"

.github/workflows/milestone-branch-workflow.md

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -72,10 +72,11 @@ The workflow integrates with GitHub Milestones:
7272
When a milestone branch is eventually merged to develop:
7373

7474
1. All changesets from the milestone branch are included in the develop branch.
75-
2. The existing develop workflow kicks in, updating the PR from develop to main with all changesets.
76-
3. The changesets maintain their original metadata, including the branch they were created in.
75+
2. The workflow automatically skips generating a new changeset for the milestone PR itself, since all changes already have their own changesets.
76+
3. The existing develop workflow kicks in, updating the PR from develop to main with all changesets.
77+
4. The changesets maintain their original metadata, including the branch they were created in.
7778

78-
This ensures that the release notes for the next release include all changes, whether they came from direct PRs to develop or from milestone branches.
79+
This ensures that the release notes for the next release include all changes, whether they came from direct PRs to develop or from milestone branches, without duplication.
7980

8081
## Example Workflow
8182

.github/workflows/semantic-pr-titles.yml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -24,6 +24,7 @@ jobs:
2424
docs
2525
feat
2626
fix
27+
milestone
2728
perf
2829
refactor
2930
release

README.md

Lines changed: 12 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -424,18 +424,18 @@ For visual representations of the workflows, see [docs/WORKFLOW_VISUALIZATION.md
424424

425425
### Milestone Branch Workflow
426426

427-
For larger features that span multiple PRs, we use a milestone branch workflow:
428-
429-
1. Create a milestone branch with the `milestone/` prefix (e.g., `milestone/custom-scalars`)
430-
2. Create a GitHub Milestone with the same name (e.g., "custom-scalars")
431-
3. Create issues for each part of the implementation and assign them to the GitHub Milestone
432-
4. Create PRs against the milestone branch
433-
5. When PRs are merged to the milestone branch, changesets are automatically generated
434-
6. A PR from the milestone branch to `develop` is automatically created/updated
435-
7. When the milestone is complete, merge the milestone branch to `develop`
436-
8. The existing workflow will include the milestone changes in the next release
437-
438-
For more details, see [Milestone Branch Workflow](.github/workflows/milestone-branch-workflow.md).
427+
For larger features that span multiple PRs, we use milestone branches. These branches follow the naming convention `milestone/feature-name` and are associated with GitHub Milestones.
428+
429+
### Key Features:
430+
431+
1. **Branch Naming**: Use `milestone/feature-name` for milestone branches
432+
2. **GitHub Milestone Integration**: Create a GitHub Milestone with the same name as your feature
433+
3. **PR Management**: Create PRs against the milestone branch for individual components
434+
4. **Changeset Generation**: Each PR merged to the milestone branch generates a changeset
435+
5. **Milestone PR**: A PR from the milestone branch to develop is automatically created/updated
436+
6. **Changeset Handling**: When merging to develop, no new changeset is generated for the milestone PR itself, as all changes already have changesets
437+
438+
For detailed documentation, see [Milestone Branch Workflow](.github/workflows/milestone-branch-workflow.md).
439439

440440
## Local Testing
441441

docs/WORKFLOW_VISUALIZATION.md

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -272,9 +272,12 @@ sequenceDiagram
272272
GH->>MS: Update progress
273273
GH->>PR: Update PR to develop
274274
MB->>D: Merge when complete
275+
Note over D,GH: No new changeset generated for milestone PR
275276
D->>GH: Include milestone changes in next release
276277
```
277278

279+
This diagram shows how feature branches are merged into a milestone branch, which generates changesets. When the milestone branch is merged to develop, no new changeset is generated since all changes already have their own changesets. The existing changesets are included in the develop branch and will be part of the next release.
280+
278281
## Complete Workflow with Milestone Branches
279282

280283
```mermaid

scripts/generate-changeset.js

Lines changed: 37 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -16,13 +16,19 @@
1616
* --body PR description
1717
* --breaking Explicitly mark as breaking change (true/false)
1818
* --branch Branch where the changeset was created (default: develop)
19+
* --source Source branch of the PR (optional)
20+
* --target Target branch of the PR (optional)
1921
*
2022
* Breaking Change Detection:
2123
* Breaking changes are automatically detected from:
2224
* 1. Conventional commit syntax with ! (e.g., "feat!: Add breaking feature")
2325
* 2. Title prefixed with "BREAKING CHANGE:" or "BREAKING-CHANGE:"
2426
* 3. Description containing "BREAKING CHANGE:" or "BREAKING-CHANGE:"
2527
* 4. Explicit --breaking=true flag
28+
*
29+
* Special Cases:
30+
* - When a PR is from a milestone branch to develop, we skip changeset generation
31+
* as those changes already have changesets in the milestone branch.
2632
*/
2733

2834
const yargs = require('yargs/yargs');
@@ -66,6 +72,16 @@ const argv = yargs(hideBin(process.argv))
6672
description: 'Branch where the changeset was created',
6773
default: 'develop'
6874
})
75+
.option('source', {
76+
type: 'string',
77+
description: 'Source branch of the PR',
78+
default: ''
79+
})
80+
.option('target', {
81+
type: 'string',
82+
description: 'Target branch of the PR',
83+
default: ''
84+
})
6985
.help()
7086
.argv;
7187

@@ -76,7 +92,7 @@ const argv = yargs(hideBin(process.argv))
7692
* @returns {string} Change type
7793
*/
7894
function extractChangeType(title) {
79-
const match = title.match(/^(feat|fix|docs|style|refactor|perf|test|build|ci|chore|revert):/);
95+
const match = title.match(/^(feat|fix|docs|style|refactor|perf|test|build|ci|chore|revert|milestone):/);
8096
return match ? match[1] : 'other';
8197
}
8298

@@ -112,12 +128,31 @@ function isBreakingChange(title, body) {
112128
return false;
113129
}
114130

131+
/**
132+
* Check if this is a PR from a milestone branch to develop
133+
*
134+
* @param {string} source Source branch of the PR
135+
* @param {string} target Target branch of the PR
136+
* @returns {boolean} Whether this is a milestone PR to develop
137+
*/
138+
function isMilestonePrToDevelop(source, target) {
139+
return source.startsWith('milestone/') && target === 'develop';
140+
}
141+
115142
/**
116143
* Generate a changeset file
117144
*/
118145
async function generateChangeset() {
119146
// Extract PR information
120-
const { pr, title, author, body, branch } = argv;
147+
const { pr, title, author, body, branch, source, target } = argv;
148+
149+
// Skip changeset generation for PRs from milestone branches to develop
150+
if (source && target && isMilestonePrToDevelop(source, target)) {
151+
console.log(`Skipping changeset generation for PR #${pr} from milestone branch ${source} to develop.`);
152+
console.log('Changesets for these changes already exist in the milestone branch.');
153+
return;
154+
}
155+
121156
const changeType = extractChangeType(title);
122157
const breaking = isBreakingChange(title, body);
123158

0 commit comments

Comments
 (0)