From dae2f26d6675e80dc6e4e91a2a7a90260b99433a Mon Sep 17 00:00:00 2001 From: itsparser Date: Thu, 25 Sep 2025 15:35:54 +0530 Subject: [PATCH 1/3] fix: Check if version exists before publishing to crates.io --- .github/workflows/version-bump.yml | 14 +++++++++++++- 1 file changed, 13 insertions(+), 1 deletion(-) diff --git a/.github/workflows/version-bump.yml b/.github/workflows/version-bump.yml index e907652..68671c8 100644 --- a/.github/workflows/version-bump.yml +++ b/.github/workflows/version-bump.yml @@ -67,7 +67,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: @@ -90,7 +102,7 @@ jobs: **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] From 50c023ac916c3fd0e94cd3fd64ee86b46e329f20 Mon Sep 17 00:00:00 2001 From: itsparser Date: Thu, 25 Sep 2025 15:36:22 +0530 Subject: [PATCH 2/3] fix: Use patch version bumps instead of minor --- .github/workflows/version-bump.yml | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/.github/workflows/version-bump.yml b/.github/workflows/version-bump.yml index 68671c8..c52b87e 100644 --- a/.github/workflows/version-bump.yml +++ b/.github/workflows/version-bump.yml @@ -39,9 +39,9 @@ jobs: echo "current_version=$CURRENT_VERSION" >> "$GITHUB_OUTPUT" echo "Current version: $CURRENT_VERSION" - - name: Bump minor version + - name: Bump patch version run: | - cargo set-version --bump minor + cargo set-version --bump patch 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" From 2e390f603fee79ece8844dc602f5e7ecd037a489 Mon Sep 17 00:00:00 2001 From: itsparser Date: Thu, 25 Sep 2025 15:39:04 +0530 Subject: [PATCH 3/3] feat: Use PR labels to determine version bump type (major/minor/patch) --- .github/workflows/version-bump.yml | 23 +++++++++++++++++++++-- 1 file changed, 21 insertions(+), 2 deletions(-) diff --git a/.github/workflows/version-bump.yml b/.github/workflows/version-bump.yml index c52b87e..94326ec 100644 --- a/.github/workflows/version-bump.yml +++ b/.github/workflows/version-bump.yml @@ -39,9 +39,26 @@ jobs: echo "current_version=$CURRENT_VERSION" >> "$GITHUB_OUTPUT" echo "Current version: $CURRENT_VERSION" - - name: Bump patch version + - name: Determine version bump type + id: version_type run: | - cargo set-version --bump patch + 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" @@ -99,6 +116,8 @@ jobs: **PR Title:** ${{ github.event.pull_request.title }} + **Version Bump:** ${{ steps.version_type.outputs.bump_type | upper }} + **Merged by:** @${{ github.event.pull_request.merged_by.login }} ### Published to crates.io