Skip to content
Merged
Show file tree
Hide file tree
Changes from 9 commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion .github/workflows/docs.yml
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@ jobs:
# just remove katex-header.html at the root and RUSTDOCFLAGS here
# TODO(template) update the crate name
- name: Build documentation
run: RUSTDOCFLAGS="--html-in-header katex-header.html" cargo doc --no-deps -p mycrate
run: RUSTDOCFLAGS="--html-in-header katex-header.html" cargo doc --no-deps -p template_crate

- name: Remove lock file
run: rm target/doc/.lock
Expand Down
89 changes: 89 additions & 0 deletions .github/workflows/semver-checks.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,89 @@
name: Semver checks

on:
pull_request:
branches: [ "main" ]
paths: ['**/Cargo.toml'] # Only run when Cargo.toml changes
push:
tags: ['v*'] # Run on version tags

# Limit permissions to minimum required
permissions:
contents: read

env:
CARGO_TERM_COLOR: always
CARGO_INCREMENTAL: 0

jobs:
semver:
runs-on: ubuntu-latest
permissions:
contents: read
steps:
- uses: actions/checkout@v4
with:
# cargo-semver-checks needs the full git history to compare versions
fetch-depth: 0

- name: Install Rust toolchain
Comment thread
svlachakis marked this conversation as resolved.
Outdated
# Pinned to v1: https://github.com/dtolnay/rust-toolchain/releases/tag/v1
uses: dtolnay/rust-toolchain@b3b07ba8b418998c39fb20f53e8b695cdcc8de1b
with:
toolchain: stable

- name: Cache cargo registry
uses: actions/cache@v4
with:
path: |
~/.cargo/registry/index/
~/.cargo/registry/cache/
~/.cargo/git/db/
key: ${{ runner.os }}-cargo-${{ hashFiles('**/Cargo.lock') }}
restore-keys: |
${{ runner.os }}-cargo-

- name: Get latest version tag
id: get-baseline
run: |
# Find the latest version tag (v0.1.0 or higher)
latest_tag=$(git describe --tags --abbrev=0 --match='v*' 2>/dev/null || echo "")
if [ -z "$latest_tag" ]; then
echo "No version tags found - skipping semver check"
echo "This is normal for new projects or templates"
echo "skip=true" >> $GITHUB_OUTPUT
else
# Extract version without 'v' prefix for comparison
version=${latest_tag#v}

# Check if version is >= 0.1.0 (using semver comparison)
if printf '%s\n%s\n' "0.1.0" "$version" | sort -V | head -n1 | grep -q "^0\.1\.0$"; then
echo "Found suitable baseline tag: $latest_tag (>= v0.1.0)"
echo "baseline_rev=$latest_tag" >> $GITHUB_OUTPUT
echo "skip=false" >> $GITHUB_OUTPUT
else
echo "Found tag $latest_tag but it's < v0.1.0 - skipping semver check"
echo "Semver checking typically starts from v0.1.0 when APIs stabilize"
echo "skip=true" >> $GITHUB_OUTPUT
fi
fi

- name: Check semver compatibility
if: steps.get-baseline.outputs.skip == 'false'
# Pinned to v2.8: https://github.com/obi1kenobi/cargo-semver-checks-action/releases/tag/v2.8
Comment thread
maksimryndin marked this conversation as resolved.
Outdated
uses: obi1kenobi/cargo-semver-checks-action@5b298c9520f7096a4683c0bd981a7ac5a7e249ae
with:
baseline-rev: ${{ steps.get-baseline.outputs.baseline_rev }}
verbose: true

- name: Semver check skipped
if: steps.get-baseline.outputs.skip == 'true'
run: |
echo "✅ Semver check skipped - no suitable version tags found"
echo "To enable semver checking:"
echo "1. Tag your first stable release: git tag v0.1.0"
echo "2. Push the tag: git push origin v0.1.0"
echo "3. Future changes will be checked against tagged versions"
echo ""
echo "Note: Semver checking starts from v0.1.0 as this indicates"
echo "the beginning of API stability commitments in Rust projects"
4 changes: 2 additions & 2 deletions CONTRIBUTING.md
Original file line number Diff line number Diff line change
Expand Up @@ -30,8 +30,8 @@ After cloning the repository, follow the instructions below to run the documenta
cargo doc
```

Docs for `TODO(template) template-crate`:
Docs for `TODO(template) template_crate`:

```sh
RUSTDOCFLAGS="--html-in-header katex-header.html" cargo doc --no-deps -p template-crate --open
RUSTDOCFLAGS="--html-in-header katex-header.html" cargo doc --no-deps -p template_crate --open
```
4 changes: 2 additions & 2 deletions Cargo.toml
Original file line number Diff line number Diff line change
@@ -1,9 +1,9 @@

# TODO(template) update for the crate name
[workspace]
members = ["examples", "mycrate"]
members = ["examples", "template_crate"]
resolver = "2"
default-members = ["mycrate"]
default-members = ["template_crate"]

[workspace.package]
version = "0.1.0"
Expand Down
2 changes: 1 addition & 1 deletion examples/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -8,4 +8,4 @@ license.workspace = true

[dependencies]
# TODO(template) update the crate name
mycrate = { path = "../mycrate" }
template_crate = { path = "../template_crate" }
2 changes: 1 addition & 1 deletion examples/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -9,4 +9,4 @@ To run an example
cargo run -p examples --bin addition
```

* `addition` - shows how to add two bounded integers with the [`mycrate`](../mycrate/) library.
* `addition` - shows how to add two bounded integers with the [`template_crate`](../template_crate/) library.
2 changes: 1 addition & 1 deletion examples/src/bin/addition.rs
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
// TODO(template) - remove/change the code below and rename the example
use mycrate::add_small_integers;
use template_crate::add_small_integers;

fn main() {
println!("{:?}", add_small_integers(6, 8));
Expand Down
2 changes: 1 addition & 1 deletion mycrate/Cargo.toml → template_crate/Cargo.toml
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
[package]
# TODO(template) rename
name = "mycrate"
name = "template_crate"
version.workspace = true
edition.workspace = true
repository.workspace = true
Expand Down
File renamed without changes.
File renamed without changes.
File renamed without changes.