Skip to content

Commit 5e52b69

Browse files
committed
ci: Implement release workflow (#5)
1 parent d87440c commit 5e52b69

6 files changed

Lines changed: 190 additions & 2 deletions

File tree

.github/workflows/ci.yml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -12,10 +12,10 @@ jobs:
1212
runs-on: ubuntu-latest
1313
steps:
1414
- name: Checkout
15-
uses: actions/checkout@v4
15+
uses: actions/checkout@de0fac2e4500dabe0009e67214ff5f5447ce83dd #v6.0.2
1616

1717
- name: Install Rust
18-
uses: dtolnay/rust-toolchain@stable
18+
uses: actions-rust-lang/setup-rust-toolchain@46268bd060767258de96ed93c1251119784f2ab6 #v1.16.1
1919
with:
2020
components: clippy, rustfmt
2121

.github/workflows/pr-title.yml

Lines changed: 31 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,31 @@
1+
name: PR Title
2+
3+
on:
4+
pull_request_target:
5+
types: [opened, edited, synchronize, reopened]
6+
7+
permissions:
8+
pull-requests: read
9+
statuses: write
10+
11+
jobs:
12+
conventional-commit:
13+
name: Conventional commit
14+
runs-on: ubuntu-latest
15+
steps:
16+
- uses: amannn/action-semantic-pull-request@48f256284bd46cdaab1048c3721360e808335d50 #v6.1.1
17+
env:
18+
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
19+
with:
20+
types: |
21+
feat
22+
fix
23+
perf
24+
revert
25+
docs
26+
chore
27+
refactor
28+
style
29+
test
30+
build
31+
ci

.github/workflows/release.yml

Lines changed: 48 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,48 @@
1+
name: Release
2+
3+
on:
4+
push:
5+
branches: [main]
6+
workflow_dispatch:
7+
inputs:
8+
publish_only:
9+
description: "Skip release-please, run publish directly (for retrying failed publishes)"
10+
type: boolean
11+
default: false
12+
13+
permissions:
14+
contents: write
15+
pull-requests: write
16+
17+
env:
18+
CARGO_TERM_COLOR: always
19+
20+
jobs:
21+
release-please:
22+
name: Release Please
23+
runs-on: ubuntu-latest
24+
outputs:
25+
releases_created: ${{ steps.release.outputs.releases_created }}
26+
steps:
27+
- uses: googleapis/release-please-action@45996ed1f6d02564a971a2fa1b5860e934307cf7 #v5.0.0
28+
id: release
29+
with:
30+
config-file: release-please-config.json
31+
manifest-file: .release-please-manifest.json
32+
33+
publish:
34+
name: Publish to crates.io
35+
runs-on: ubuntu-latest
36+
needs: release-please
37+
if: |
38+
needs.release-please.outputs.releases_created == 'true' ||
39+
inputs.publish_only == true
40+
environment: crates-io
41+
steps:
42+
- uses: actions/checkout@de0fac2e4500dabe0009e67214ff5f5447ce83dd #v6.0.2
43+
- uses: actions-rust-lang/setup-rust-toolchain@46268bd060767258de96ed93c1251119784f2ab6 #v1.16.1
44+
45+
- name: Publish cli-engine
46+
env:
47+
CARGO_REGISTRY_TOKEN: ${{ secrets.CRATES_IO_TOKEN }}
48+
run: cargo publish

.release-please-manifest.json

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
{
2+
".": "0.1.0"
3+
}

CONTRIBUTING.md

Lines changed: 82 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,82 @@
1+
# Contributing
2+
3+
## Commit Messages
4+
5+
This project uses [Conventional Commits](https://www.conventionalcommits.org/). The release tooling reads commit messages to determine version bumps and generate the changelog, so the format matters.
6+
7+
```
8+
<type>(<optional scope>): <description>
9+
10+
<optional body>
11+
12+
<optional footer>
13+
```
14+
15+
Common types:
16+
17+
| Type | Changelog section | Version effect (pre-1.0) |
18+
|------------|----------------------------|---------------------------|
19+
| `feat` | Features | minor bump (0.x → 0.x+1) |
20+
| `fix` | Bug Fixes | patch bump |
21+
| `perf` | Performance Improvements | patch bump |
22+
| `docs` | Documentation | patch bump |
23+
| `refactor` | Code Refactoring | patch bump |
24+
| `chore` | Miscellaneous | patch bump |
25+
| `build` | Build System | patch bump |
26+
| `test` | Tests | patch bump |
27+
| `ci` | *(hidden)* | no bump |
28+
29+
### Breaking changes
30+
31+
Append `!` to the type, or add a `BREAKING CHANGE:` footer, to signal a breaking change. This
32+
produces a major version bump once the project reaches 1.0; before 1.0 it produces a minor bump.
33+
34+
```
35+
feat!: remove deprecated --output flag
36+
37+
BREAKING CHANGE: the --output flag was removed; use --format instead
38+
```
39+
40+
## Development
41+
42+
```sh
43+
cargo fmt --all --check
44+
cargo clippy --all-targets -- -D warnings
45+
RUSTDOCFLAGS='-D warnings' cargo doc --no-deps
46+
cargo test --all-targets
47+
cargo test --doc
48+
```
49+
50+
## Release Process
51+
52+
Releases are automated via [release-please](https://github.com/googleapis/release-please).
53+
54+
### How it works
55+
56+
1. Every merge to `main` runs the Release Please GitHub Action.
57+
2. The action inspects commits since the last release and opens (or updates) a **Release PR** that:
58+
- bumps the version in `Cargo.toml`
59+
- updates `CHANGELOG.md`
60+
3. When a maintainer is ready to ship, they **merge the Release PR**.
61+
4. Merging the Release PR triggers the `publish` job, which runs `cargo publish` to crates.io.
62+
63+
No manual tagging or version editing is needed — everything flows from commit messages.
64+
65+
### Pre-1.0 versioning
66+
67+
Until the crate reaches `1.0.0`, the bump rules are conservative:
68+
69+
- A `feat` commit bumps the **patch** version (not minor).
70+
- A breaking change bumps the **minor** version (not major).
71+
72+
This matches the project's current stability expectations. The rules will switch to standard semver
73+
once `1.0.0` is tagged.
74+
75+
### Retrying a failed publish
76+
77+
If the release tag was created but `cargo publish` failed (network blip, crates.io outage, etc.),
78+
trigger the workflow manually without creating a duplicate release:
79+
80+
1. Go to **Actions → Release → Run workflow**.
81+
2. Check **Skip release-please, run publish directly**.
82+
3. Click **Run workflow**.

release-please-config.json

Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,24 @@
1+
{
2+
"$schema": "https://raw.githubusercontent.com/googleapis/release-please/main/schemas/config.json",
3+
"bump-minor-pre-major": true,
4+
"bump-patch-for-minor-pre-major": true,
5+
"changelog-sections": [
6+
{ "type": "feat", "section": "Features" },
7+
{ "type": "fix", "section": "Bug Fixes" },
8+
{ "type": "perf", "section": "Performance Improvements" },
9+
{ "type": "revert", "section": "Reverts" },
10+
{ "type": "docs", "section": "Documentation" },
11+
{ "type": "chore", "section": "Miscellaneous" },
12+
{ "type": "refactor", "section": "Code Refactoring" },
13+
{ "type": "style", "section": "Styles" },
14+
{ "type": "test", "section": "Tests" },
15+
{ "type": "build", "section": "Build System" },
16+
{ "type": "ci", "section": "Continuous Integration", "hidden": true }
17+
],
18+
"packages": {
19+
".": {
20+
"release-type": "rust",
21+
"component": "cli-engine"
22+
}
23+
}
24+
}

0 commit comments

Comments
 (0)