From ee60d46f4fb4177bd00118a3cadb7347d0956401 Mon Sep 17 00:00:00 2001 From: dkgoutham Date: Fri, 27 Jun 2025 10:18:41 +0200 Subject: [PATCH 01/10] Add cargo-semver-checks workflow --- .github/workflows/semver-checks.yml | 29 +++++++++++++++++++++++++++++ 1 file changed, 29 insertions(+) create mode 100644 .github/workflows/semver-checks.yml diff --git a/.github/workflows/semver-checks.yml b/.github/workflows/semver-checks.yml new file mode 100644 index 0000000..e7ace27 --- /dev/null +++ b/.github/workflows/semver-checks.yml @@ -0,0 +1,29 @@ +name: Semver checks + +on: + push: + branches: [ "main" ] + pull_request: + branches: [ "main" ] + +env: + CARGO_TERM_COLOR: always + CARGO_INCREMENTAL: 0 + +jobs: + semver: + runs-on: ubuntu-latest + steps: + - uses: actions/checkout@v4 + with: + # cargo-semver-checks needs the full git history to compare versions + fetch-depth: 0 + + - name: Check semver compatibility + uses: obi1kenobi/cargo-semver-checks-action@v2 + with: + # Check all packages in the workspace + package: --workspace + # Only run on packages that have been published before + # This prevents errors on new packages that haven't been published yet + baseline-version: auto \ No newline at end of file From e802b9f951aa274dee776bc2bc5cb42c17f86a9b Mon Sep 17 00:00:00 2001 From: dkgoutham Date: Fri, 27 Jun 2025 13:33:35 +0200 Subject: [PATCH 02/10] Fix semver-checks workflow configuration --- .github/workflows/semver-checks.yml | 5 +---- 1 file changed, 1 insertion(+), 4 deletions(-) diff --git a/.github/workflows/semver-checks.yml b/.github/workflows/semver-checks.yml index e7ace27..666469f 100644 --- a/.github/workflows/semver-checks.yml +++ b/.github/workflows/semver-checks.yml @@ -23,7 +23,4 @@ jobs: uses: obi1kenobi/cargo-semver-checks-action@v2 with: # Check all packages in the workspace - package: --workspace - # Only run on packages that have been published before - # This prevents errors on new packages that haven't been published yet - baseline-version: auto \ No newline at end of file + package: --workspace \ No newline at end of file From a7f2ab1cfa7f741f8bbf60e8c5819ad2350cf5e5 Mon Sep 17 00:00:00 2001 From: dkgoutham Date: Fri, 27 Jun 2025 13:45:57 +0200 Subject: [PATCH 03/10] Fix semver-checks workflow: remove invalid package parameter --- .github/workflows/semver-checks.yml | 4 +--- 1 file changed, 1 insertion(+), 3 deletions(-) diff --git a/.github/workflows/semver-checks.yml b/.github/workflows/semver-checks.yml index 666469f..d7887fe 100644 --- a/.github/workflows/semver-checks.yml +++ b/.github/workflows/semver-checks.yml @@ -21,6 +21,4 @@ jobs: - name: Check semver compatibility uses: obi1kenobi/cargo-semver-checks-action@v2 - with: - # Check all packages in the workspace - package: --workspace \ No newline at end of file + # No parameters needed - automatically checks all packages in workspace \ No newline at end of file From dfd3c625315e294e60003ae605a6990e39cb7db1 Mon Sep 17 00:00:00 2001 From: dkgoutham Date: Fri, 27 Jun 2025 19:46:49 +0200 Subject: [PATCH 04/10] Configure semver-checks to skip template's default package names --- .github/workflows/semver-checks.yml | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/.github/workflows/semver-checks.yml b/.github/workflows/semver-checks.yml index d7887fe..e70379f 100644 --- a/.github/workflows/semver-checks.yml +++ b/.github/workflows/semver-checks.yml @@ -21,4 +21,7 @@ jobs: - name: Check semver compatibility uses: obi1kenobi/cargo-semver-checks-action@v2 - # No parameters needed - automatically checks all packages in workspace \ No newline at end of file + with: + # Skip semver checks if this is still the template's default "mycrate" name + # Users should rename their crate before publishing + exclude: mycrate \ No newline at end of file From cd7b554032890f5e6ad656a34515dc744cdb6b06 Mon Sep 17 00:00:00 2001 From: dkgoutham Date: Fri, 27 Jun 2025 20:15:26 +0200 Subject: [PATCH 05/10] Rename mycrate to template-crate and update semver workflow --- .github/workflows/docs.yml | 2 +- .github/workflows/semver-checks.yml | 5 +---- Cargo.toml | 4 ++-- {mycrate => template-crate}/Cargo.toml | 2 +- {mycrate => template-crate}/README.md | 0 {mycrate => template-crate}/doc/mainpage-doc.md | 0 {mycrate => template-crate}/src/lib.rs | 0 7 files changed, 5 insertions(+), 8 deletions(-) rename {mycrate => template-crate}/Cargo.toml (95%) rename {mycrate => template-crate}/README.md (100%) rename {mycrate => template-crate}/doc/mainpage-doc.md (100%) rename {mycrate => template-crate}/src/lib.rs (100%) diff --git a/.github/workflows/docs.yml b/.github/workflows/docs.yml index cb8f6e5..5a50c69 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 index e70379f..4812c6c 100644 --- a/.github/workflows/semver-checks.yml +++ b/.github/workflows/semver-checks.yml @@ -21,7 +21,4 @@ jobs: - name: Check semver compatibility uses: obi1kenobi/cargo-semver-checks-action@v2 - with: - # Skip semver checks if this is still the template's default "mycrate" name - # Users should rename their crate before publishing - exclude: mycrate \ No newline at end of file + diff --git a/Cargo.toml b/Cargo.toml index 896ca62..695ed8b 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/mycrate/Cargo.toml b/template-crate/Cargo.toml similarity index 95% rename from mycrate/Cargo.toml rename to template-crate/Cargo.toml index e01630a..2b08830 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 From dcd1d2a8e91b2f61b66e0bb2968437c5e9559c58 Mon Sep 17 00:00:00 2001 From: stavrosvl7 Date: Mon, 30 Jun 2025 18:12:41 +0300 Subject: [PATCH 06/10] Fixes to packages & GitHub Action Signed-off-by: stavrosvl7 --- .github/workflows/docs.yml | 2 +- .github/workflows/semver-checks.yml | 27 +++++++++++++++++-- CONTRIBUTING.md | 4 +-- Cargo.toml | 4 +-- examples/Cargo.toml | 2 +- examples/README.md | 2 +- examples/src/bin/addition.rs | 2 +- {template-crate => template_crate}/Cargo.toml | 2 +- {template-crate => template_crate}/README.md | 0 .../doc/mainpage-doc.md | 0 {template-crate => template_crate}/src/lib.rs | 0 11 files changed, 34 insertions(+), 11 deletions(-) rename {template-crate => template_crate}/Cargo.toml (95%) rename {template-crate => template_crate}/README.md (100%) rename {template-crate => template_crate}/doc/mainpage-doc.md (100%) rename {template-crate => template_crate}/src/lib.rs (100%) diff --git a/.github/workflows/docs.yml b/.github/workflows/docs.yml index 5a50c69..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 template-crate + 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 index 4812c6c..bd5bbd3 100644 --- a/.github/workflows/semver-checks.yml +++ b/.github/workflows/semver-checks.yml @@ -6,6 +6,10 @@ on: pull_request: branches: [ "main" ] +# Limit permissions to minimum required +permissions: + contents: read + env: CARGO_TERM_COLOR: always CARGO_INCREMENTAL: 0 @@ -13,12 +17,31 @@ env: 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 + uses: dtolnay/rust-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: Check semver compatibility - uses: obi1kenobi/cargo-semver-checks-action@v2 - + # Pinned to v2.8: https://github.com/obi1kenobi/cargo-semver-checks-action/releases/tag/v2.8 + uses: obi1kenobi/cargo-semver-checks-action@5b298c9520f7096a4683c0bd981a7ac5a7e249ae + with: + # Optional: customize behavior + verbose: true \ 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 695ed8b..0d8599c 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -1,9 +1,9 @@ # TODO(template) update for the crate name [workspace] -members = ["examples", "template-crate"] +members = ["examples", "template_crate"] resolver = "2" -default-members = ["template-crate"] +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/template-crate/Cargo.toml b/template_crate/Cargo.toml similarity index 95% rename from template-crate/Cargo.toml rename to template_crate/Cargo.toml index 2b08830..aa411db 100644 --- a/template-crate/Cargo.toml +++ b/template_crate/Cargo.toml @@ -1,6 +1,6 @@ [package] # TODO(template) rename -name = "template-crate" +name = "template_crate" version.workspace = true edition.workspace = true repository.workspace = true diff --git a/template-crate/README.md b/template_crate/README.md similarity index 100% rename from template-crate/README.md rename to template_crate/README.md diff --git a/template-crate/doc/mainpage-doc.md b/template_crate/doc/mainpage-doc.md similarity index 100% rename from template-crate/doc/mainpage-doc.md rename to template_crate/doc/mainpage-doc.md diff --git a/template-crate/src/lib.rs b/template_crate/src/lib.rs similarity index 100% rename from template-crate/src/lib.rs rename to template_crate/src/lib.rs From 59cdff67b0c5b7d10a1f005ce3e75d8de12ad137 Mon Sep 17 00:00:00 2001 From: stavrosvl7 Date: Mon, 30 Jun 2025 18:28:41 +0300 Subject: [PATCH 07/10] Fixes to GitHub Action Signed-off-by: stavrosvl7 --- .github/workflows/semver-checks.yml | 34 +++++++++++++++++++++++++---- 1 file changed, 30 insertions(+), 4 deletions(-) diff --git a/.github/workflows/semver-checks.yml b/.github/workflows/semver-checks.yml index bd5bbd3..e76f69f 100644 --- a/.github/workflows/semver-checks.yml +++ b/.github/workflows/semver-checks.yml @@ -1,10 +1,11 @@ name: Semver checks on: - push: - branches: [ "main" ] 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: @@ -39,9 +40,34 @@ jobs: restore-keys: | ${{ runner.os }}-cargo- + - name: Get latest version tag + id: get-baseline + run: | + # Find the latest version tag + 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 + echo "Found baseline tag: $latest_tag" + echo "baseline_rev=$latest_tag" >> $GITHUB_OUTPUT + echo "skip=false" >> $GITHUB_OUTPUT + 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 uses: obi1kenobi/cargo-semver-checks-action@5b298c9520f7096a4683c0bd981a7ac5a7e249ae with: - # Optional: customize behavior - verbose: true \ No newline at end of file + 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 previous version tags found" + echo "To enable semver checking:" + echo "1. Tag your first 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" \ No newline at end of file From 9511616061c1469e144a667da0e709b112861edd Mon Sep 17 00:00:00 2001 From: stavrosvl7 Date: Mon, 30 Jun 2025 18:34:03 +0300 Subject: [PATCH 08/10] Fixes to GitHub Action Signed-off-by: stavrosvl7 --- .github/workflows/semver-checks.yml | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/.github/workflows/semver-checks.yml b/.github/workflows/semver-checks.yml index e76f69f..5d6ee85 100644 --- a/.github/workflows/semver-checks.yml +++ b/.github/workflows/semver-checks.yml @@ -27,7 +27,10 @@ jobs: fetch-depth: 0 - name: Install Rust toolchain - uses: dtolnay/rust-toolchain@stable + # 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 From bd9d0807eefa9c1df4bf8f0ba5672cf67a9209c3 Mon Sep 17 00:00:00 2001 From: stavrosvl7 Date: Tue, 1 Jul 2025 00:37:44 +0300 Subject: [PATCH 09/10] Fixes to GitHub Action Signed-off-by: stavrosvl7 --- .github/workflows/semver-checks.yml | 27 ++++++++++++++++++++------- 1 file changed, 20 insertions(+), 7 deletions(-) diff --git a/.github/workflows/semver-checks.yml b/.github/workflows/semver-checks.yml index 5d6ee85..2861bed 100644 --- a/.github/workflows/semver-checks.yml +++ b/.github/workflows/semver-checks.yml @@ -46,16 +46,26 @@ jobs: - name: Get latest version tag id: get-baseline run: | - # Find the latest version tag + # 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 - echo "Found baseline tag: $latest_tag" - echo "baseline_rev=$latest_tag" >> $GITHUB_OUTPUT - echo "skip=false" >> $GITHUB_OUTPUT + # 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 @@ -69,8 +79,11 @@ jobs: - name: Semver check skipped if: steps.get-baseline.outputs.skip == 'true' run: | - echo "✅ Semver check skipped - no previous version tags found" + echo "✅ Semver check skipped - no suitable version tags found" echo "To enable semver checking:" - echo "1. Tag your first release: git tag v0.1.0" + 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" \ No newline at end of file + 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 From 5fd72392909bf40c8ad34710b3b6b29a8bcd1d05 Mon Sep 17 00:00:00 2001 From: stavrosvl7 Date: Fri, 11 Jul 2025 15:10:05 +0300 Subject: [PATCH 10/10] PR Review fixes Signed-off-by: stavrosvl7 --- .github/workflows/semver-checks.yml | 9 +-------- 1 file changed, 1 insertion(+), 8 deletions(-) diff --git a/.github/workflows/semver-checks.yml b/.github/workflows/semver-checks.yml index 2861bed..cca3b1c 100644 --- a/.github/workflows/semver-checks.yml +++ b/.github/workflows/semver-checks.yml @@ -26,12 +26,6 @@ jobs: # cargo-semver-checks needs the full git history to compare versions fetch-depth: 0 - - name: Install Rust toolchain - # 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: @@ -70,8 +64,7 @@ jobs: - 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 - uses: obi1kenobi/cargo-semver-checks-action@5b298c9520f7096a4683c0bd981a7ac5a7e249ae + uses: obi1kenobi/cargo-semver-checks-action@v2 with: baseline-rev: ${{ steps.get-baseline.outputs.baseline_rev }} verbose: true