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
72 changes: 72 additions & 0 deletions .github/actions/create-release-pr-for-python/action.yml
Original file line number Diff line number Diff line change
@@ -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 <<EOF > /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
Loading