diff --git a/.github/workflows/release.yaml b/.github/workflows/release.yaml index 18370a7..92e5db6 100644 --- a/.github/workflows/release.yaml +++ b/.github/workflows/release.yaml @@ -39,25 +39,26 @@ jobs: - name: Bump version (automatic) if: ${{ !inputs.force_version }} + id: auto_version run: | semantic-release version --no-push --no-commit + VERSION=$(python -c "import tomllib; print(tomllib.load(open('pyproject.toml', 'rb'))['project']['version'])") + echo "version=$VERSION" >> $GITHUB_OUTPUT - name: Bump version (forced) if: ${{ inputs.force_version }} + id: forced_version run: | sed -i 's/^version = ".*"/version = "${{ inputs.force_version }}"/' pyproject.toml - - - name: Get version - id: version - run: | - VERSION=$(grep '^version = "' pyproject.toml | cut -d'"' -f2) - echo "version=$VERSION" >> $GITHUB_OUTPUT + echo "version=${{ inputs.force_version }}" >> $GITHUB_OUTPUT - name: Commit and tag + env: + VERSION: ${{ steps.forced_version.outputs.version || steps.auto_version.outputs.version }} run: | git add pyproject.toml CHANGELOG.md 2>/dev/null || git add pyproject.toml - git commit -m "chore(release): bump version to ${{ steps.version.outputs.version }}" || echo "No changes to commit" - git tag -a "v${{ steps.version.outputs.version }}" -m "Release v${{ steps.version.outputs.version }}" + git commit -m "chore(release): bump version to $VERSION" || echo "No changes to commit" + git tag -a "v$VERSION" -m "Release v$VERSION" git push origin main --tags - uses: astral-sh/setup-uv@v3 @@ -71,6 +72,6 @@ jobs: - name: Create GitHub Release uses: softprops/action-gh-release@v2 with: - tag_name: v${{ steps.version.outputs.version }} + tag_name: v${{ steps.forced_version.outputs.version || steps.auto_version.outputs.version }} generate_release_notes: true files: dist/*