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

Commit 890eb10

Browse files
committed
- add GitHub workflow and changes to scripts to support milestone branches (i.e. custom scalars, etc)
1 parent 8d87c4d commit 890eb10

File tree

8 files changed

+628
-72
lines changed

8 files changed

+628
-72
lines changed

.github/workflows/generate-changeset.yml

Lines changed: 241 additions & 38 deletions
Large diffs are not rendered by default.
Lines changed: 202 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,202 @@
1+
# Milestone Branch Workflow
2+
3+
This document outlines the requirements and implementation details for the Milestone Branch workflow.
4+
5+
## Overview
6+
7+
The Milestone Branch workflow allows for the development of larger features that span multiple PRs. It provides a way to collect changesets for a specific feature or milestone while keeping them separate from the main development branch until the feature is complete.
8+
9+
## Branch Naming Convention
10+
11+
Milestone branches follow this naming convention:
12+
13+
```
14+
milestone/feature-name
15+
```
16+
17+
For example:
18+
- `milestone/custom-scalars`
19+
- `milestone/media-refactor`
20+
- `milestone/new-api`
21+
22+
The feature name should use kebab-case (lowercase with hyphens).
23+
24+
## Workflow Steps
25+
26+
The workflow consists of the following steps:
27+
28+
1. **Create Milestone Branch**: Create a branch with the `milestone/` prefix for your feature.
29+
2. **Create GitHub Milestone**: Create a GitHub Milestone with the same name as your feature.
30+
3. **Create Issues**: Create issues for each part of the implementation and assign them to the GitHub Milestone.
31+
4. **Create PRs**: As you implement each part, create PRs against the milestone branch.
32+
5. **Collect Changesets**: Each merged PR automatically generates a changeset in the milestone branch.
33+
6. **Track Progress**: A PR from the milestone branch to develop is automatically created/updated with:
34+
- A list of all changes (from changesets)
35+
- Progress information from the GitHub Milestone
36+
- Links to the Milestone for more details
37+
7. **Final Merge**: When the milestone is complete, merge the milestone branch to develop.
38+
39+
## Changeset Generation
40+
41+
When a PR is merged to a milestone branch, the changeset generation workflow:
42+
43+
1. Detects that the target branch is a milestone branch
44+
2. Generates a changeset with branch information
45+
3. Commits the changeset to the milestone branch
46+
4. Generates release notes for the milestone branch
47+
5. Creates or updates a PR from the milestone branch to develop
48+
49+
## Milestone PR Management
50+
51+
The workflow automatically creates and maintains a PR from the milestone branch to the develop branch:
52+
53+
1. **PR Title**: `feat: feature-name 🚀`
54+
2. **PR Body**: Contains:
55+
- Milestone information and progress
56+
- Link to the GitHub Milestone
57+
- List of changes from changesets
58+
- Explanation of the milestone
59+
60+
This PR serves as a preview of what will be merged to develop when the milestone is complete.
61+
62+
## GitHub Milestone Integration
63+
64+
The workflow integrates with GitHub Milestones:
65+
66+
1. **Milestone Assignment**: PRs targeting the milestone branch are automatically assigned to the corresponding GitHub Milestone.
67+
2. **Progress Tracking**: The milestone PR includes progress information from the GitHub Milestone (e.g., "5/10 issues completed (50%)").
68+
3. **Milestone Links**: The milestone PR includes links to the GitHub Milestone for more details.
69+
70+
## Changeset Handling
71+
72+
When a milestone branch is eventually merged to develop:
73+
74+
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.
77+
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+
80+
## Example Workflow
81+
82+
Here's an example of how to use the milestone branch workflow:
83+
84+
1. **Create a Milestone Branch**:
85+
```bash
86+
git checkout develop
87+
git pull
88+
git checkout -b milestone/custom-scalars
89+
git push -u origin milestone/custom-scalars
90+
```
91+
92+
2. **Create a GitHub Milestone**:
93+
- Go to GitHub > Issues > Milestones > New Milestone
94+
- Title: "custom-scalars"
95+
- Description: "Implement custom scalar types for GraphQL schema"
96+
- Due date: (optional)
97+
- Click "Create milestone"
98+
99+
3. **Create Issues**:
100+
- Create issues for each part of the implementation
101+
- Assign them to the "custom-scalars" milestone
102+
- Example issues:
103+
- "Implement DateTime scalar"
104+
- "Implement Email scalar"
105+
- "Implement Color scalar"
106+
107+
4. **Create PRs**:
108+
- Implement each part in a separate branch
109+
- Create PRs targeting the `milestone/custom-scalars` branch
110+
- Example PR titles:
111+
- "feat: Implement DateTime scalar"
112+
- "feat: Implement Email scalar"
113+
- "feat: Implement Color scalar"
114+
115+
5. **Review and Merge PRs**:
116+
- Review and merge PRs to the milestone branch
117+
- Each merged PR automatically generates a changeset
118+
- The milestone PR to develop is automatically updated
119+
120+
6. **Complete the Milestone**:
121+
- When all issues are resolved, merge the milestone PR to develop
122+
- The develop branch now includes all changes from the milestone
123+
- The existing develop workflow updates the PR from develop to main
124+
125+
## Benefits
126+
127+
The milestone branch workflow provides several benefits:
128+
129+
1. **Feature Isolation**: Develop large features in isolation without affecting the main development branch.
130+
2. **Progress Tracking**: Track progress of large features using GitHub Milestones.
131+
3. **Changeset Collection**: Collect changesets for a specific feature or milestone.
132+
4. **Preview Changes**: Preview what will be merged to develop when the milestone is complete.
133+
5. **Collaborative Development**: Allow multiple developers to work on different parts of the same feature.
134+
6. **Detailed Release Notes**: Generate detailed release notes for the milestone.
135+
136+
## Considerations
137+
138+
When using the milestone branch workflow, consider the following:
139+
140+
1. **Branch Synchronization**: Regularly sync the milestone branch with develop to avoid divergence.
141+
2. **Milestone Scope**: Keep milestones focused on a specific feature or set of related changes.
142+
3. **PR Size**: Even within a milestone, keep PRs small and focused for easier review.
143+
4. **Documentation**: Document the milestone's purpose and scope in the GitHub Milestone description.
144+
5. **Testing**: Thoroughly test the milestone branch before merging to develop.
145+
146+
## GitHub Action Implementation
147+
148+
The milestone branch workflow is implemented in the `generate-changeset.yml` workflow:
149+
150+
```yaml
151+
name: Generate Changeset
152+
153+
on:
154+
pull_request_target:
155+
types: [closed]
156+
branches:
157+
- develop
158+
- 'milestone/**' # Support for milestone branches
159+
workflow_dispatch:
160+
# ...
161+
162+
jobs:
163+
generate-changeset:
164+
# ...
165+
steps:
166+
# ...
167+
- name: Determine target branch
168+
id: target_branch
169+
run: |
170+
# Check if this is a milestone branch
171+
if [[ "${TARGET_BRANCH}" == milestone/* ]]; then
172+
echo "is_milestone=true" >> $GITHUB_OUTPUT
173+
# Extract milestone name from branch name
174+
MILESTONE_NAME=$(echo "${TARGET_BRANCH}" | sed 's/^milestone\///')
175+
echo "milestone_name=${MILESTONE_NAME}" >> $GITHUB_OUTPUT
176+
else
177+
echo "is_milestone=false" >> $GITHUB_OUTPUT
178+
fi
179+
180+
# Generate changeset with branch information
181+
- name: Generate changeset for current PR
182+
run: |
183+
node scripts/generate-changeset.js \
184+
--pr="${{ steps.pr_info.outputs.pr_number }}" \
185+
--title="${{ steps.pr_info.outputs.pr_title }}" \
186+
--author="${{ steps.pr_info.outputs.pr_author }}" \
187+
--body="${{ steps.pr_info.outputs.pr_body }}" \
188+
--branch="${{ steps.target_branch.outputs.name }}"
189+
190+
# For milestone branches, create/update PR to develop
191+
- name: Create/Update milestone PR to develop
192+
if: steps.target_branch.outputs.is_milestone == 'true'
193+
# ...
194+
```
195+
196+
## Next Steps and Considerations
197+
198+
- Create GitHub Milestones for each milestone branch
199+
- Regularly sync milestone branches with develop
200+
- Consider adding a workflow to automatically create milestone branches and GitHub Milestones
201+
- Add support for milestone branch deletion after merging to develop
202+
- Consider adding a workflow to automatically close GitHub Milestones when the milestone branch is merged to develop

README.md

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -422,6 +422,21 @@ For visual representations of the workflows, see [docs/WORKFLOW_VISUALIZATION.md
422422
7. The release management workflow creates a tag and GitHub release
423423
8. The plugin is deployed to the appropriate environments
424424

425+
### Milestone Branch Workflow
426+
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).
439+
425440
## Local Testing
426441

427442
You can test the scripts locally:

SUMMARY.md

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -21,6 +21,9 @@
2121
## Workflows
2222

2323
- **generate-changeset.yml**: Automatically generates a changeset file when a PR is merged to develop.
24+
- Now supports milestone branches with the `milestone/` prefix
25+
- Automatically creates/updates a PR from the milestone branch to develop
26+
- Integrates with GitHub Milestones for progress tracking
2427
- **release-management.yml**: Handles version bumping, changelog updates, and release creation when changes are merged to main.
2528
- Now includes improved sync between main and develop branches after releases
2629
- Uses a non-fast-forward merge strategy with a descriptive commit message
@@ -43,6 +46,7 @@
4346
- Changeset generation process with temporary file handling
4447
- Release management workflow
4548
- Deployment process
49+
- Milestone branch workflow
4650
- Added examples and usage instructions for all scripts
4751
- Documented breaking change detection and handling
4852
- Added information about the new `generate-release-notes.js` script and how to use it locally
@@ -73,6 +77,11 @@
7377

7478
## Recent Updates
7579

80+
- **Milestone Branch Support**: Added support for milestone branches with the `milestone/` prefix.
81+
- Allows for development of larger features that span multiple PRs
82+
- Automatically creates/updates a PR from the milestone branch to develop
83+
- Integrates with GitHub Milestones for progress tracking
84+
- Provides detailed release notes for milestone branches
7685
- **Environment Variables Support**: Added support for environment variables (`REPO_URL` and `GITHUB_TOKEN`) to simplify configuration and usage of the release notes script.
7786
- **Contributor Recognition**: Enhanced release notes to include a contributors section with special recognition for first-time contributors.
7887
- **GitHub Workflow Improvements**: Updated the GitHub workflow to use environment variables instead of command-line arguments, making it cleaner and more maintainable.

docs/WORKFLOW_VISUALIZATION.md

Lines changed: 80 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -220,4 +220,84 @@ gitGraph
220220
merge main id: "Sync v1.1.0 back to develop"
221221
```
222222

223+
## Standard Workflow
224+
225+
```mermaid
226+
graph TD
227+
A[Feature Branch] -->|Create PR| B[develop]
228+
B -->|Merge PR| C[Generate Changeset]
229+
C -->|Commit Changeset| B
230+
B -->|Create/Update PR| D[main]
231+
D -->|Merge PR| E[Release Management]
232+
E -->|Version Bump| F[Create Tag]
233+
F -->|Push Tag| G[Deploy]
234+
G -->|Create GitHub Release| H[WordPress.org SVN]
235+
E -->|Sync Changes| B
236+
```
237+
238+
## Milestone Branch Workflow
239+
240+
```mermaid
241+
graph TD
242+
A[Feature Branch 1] -->|Create PR| B[milestone/feature]
243+
C[Feature Branch 2] -->|Create PR| B
244+
D[Feature Branch 3] -->|Create PR| B
245+
B -->|Merge PR| E[Generate Changeset]
246+
E -->|Commit Changeset| B
247+
B -->|Create/Update PR| F[develop]
248+
F -->|Merge PR| G[Generate Changeset]
249+
G -->|Commit Changeset| F
250+
F -->|Create/Update PR| H[main]
251+
H -->|Merge PR| I[Release Management]
252+
I -->|Version Bump| J[Create Tag]
253+
J -->|Push Tag| K[Deploy]
254+
K -->|Create GitHub Release| L[WordPress.org SVN]
255+
I -->|Sync Changes| F
256+
```
257+
258+
## Milestone Branch Integration
259+
260+
```mermaid
261+
sequenceDiagram
262+
participant FB as Feature Branches
263+
participant MB as Milestone Branch
264+
participant GH as GitHub Actions
265+
participant MS as GitHub Milestone
266+
participant PR as Milestone PR
267+
participant D as develop
268+
269+
FB->>MB: Create PRs
270+
MB->>GH: Merge PRs
271+
GH->>MB: Generate changesets
272+
GH->>MS: Update progress
273+
GH->>PR: Update PR to develop
274+
MB->>D: Merge when complete
275+
D->>GH: Include milestone changes in next release
276+
```
277+
278+
## Complete Workflow with Milestone Branches
279+
280+
```mermaid
281+
graph TD
282+
A[Feature Branch] -->|Create PR| B[develop]
283+
C[Feature Branch 1] -->|Create PR| D[milestone/feature]
284+
E[Feature Branch 2] -->|Create PR| D
285+
F[Feature Branch 3] -->|Create PR| D
286+
287+
B -->|Merge PR| G[Generate Changeset for develop]
288+
D -->|Merge PR| H[Generate Changeset for milestone]
289+
290+
G -->|Commit Changeset| B
291+
H -->|Commit Changeset| D
292+
293+
D -->|Create/Update PR| B
294+
B -->|Create/Update PR| I[main]
295+
296+
I -->|Merge PR| J[Release Management]
297+
J -->|Version Bump| K[Create Tag]
298+
K -->|Push Tag| L[Deploy]
299+
L -->|Create GitHub Release| M[WordPress.org SVN]
300+
J -->|Sync Changes| B
301+
```
302+
223303
These visualizations provide a comprehensive overview of how the different components of the automation system interact. They can be especially helpful for new contributors to understand the workflow and for maintainers to identify potential areas for improvement.

scripts/generate-changeset.js

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,13 +7,15 @@
77
* node scripts/generate-changeset.js --pr=123 --title="feat: Add new feature" --author="username" --body="Description of the change"
88
* node scripts/generate-changeset.js --pr=123 --title="feat!: Add breaking feature" --author="username" --body="Description of the change"
99
* node scripts/generate-changeset.js --pr=123 --title="BREAKING CHANGE: Refactor API" --author="username" --body="Description of the change"
10+
* node scripts/generate-changeset.js --pr=123 --title="feat: Add new feature" --author="username" --body="Description of the change" --branch="milestone/custom-scalars"
1011
*
1112
* Options:
1213
* --pr PR number
1314
* --title PR title
1415
* --author PR author
1516
* --body PR description
1617
* --breaking Explicitly mark as breaking change (true/false)
18+
* --branch Branch where the changeset was created (default: develop)
1719
*
1820
* Breaking Change Detection:
1921
* Breaking changes are automatically detected from:
@@ -59,6 +61,11 @@ const argv = yargs(hideBin(process.argv))
5961
description: 'Whether the PR indicates a breaking change',
6062
default: false
6163
})
64+
.option('branch', {
65+
type: 'string',
66+
description: 'Branch where the changeset was created',
67+
default: 'develop'
68+
})
6269
.help()
6370
.argv;
6471

@@ -110,7 +117,7 @@ function isBreakingChange(title, body) {
110117
*/
111118
async function generateChangeset() {
112119
// Extract PR information
113-
const { pr, title, author, body } = argv;
120+
const { pr, title, author, body, branch } = argv;
114121
const changeType = extractChangeType(title);
115122
const breaking = isBreakingChange(title, body);
116123

@@ -121,6 +128,7 @@ async function generateChangeset() {
121128
author,
122129
type: changeType,
123130
breaking,
131+
branch,
124132
description: body
125133
});
126134

0 commit comments

Comments
 (0)