|
| 1 | +# Release Process Guide |
| 2 | + |
| 3 | +This guide outlines the complete release process for the `repos` project, from |
| 4 | +development and pull requests to creating a new versioned release. Our strategy |
| 5 | +is built on semantic versioning, conventional commits, and a release branch |
| 6 | +workflow to ensure releases are intentional and well-documented. |
| 7 | + |
| 8 | +## Overview |
| 9 | + |
| 10 | +- **Main Branch (`main`)**: The `main` branch is the primary development branch. |
| 11 | +All new features and fixes are merged here. No releases are created directly |
| 12 | +from `main`. |
| 13 | +- **Release Branches (`release/**`)**: Releases are created by pushing a branch |
| 14 | +with the `release/` prefix (e.g., `release/2025.09`). This triggers the release |
| 15 | +workflow. |
| 16 | +- **Semantic Versioning**: The release workflow automatically determines the new |
| 17 | +version number based on the commit messages since the last release. |
| 18 | +- **Squash Merges**: We use squash merges for pull requests to maintain a clean, |
| 19 | +meaningful commit history on the `main` branch, which is essential for accurate |
| 20 | +semantic versioning. |
| 21 | + |
| 22 | +## The Release Workflow: Step-by-Step |
| 23 | + |
| 24 | +The process is designed to be simple and automated, with clear quality gates. |
| 25 | + |
| 26 | +### Step 1: Development & Pull Requests |
| 27 | + |
| 28 | +All development happens on feature branches. When a feature or fix is ready, |
| 29 | +open a Pull Request (PR) against the `main` branch. |
| 30 | + |
| 31 | +#### PR Best Practices: Squash Merging |
| 32 | + |
| 33 | +When merging a PR, **always use the "Squash and merge"** option. |
| 34 | + |
| 35 | +**Why?** |
| 36 | + |
| 37 | +Squash merging combines all of a PR's commits into a single commit on the `main` |
| 38 | +branch. This is critical for our release process because: |
| 39 | + |
| 40 | +1. **Clean History**: It keeps the `main` branch history clean and readable. |
| 41 | +2. **Accurate Versioning**: It allows us to craft a single, precise conventional |
| 42 | +commit message that the semantic versioning tool can parse to determine the |
| 43 | +correct version bump. Merge commits often hide the original `feat:` or `fix:` |
| 44 | +prefixes. |
| 45 | + |
| 46 | +**How to Squash Merge:** |
| 47 | + |
| 48 | +1. **From the GitHub UI**: |
| 49 | + - In the PR, select **"Squash and merge"** from the merge dropdown. |
| 50 | + - **Crucially, edit the commit title** to follow the |
| 51 | + [Conventional Commits](#conventional-commits) format (e.g., |
| 52 | + `feat: add new command`). |
| 53 | + - Confirm the merge. |
| 54 | + |
| 55 | +2. **From the GitHub CLI**: |
| 56 | + |
| 57 | + ```bash |
| 58 | + # Example for PR #42 |
| 59 | + gh pr merge 42 \ |
| 60 | + --squash \ |
| 61 | + --subject "feat: add a new feature" \ |
| 62 | + --body "Detailed description of the feature." |
| 63 | + ``` |
| 64 | + |
| 65 | +### Step 2: Creating a Release |
| 66 | + |
| 67 | +When you are ready to release the features and fixes that have been merged into |
| 68 | +`main`, you create a release branch. |
| 69 | + |
| 70 | +1. **Ensure your `main` branch is up-to-date**: |
| 71 | + |
| 72 | + ```bash |
| 73 | + git checkout main |
| 74 | + git pull origin main |
| 75 | + ``` |
| 76 | + |
| 77 | +2. **Create and push a release branch**: |
| 78 | + The branch name can be anything, but it **must** start with `release/`. A |
| 79 | + good practice is to name it after the expected version or date. |
| 80 | + |
| 81 | + ```bash |
| 82 | + # Create a release branch (e.g., release/2025.10) |
| 83 | + git checkout -b release/prepare-release |
| 84 | +
|
| 85 | + # Push the branch to GitHub |
| 86 | + git push -u origin release/prepare-release |
| 87 | + ``` |
| 88 | + |
| 89 | +### Step 3: Automated Release Workflow |
| 90 | + |
| 91 | +Pushing the `release/` branch automatically triggers the `release.yml` GitHub |
| 92 | +Actions workflow, which performs the following steps: |
| 93 | + |
| 94 | +1. **Compute Version**: Analyzes commit messages on `main` since the last tag |
| 95 | +and determines the new semantic version (e.g., `v1.3.0`). |
| 96 | +2. **Run Quality Gates**: Runs the full test suite, linter (`clippy`), and |
| 97 | +format checks. The release fails if any of these checks do not pass. |
| 98 | +3. **Update `Cargo.toml`**: Bumps the `version` in `Cargo.toml` and pushes the |
| 99 | +change to the release branch. |
| 100 | +4. **Create GitHub Release**: |
| 101 | + - Creates a new Git tag (e.g., `v1.3.0`). |
| 102 | + - Generates a new GitHub Release with a "What's Changed" section populated |
| 103 | + from the conventional commit messages. |
| 104 | +5. **Build Release Assets**: Compiles the application and creates binaries for |
| 105 | +Linux and macOS (x86_64, aarch64, and universal). These are attached to the |
| 106 | +GitHub Release. |
| 107 | +6. **Sync `main` Branch**: After the release is successfully created, the |
| 108 | +version bump in `Cargo.toml` is automatically merged back into the `main` branch |
| 109 | +to keep it in sync. |
| 110 | + |
| 111 | +## Conventional Commits |
| 112 | + |
| 113 | +To ensure the automation works correctly, all commits merged into `main` must |
| 114 | +follow the Conventional Commits specification. |
| 115 | + |
| 116 | +### Commit Message Structure |
| 117 | + |
| 118 | +```text |
| 119 | +<type>[optional scope]: <description> |
| 120 | +``` |
| 121 | + |
| 122 | +- **`<type>`**: Must be one of the following. |
| 123 | +- **`<description>`**: A short, imperative-tense description of the change. |
| 124 | + |
| 125 | +### Commit Types and Version Bumps |
| 126 | + |
| 127 | +- **`feat`**: A new feature. Triggers a **minor** version bump (e.g., `1.2.3` → |
| 128 | +`1.3.0`). |
| 129 | + - `feat: add a new 'run' command` |
| 130 | +- **`fix`**: A bug fix. Triggers a **patch** version bump (e.g., `1.2.3` → |
| 131 | +`1.2.4`). |
| 132 | + - `fix: correct an issue with path resolution` |
| 133 | +- **`BREAKING CHANGE`**: A commit that introduces a breaking API change. This |
| 134 | +can be added to the footer of any commit type and triggers a **major** version |
| 135 | +bump (e.g., `1.2.3` → `2.0.0`). |
| 136 | + |
| 137 | + ```text |
| 138 | + feat: change CLI argument structure |
| 139 | +
|
| 140 | + BREAKING CHANGE: The '--repo' argument has been renamed to '--repository'. |
| 141 | + ``` |
| 142 | + |
| 143 | +- **Other Types**: These trigger a **patch** version bump and are great for |
| 144 | +organizing your work. |
| 145 | + - `docs:`: Documentation changes. |
| 146 | + - `style:`: Code style changes (formatting, etc.). |
| 147 | + - `refactor:`: Code changes that neither fix a bug nor add a feature. |
| 148 | + - `perf:`: A code change that improves performance. |
| 149 | + - `test:`: Adding or correcting tests. |
| 150 | + - `ci:`: Changes to CI configuration files and scripts. |
| 151 | + - `chore:`: Other changes that don't modify `src` or `test` files. |
0 commit comments