-
Notifications
You must be signed in to change notification settings - Fork 0
feat: Smart version bumps based on PR labels #6
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 all commits
Commits
Show all changes
3 commits
Select commit
Hold shift + click to select a range
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
| Original file line number | Diff line number | Diff line change | ||||
|---|---|---|---|---|---|---|
|
|
@@ -39,9 +39,26 @@ jobs: | |||||
| echo "current_version=$CURRENT_VERSION" >> "$GITHUB_OUTPUT" | ||||||
| echo "Current version: $CURRENT_VERSION" | ||||||
|
|
||||||
| - name: Bump minor version | ||||||
| - name: Determine version bump type | ||||||
| id: version_type | ||||||
| run: | | ||||||
| cargo set-version --bump minor | ||||||
| LABELS="${{ join(github.event.pull_request.labels.*.name, ' ') }}" | ||||||
| echo "PR Labels: $LABELS" | ||||||
|
|
||||||
| if [[ "$LABELS" == *"major"* ]]; then | ||||||
| echo "bump_type=major" >> "$GITHUB_OUTPUT" | ||||||
| echo "Version bump: MAJOR" | ||||||
| elif [[ "$LABELS" == *"minor"* ]]; then | ||||||
| echo "bump_type=minor" >> "$GITHUB_OUTPUT" | ||||||
| echo "Version bump: MINOR" | ||||||
| else | ||||||
| echo "bump_type=patch" >> "$GITHUB_OUTPUT" | ||||||
| echo "Version bump: PATCH (default)" | ||||||
| fi | ||||||
|
|
||||||
| - name: Bump version | ||||||
| run: | | ||||||
| cargo set-version --bump ${{ steps.version_type.outputs.bump_type }} | ||||||
| NEW_VERSION=$(cargo metadata --no-deps --format-version 1 | jq -r '.packages[0].version') | ||||||
| echo "New version: $NEW_VERSION" | ||||||
| echo "new_version=$NEW_VERSION" >> "$GITHUB_ENV" | ||||||
|
|
@@ -67,7 +84,19 @@ jobs: | |||||
| run: | | ||||||
| git push origin "v${{ env.new_version }}" | ||||||
|
|
||||||
| - name: Check if version exists on crates.io | ||||||
| id: check_version | ||||||
| run: | | ||||||
| if cargo search gonfig --limit 1 | grep -q "gonfig = \"${{ env.new_version }}\""; then | ||||||
| echo "version_exists=true" >> "$GITHUB_OUTPUT" | ||||||
| echo "Version ${{ env.new_version }} already exists on crates.io" | ||||||
| else | ||||||
| echo "version_exists=false" >> "$GITHUB_OUTPUT" | ||||||
| echo "Version ${{ env.new_version }} does not exist, proceeding with publish" | ||||||
| fi | ||||||
|
|
||||||
| - name: Publish to crates.io | ||||||
| if: steps.check_version.outputs.version_exists == 'false' | ||||||
| run: | | ||||||
| cargo publish | ||||||
| env: | ||||||
|
|
@@ -87,10 +116,12 @@ jobs: | |||||
|
|
||||||
| **PR Title:** ${{ github.event.pull_request.title }} | ||||||
|
|
||||||
| **Version Bump:** ${{ steps.version_type.outputs.bump_type | upper }} | ||||||
|
||||||
| **Version Bump:** ${{ steps.version_type.outputs.bump_type | upper }} | |
| **Version Bump:** ${{ steps.version_type.outputs.bump_type }} |
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.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The version check logic is flawed. The
cargo searchcommand returns results in the formatgonfig = \"latest_version\"but this checks for an exact match with the new version. If the new version is newer than what's published, this grep will fail even when the version doesn't exist on crates.io.