|
| 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 |
0 commit comments