diff --git a/.github/workflows/docs.yml b/.github/workflows/docs.yml index cb8f6e5..05fb081 100644 --- a/.github/workflows/docs.yml +++ b/.github/workflows/docs.yml @@ -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 diff --git a/.github/workflows/semver-checks.yml b/.github/workflows/semver-checks.yml new file mode 100644 index 0000000..cca3b1c --- /dev/null +++ b/.github/workflows/semver-checks.yml @@ -0,0 +1,82 @@ +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: 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' + uses: obi1kenobi/cargo-semver-checks-action@v2 + 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" \ No newline at end of file diff --git a/CONTRIBUTING.md b/CONTRIBUTING.md index 44cf999..4e15990 100644 --- a/CONTRIBUTING.md +++ b/CONTRIBUTING.md @@ -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 ``` \ No newline at end of file diff --git a/Cargo.toml b/Cargo.toml index 896ca62..0d8599c 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -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" diff --git a/examples/Cargo.toml b/examples/Cargo.toml index 0629047..b8924ed 100644 --- a/examples/Cargo.toml +++ b/examples/Cargo.toml @@ -8,4 +8,4 @@ license.workspace = true [dependencies] # TODO(template) update the crate name -mycrate = { path = "../mycrate" } +template_crate = { path = "../template_crate" } diff --git a/examples/README.md b/examples/README.md index 083347f..d2886b2 100644 --- a/examples/README.md +++ b/examples/README.md @@ -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. \ No newline at end of file +* `addition` - shows how to add two bounded integers with the [`template_crate`](../template_crate/) library. \ No newline at end of file diff --git a/examples/src/bin/addition.rs b/examples/src/bin/addition.rs index c44bbc6..5d90fb7 100644 --- a/examples/src/bin/addition.rs +++ b/examples/src/bin/addition.rs @@ -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)); diff --git a/mycrate/Cargo.toml b/template_crate/Cargo.toml similarity index 95% rename from mycrate/Cargo.toml rename to template_crate/Cargo.toml index e01630a..aa411db 100644 --- a/mycrate/Cargo.toml +++ b/template_crate/Cargo.toml @@ -1,6 +1,6 @@ [package] # TODO(template) rename -name = "mycrate" +name = "template_crate" version.workspace = true edition.workspace = true repository.workspace = true diff --git a/mycrate/README.md b/template_crate/README.md similarity index 100% rename from mycrate/README.md rename to template_crate/README.md diff --git a/mycrate/doc/mainpage-doc.md b/template_crate/doc/mainpage-doc.md similarity index 100% rename from mycrate/doc/mainpage-doc.md rename to template_crate/doc/mainpage-doc.md diff --git a/mycrate/src/lib.rs b/template_crate/src/lib.rs similarity index 100% rename from mycrate/src/lib.rs rename to template_crate/src/lib.rs