Skip to content
Merged
Changes from all 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
37 changes: 34 additions & 3 deletions .github/workflows/version-bump.yml
Original file line number Diff line number Diff line change
Expand Up @@ -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"
Expand All @@ -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

Copilot AI Sep 25, 2025

Copy link

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 search command returns results in the format gonfig = \"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.

Suggested change
if cargo search gonfig --limit 1 | grep -q "gonfig = \"${{ env.new_version }}\""; then
if curl -s "https://crates.io/api/v1/crates/gonfig" | jq -e '.versions[].num == "${{ env.new_version }}"' > /dev/null; then

Copilot uses AI. Check for mistakes.
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:
Expand All @@ -87,10 +116,12 @@ jobs:

**PR Title:** ${{ github.event.pull_request.title }}

**Version Bump:** ${{ steps.version_type.outputs.bump_type | upper }}

Copilot AI Sep 25, 2025

Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The upper filter is not a valid GitHub Actions expression filter. This will cause a workflow syntax error. Use {{ steps.version_type.outputs.bump_type }} and handle case conversion in the shell script if needed.

Suggested change
**Version Bump:** ${{ steps.version_type.outputs.bump_type | upper }}
**Version Bump:** ${{ steps.version_type.outputs.bump_type }}

Copilot uses AI. Check for mistakes.

**Merged by:** @${{ github.event.pull_request.merged_by.login }}

### Published to crates.io
This version has been published to [crates.io](https://crates.io/crates/gonfig) and is available for use in your projects.
${{ steps.check_version.outputs.version_exists == 'false' && 'This version has been published to [crates.io](https://crates.io/crates/gonfig) and is available for use in your projects.' || 'This version was already available on [crates.io](https://crates.io/crates/gonfig).' }}

```toml
[dependencies]
Expand Down