Skip to content

Commit a79cd4e

Browse files
committed
ci: add release process
1 parent 2e49d86 commit a79cd4e

File tree

4 files changed

+190
-0
lines changed

4 files changed

+190
-0
lines changed

.github/workflows/ci.yml

Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,23 @@
1+
name: CI
2+
3+
on:
4+
push:
5+
branches: [main]
6+
pull_request:
7+
branches: [main]
8+
9+
env:
10+
CARGO_TERM_COLOR: always
11+
12+
jobs:
13+
check:
14+
runs-on: ubuntu-latest
15+
steps:
16+
- uses: actions/checkout@v4
17+
- uses: dtolnay/rust-toolchain@stable
18+
with:
19+
components: rustfmt, clippy
20+
- uses: Swatinem/rust-cache@v2
21+
- run: cargo fmt --check
22+
- run: cargo clippy -- -D warnings
23+
- run: cargo test

.github/workflows/publish.yml

Lines changed: 46 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,46 @@
1+
name: Publish
2+
3+
on:
4+
pull_request:
5+
types: [closed]
6+
branches: [main]
7+
8+
env:
9+
CARGO_TERM_COLOR: always
10+
11+
jobs:
12+
publish:
13+
if: github.event.pull_request.merged == true && startsWith(github.event.pull_request.head.ref, 'release/')
14+
runs-on: ubuntu-latest
15+
permissions:
16+
contents: write
17+
steps:
18+
- uses: actions/checkout@v4
19+
with:
20+
ref: main
21+
22+
- uses: dtolnay/rust-toolchain@stable
23+
- uses: Swatinem/rust-cache@v2
24+
25+
- name: Get version
26+
id: version
27+
run: |
28+
VERSION=$(grep '^version' Cargo.toml | head -1 | sed 's/version = "\(.*\)"/\1/')
29+
echo "version=$VERSION" >> "$GITHUB_OUTPUT"
30+
31+
- name: Tag release
32+
run: |
33+
git config user.name "github-actions[bot]"
34+
git config user.email "github-actions[bot]@users.noreply.github.com"
35+
git tag "v${{ steps.version.outputs.version }}"
36+
git push origin "v${{ steps.version.outputs.version }}"
37+
38+
- name: Publish to crates.io
39+
run: cargo publish
40+
env:
41+
CARGO_REGISTRY_TOKEN: ${{ secrets.CARGO_REGISTRY_TOKEN }}
42+
43+
- name: Create GitHub Release
44+
env:
45+
GH_TOKEN: ${{ github.token }}
46+
run: gh release create "v${{ steps.version.outputs.version }}" --generate-notes

.github/workflows/release.yml

Lines changed: 93 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,93 @@
1+
name: Release
2+
3+
on:
4+
workflow_dispatch:
5+
inputs:
6+
bump:
7+
description: "Version bump type"
8+
required: true
9+
type: choice
10+
options:
11+
- patch
12+
- minor
13+
- major
14+
15+
env:
16+
CARGO_TERM_COLOR: always
17+
18+
jobs:
19+
prepare-release:
20+
runs-on: ubuntu-latest
21+
permissions:
22+
contents: write
23+
pull-requests: write
24+
steps:
25+
- uses: actions/checkout@v4
26+
with:
27+
fetch-depth: 0
28+
29+
- name: Calculate new version
30+
id: version
31+
run: |
32+
CURRENT=$(grep '^version' Cargo.toml | head -1 | sed 's/version = "\(.*\)"/\1/')
33+
IFS='.' read -r MAJOR MINOR PATCH <<< "$CURRENT"
34+
35+
case "${{ inputs.bump }}" in
36+
major) MAJOR=$((MAJOR + 1)); MINOR=0; PATCH=0 ;;
37+
minor) MINOR=$((MINOR + 1)); PATCH=0 ;;
38+
patch) PATCH=$((PATCH + 1)) ;;
39+
esac
40+
41+
NEW="${MAJOR}.${MINOR}.${PATCH}"
42+
echo "current=$CURRENT" >> "$GITHUB_OUTPUT"
43+
echo "new=$NEW" >> "$GITHUB_OUTPUT"
44+
echo "Bumping $CURRENT -> $NEW"
45+
46+
- name: Update Cargo.toml version
47+
run: sed -i "s/^version = \"${{ steps.version.outputs.current }}\"/version = \"${{ steps.version.outputs.new }}\"/" Cargo.toml
48+
49+
- name: Generate changelog entry
50+
env:
51+
GH_TOKEN: ${{ github.token }}
52+
run: |
53+
VERSION="${{ steps.version.outputs.new }}"
54+
DATE=$(date +%Y-%m-%d)
55+
LAST_TAG=$(git describe --tags --abbrev=0 2>/dev/null || echo "")
56+
57+
# Generate notes from GitHub (PR titles since last tag)
58+
if [ -n "$LAST_TAG" ]; then
59+
NOTES=$(gh api repos/${{ github.repository }}/releases/generate-notes \
60+
-f tag_name="v${VERSION}" \
61+
-f target_commitish=main \
62+
-f previous_tag_name="$LAST_TAG" \
63+
--jq '.body')
64+
else
65+
NOTES="- Initial release"
66+
fi
67+
68+
# Build the new changelog entry
69+
ENTRY="## [${VERSION}] - ${DATE}
70+
71+
${NOTES}"
72+
73+
# Prepend to CHANGELOG.md after the header line
74+
awk -v entry="$ENTRY" '
75+
/^# Changelog/ { print; getline; print; print ""; print entry; next }
76+
{ print }
77+
' CHANGELOG.md > CHANGELOG.tmp && mv CHANGELOG.tmp CHANGELOG.md
78+
79+
- name: Create release PR
80+
env:
81+
GH_TOKEN: ${{ github.token }}
82+
run: |
83+
BRANCH="release/v${{ steps.version.outputs.new }}"
84+
git checkout -b "$BRANCH"
85+
git add Cargo.toml CHANGELOG.md
86+
git config user.name "github-actions[bot]"
87+
git config user.email "github-actions[bot]@users.noreply.github.com"
88+
git commit -m "release: v${{ steps.version.outputs.new }}"
89+
git push origin "$BRANCH"
90+
gh pr create \
91+
--title "release: v${{ steps.version.outputs.new }}" \
92+
--body "Bumps version from ${{ steps.version.outputs.current }} to ${{ steps.version.outputs.new }}." \
93+
--label "release"

CHANGELOG.md

Lines changed: 28 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,28 @@
1+
# Changelog
2+
3+
All notable changes to this project will be documented in this file.
4+
5+
## [0.1.1] - 2026-03-17
6+
7+
### Changed
8+
9+
- Use library crate in main.rs instead of re-declaring modules
10+
- Switch to `BTreeMap` for deterministic diagnostic ordering
11+
- Support glob patterns in `workspace.exclude`
12+
- Deterministic tie-breaking for promotion version suggestion
13+
- Validate `--format` flag with `ValueEnum` to reject invalid values
14+
- Restrict `_subcommand` positional to expected value only
15+
16+
## [0.1.0] - 2026-03-17
17+
18+
### Added
19+
20+
- Initial release
21+
- Check 1: Workspace dependency not inherited (error)
22+
- Check 2: Version mismatch (error)
23+
- Check 3: Candidate for workspace promotion (warning)
24+
- Human-readable and JSON output formats
25+
- `--path`, `--promotion-threshold`, `--promotion-failure`, `--format`, `--no-fail` flags
26+
- Support for `[dependencies]`, `[dev-dependencies]`, `[build-dependencies]`, and target-specific dependencies
27+
- Support for `workspace.exclude` with glob patterns
28+
- Support for renamed dependencies (`package` field)

0 commit comments

Comments
 (0)