From 0273671f9f57d61792f6d40eef79cecd9a672461 Mon Sep 17 00:00:00 2001 From: Nabin Date: Thu, 19 Jun 2025 12:52:56 -0400 Subject: [PATCH] fix: test file fixed --- .github/workflows/release.yaml | 85 ++++++++++------------------------ 1 file changed, 24 insertions(+), 61 deletions(-) diff --git a/.github/workflows/release.yaml b/.github/workflows/release.yaml index ba248c5..cf80461 100644 --- a/.github/workflows/release.yaml +++ b/.github/workflows/release.yaml @@ -41,7 +41,7 @@ jobs: - name: Get version id: version run: | - version=$(git describe --abbrev=0 --tags 2>/dev/null || echo "0.0.0") + version=$(git describe --abbrev=0 --tags) echo $version echo "version=${version}" >> $GITHUB_OUTPUT @@ -60,9 +60,9 @@ jobs: exit 1 release: - needs: [test] + needs: test # For manual releases, also need version check - if: always() && needs.test.result == 'success' && (needs.check-version.result == 'success' || needs.check-version.result == 'skipped' || github.event_name == 'push') + if: always() && needs.test.result == 'success' && (needs.check-version.result == 'success' || needs.check-version.result == 'skipped') runs-on: ubuntu-latest timeout-minutes: 30 @@ -86,113 +86,76 @@ jobs: run: | if [ "${{ github.event_name }}" == "workflow_dispatch" ]; then echo "version=${{ inputs.release-version }}" >> $GITHUB_OUTPUT - echo "Manual release triggered with version: ${{ inputs.release-version }}" else # For automatic releases, use semantic versioning # Get the latest tag - latest_tag=$(git describe --abbrev=0 --tags 2>/dev/null || echo "0.0.0") + latest_tag=$(git describe --abbrev=0 --tags 2>/dev/null || echo "v0.0.0") echo "Latest tag: $latest_tag" - # Remove 'v' prefix if present for calculations - clean_tag=${latest_tag#v} - - # Check commit messages for version bump type since last tag - if [ "$latest_tag" = "0.0.0" ]; then - commits=$(git log --pretty=format:"%s") - else - commits=$(git log ${latest_tag}..HEAD --pretty=format:"%s") - fi - + # Check commit messages for version bump type + commits=$(git log ${latest_tag}..HEAD --pretty=format:"%s") echo "Commits since last tag:" echo "$commits" - # Check if there are any commits - if [ -z "$commits" ]; then - echo "No new commits since last tag, skipping release" - echo "skip=true" >> $GITHUB_OUTPUT - exit 0 - fi - # Determine version bump based on conventional commits - if echo "$commits" | grep -qE "^feat(\(.+\))?:|^BREAKING CHANGE"; then + if echo "$commits" | grep -q "^feat\|^BREAKING CHANGE"; then # Minor version bump for features - new_version=$(echo $clean_tag | awk -F. '{print ($1"."($2+1)".0")}') - elif echo "$commits" | grep -qE "^fix(\(.+\))?:|^perf(\(.+\))?:"; then + new_version=$(echo $latest_tag | sed 's/v//' | awk -F. '{print "v" ($1"."($2+1)".0")}') + elif echo "$commits" | grep -q "^fix\|^perf"; then # Patch version bump for fixes - new_version=$(echo $clean_tag | awk -F. '{print ($1"."$2"."($3+1))}') + new_version=$(echo $latest_tag | sed 's/v//' | awk -F. '{print "v" $1"."$2"."($3+1)}') else - echo "No version-bumping commits found (no feat:, fix:, or perf: commits)" - echo "Commits found:" - echo "$commits" - echo "skip=true" >> $GITHUB_OUTPUT + echo "No version-bumping commits found, skipping release" exit 0 fi echo "version=$new_version" >> $GITHUB_OUTPUT - echo "Determined new version: $new_version" fi - - name: Skip release if no version change - if: steps.version.outputs.skip == 'true' - run: | - echo "Skipping release - no version-bumping commits found" - exit 0 - - name: Update version in pyproject.toml - if: steps.version.outputs.skip != 'true' run: | version="${{ steps.version.outputs.version }}" - echo "Updating pyproject.toml to version: $version" + # Remove 'v' prefix if present + version=${version#v} # Update version in pyproject.toml sed -i "s/version = \"[^\"]*\"/version = \"$version\"/" pyproject.toml - # Show the change - echo "Updated pyproject.toml:" - grep 'version = ' pyproject.toml + # Commit the version change + git config --global user.name "${GITHUB_ACTOR}" + git config --global user.email "${GITHUB_ACTOR}@users.noreply.github.com" + git add pyproject.toml + git commit -m "chore: bump version to $version" || echo "No changes to commit" - name: Build Changelog - if: steps.version.outputs.skip != 'true' id: github_release uses: mikepenz/release-changelog-builder-action@v5 with: toTag: "main" configuration: ".github/changelog_config.json" - - name: Build the wheel and sdist - if: steps.version.outputs.skip != 'true' - run: uv build - - name: Create and push git tag - if: steps.version.outputs.skip != 'true' run: | version="${{ steps.version.outputs.version }}" - # Configure git - git config --global user.name "${GITHUB_ACTOR}" - git config --global user.email "${GITHUB_ACTOR}@users.noreply.github.com" - - # Commit the version change - git add pyproject.toml - git commit -m "chore: bump version to $version" || echo "No changes to commit" - # Tag the release - git tag -a "v$version" -m "Release version $version" + git tag -a "$version" -m "Release version $version" # Push the changes and tags git push origin main - git push origin "v$version" + git push origin "$version" + + - name: Build the wheel and sdist + run: uv build - name: Publish package to PyPI - if: steps.version.outputs.skip != 'true' uses: pypa/gh-action-pypi-publish@release/v1 with: password: ${{ secrets.PYPI_API_TOKEN }} packages-dir: dist/ - name: Create GitHub Release - if: steps.version.outputs.skip != 'true' uses: softprops/action-gh-release@de2c0eb89ae2a093876385947365aca7b0e5f844 with: - tag_name: v${{ steps.version.outputs.version }} + tag_name: ${{ steps.version.outputs.version }} body: ${{steps.github_release.outputs.changelog}}