-
Notifications
You must be signed in to change notification settings - Fork 2
Add semver-checks workflow #17
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Merged
Merged
Changes from 9 commits
Commits
Show all changes
10 commits
Select commit
Hold shift + click to select a range
ee60d46
Add cargo-semver-checks workflow
e802b9f
Fix semver-checks workflow configuration
dkgoutham a7f2ab1
Fix semver-checks workflow: remove invalid package parameter
dkgoutham dfd3c62
Configure semver-checks to skip template's default package names
dkgoutham cd7b554
Rename mycrate to template-crate and update semver workflow
dkgoutham dcd1d2a
Fixes to packages & GitHub Action
svlachakis 59cdff6
Fixes to GitHub Action
svlachakis 9511616
Fixes to GitHub Action
svlachakis bd9d080
Fixes to GitHub Action
svlachakis 5fd7239
PR Review fixes
svlachakis File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| 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 | ||
| # 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 | ||
|
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" | ||
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
File renamed without changes.
File renamed without changes.
File renamed without changes.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.