From a95182c847a826d4c353a375335a85b2b7e52335 Mon Sep 17 00:00:00 2001 From: meriy100 Date: Tue, 26 May 2026 17:36:47 +0900 Subject: [PATCH] feat: Add create-release-pr-for-python action Add a new composite action for creating release PRs for Python packages. Based on create-release-pr-for-gem, with the version file update step changed from awk (single-quote pattern) to sed (double-quote pattern) to support Python's VERSION = "x.y.z" convention. Co-Authored-By: Claude Opus 4.6 --- .../create-release-pr-for-python/action.yml | 72 +++++++++++++++++++ 1 file changed, 72 insertions(+) create mode 100644 .github/actions/create-release-pr-for-python/action.yml diff --git a/.github/actions/create-release-pr-for-python/action.yml b/.github/actions/create-release-pr-for-python/action.yml new file mode 100644 index 0000000..196b3df --- /dev/null +++ b/.github/actions/create-release-pr-for-python/action.yml @@ -0,0 +1,72 @@ +name: Create Release PR for Python +description: Create a pull request for releasing a new version of a Python package. +inputs: + base-branch: + required: true + description: The base branch + version-file-path: + required: true + description: The path to the version file. ex. ./src/my_pkg/version.py + commit-user-email: + description: The email address of the user who created the commit + default: "41898282+github-actions[bot]@users.noreply.github.com" + commit-user-name: + description: The name of the user who created the commit + default: "github-actions[bot]" + tag-prefix: + description: The tag prefix + default: "v" + pre-release: + description: Whether the release is a pre-release + default: false + source-branch: + required: false + description: Branch to scan for commits. Defaults to base-branch if not specified. + default: "" + +runs: + using: "composite" + steps: + - name: Checkout repository + uses: actions/checkout@v4 + with: + fetch-depth: 2 + ref: ${{ inputs.source-branch || inputs.base-branch }} + token: ${{ env.GITHUB_TOKEN }} + - name: Conventional Changelog Action + id: changelog + uses: TriPSs/conventional-changelog-action@v6 + with: + preset: conventionalcommits + skip-version-file: true + output-file: false + git-branch: ${{ inputs.source-branch || inputs.base-branch }} + git-push: false + skip-commit: true + skip-tag: true + tag-prefix: ${{ inputs.tag-prefix }} + github-token: ${{ env.GITHUB_TOKEN }} + pre-release: ${{ inputs.pre-release }} + - name: Commit version up commit + if: ${{ steps.changelog.outputs.skipped == 'false' }} + env: + VERSION: ${{ steps.changelog.outputs.version }} + run: | + git config --local user.email "${{ inputs.commit-user-email }}" + git config --local user.name "${{ inputs.commit-user-name }}" + git checkout -b release/${{ inputs.tag-prefix }}$VERSION + sed -i "s/VERSION = \".*\"/VERSION = \"$VERSION\"/" ${{ inputs.version-file-path }} + git add ${{ inputs.version-file-path }} + git commit -m "chore: bump version to v$VERSION" + git push origin release/${{ inputs.tag-prefix }}$VERSION + shell: bash + - name: Create Pull Request + if: ${{ steps.changelog.outputs.skipped == 'false' }} + env: + GH_TOKEN: ${{ env.GITHUB_TOKEN }} + run: | + cat < /tmp/pr_body.txt + ${{ steps.changelog.outputs.clean_changelog }} + EOF + gh pr create --title "chore: Release version to v${{ steps.changelog.outputs.version }}" --body-file /tmp/pr_body.txt --base ${{ inputs.base-branch }} --head release/${{ inputs.tag-prefix }}${{ steps.changelog.outputs.version }} + shell: bash