Skip to content

Commit 25be0b8

Browse files
author
nicos_backbase
committed
ci: merge back to main
1 parent 0519f25 commit 25be0b8

5 files changed

Lines changed: 213 additions & 307 deletions

File tree

.github/workflows/release.yml

Lines changed: 62 additions & 26 deletions
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@ on:
99
permissions:
1010
contents: write
1111
packages: write
12-
pull-requests: read
12+
pull-requests: write
1313

1414
env:
1515
CARGO_TERM_COLOR: always
@@ -31,13 +31,13 @@ jobs:
3131
- id: semver
3232
uses: PaulHatch/semantic-version@v5.4.0
3333
with:
34-
tag_prefix: "v"
35-
major_pattern: "BREAKING CHANGE:"
36-
minor_pattern: "feat:"
37-
bump_each_commit: false
38-
search_commit_body: true
39-
user_format_type: "csv"
40-
enable_prerelease_mode: true
34+
tag_prefix: "v"
35+
major_pattern: "BREAKING CHANGE:"
36+
minor_pattern: "feat:"
37+
bump_each_commit: false
38+
search_commit_body: true
39+
user_format_type: "csv"
40+
enable_prerelease_mode: true
4141
- name: Fail if no semantic changes
4242
if: steps.semver.outputs.changed != 'true'
4343
run: |
@@ -62,10 +62,27 @@ jobs:
6262
- name: Tests
6363
run: cargo test --all --locked
6464

65+
update-version:
66+
name: Sync Cargo Version
67+
runs-on: ubuntu-latest
68+
needs: [semantic-version, test]
69+
steps:
70+
- uses: actions/checkout@v5
71+
with:
72+
fetch-depth: 0
73+
- name: Update Cargo.toml
74+
run: |
75+
sed -i.bak 's/^version = ".*"/version = "${{ needs.semantic-version.outputs.version }}"/' Cargo.toml && rm Cargo.toml.bak
76+
git config user.email "action@github.com"
77+
git config user.name "GitHub Action"
78+
git add Cargo.toml
79+
git commit -m "chore: sync version ${{ needs.semantic-version.outputs.version }}" || echo "No change"
80+
git push || true
81+
6582
create-release:
6683
name: Create GitHub Release
6784
runs-on: ubuntu-latest
68-
needs: [semantic-version, test]
85+
needs: [semantic-version, test, update-version]
6986
outputs:
7087
upload_url: ${{ steps.rel.outputs.upload_url }}
7188
steps:
@@ -103,23 +120,6 @@ jobs:
103120
104121
**Full Changelog**: https://github.com/${{ github.repository }}/compare/${{ steps.previous-tag.outputs.tag }}...v${{ needs.semantic-version.outputs.version }}
105122
106-
update-version:
107-
name: Sync Cargo Version
108-
runs-on: ubuntu-latest
109-
needs: [semantic-version, create-release]
110-
steps:
111-
- uses: actions/checkout@v5
112-
with:
113-
fetch-depth: 0
114-
- name: Update Cargo.toml
115-
run: |
116-
sed -i.bak 's/^version = ".*"/version = "${{ needs.semantic-version.outputs.version }}"/' Cargo.toml && rm Cargo.toml.bak
117-
git config user.email "action@github.com"
118-
git config user.name "GitHub Action"
119-
git add Cargo.toml
120-
git commit -m "chore: sync version ${{ needs.semantic-version.outputs.version }}" || echo "No change"
121-
git push || true
122-
123123
build-matrix:
124124
name: Build Targets
125125
needs: [semantic-version, update-version]
@@ -189,3 +189,39 @@ jobs:
189189
with:
190190
tag_name: ${{ needs.semantic-version.outputs.version_tag }}
191191
files: ${{ env.UNIVERSAL }}
192+
193+
sync-main:
194+
name: Sync version back to main
195+
runs-on: ubuntu-latest
196+
needs: [semantic-version, create-release]
197+
permissions:
198+
contents: write
199+
pull-requests: write
200+
steps:
201+
- uses: actions/checkout@v5
202+
with:
203+
fetch-depth: 0
204+
- name: Fast-forward main
205+
run: |
206+
RELEASE_BRANCH="${GITHUB_REF_NAME}"
207+
git fetch origin main
208+
git fetch origin "$RELEASE_BRANCH"
209+
git checkout main
210+
if git merge --ff-only "origin/$RELEASE_BRANCH"; then
211+
git config user.name "GitHub Action"
212+
git config user.email "action@github.com"
213+
git push origin main
214+
echo "FAST_FORWARD=1" >> $GITHUB_ENV
215+
else
216+
echo "FAST_FORWARD=0" >> $GITHUB_ENV
217+
fi
218+
- name: Create PR (non fast-forward)
219+
if: env.FAST_FORWARD == '0'
220+
env:
221+
GH_TOKEN: ${{ secrets.GITHUB_TOKEN }}
222+
run: |
223+
gh pr create \
224+
--base main \
225+
--head "${GITHUB_REF_NAME}" \
226+
--title "chore: sync version ${{ needs.semantic-version.outputs.version }}" \
227+
--body "Automatic version sync after release v${{ needs.semantic-version.outputs.version }}."

docs/release-process.md

Lines changed: 151 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,151 @@
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

Comments
 (0)