Setup Release #6
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
name: Setup Release | |
on: | |
workflow_dispatch: | |
inputs: | |
version_rule: | |
description: "Version to bump (major, minor, patch)" | |
required: true | |
type: choice | |
options: | |
- "major" | |
- "minor" | |
- "patch" | |
default: "minor" | |
jobs: | |
setup-release: | |
runs-on: ubuntu-latest | |
permissions: | |
contents: write | |
pull-requests: write | |
issues: write | |
steps: | |
- name: Checkout code | |
uses: actions/checkout@v4 | |
- name: Set up Python | |
uses: actions/setup-python@v5 | |
with: | |
python-version: 3.11 | |
- name: Install Poetry | |
run: | | |
pip install poetry | |
- name: Update the version | |
id: bump_version | |
run: | | |
poetry version ${{ github.event.inputs.version_rule }} | |
echo VERSION=$(poetry version -s) >> "$GITHUB_OUTPUT" | |
# First create a PR for the new version before pushing the artifacts. If this fails, we can just rerun the job since there are no artifacts uploaded yet. | |
- name: commit the new pyproject.toml with the new version | |
uses: EndBug/add-and-commit@v9 # You can change this to use a specific version. | |
with: | |
message: "chore(ci): bumped the version to ${{ steps.bump_version.outputs.VERSION }}" | |
new_branch: "chore/version-bump-${{ steps.bump_version.outputs.VERSION }}" | |
default_author: github_actions | |
# Create a PR for the new version since we don't want to push directly to main | |
- name: create pull request | |
run: gh pr create -B main -H "chore/version-bump-${{ steps.bump_version.outputs.VERSION }}" --title 'Bump the version to ${{ steps.bump_version.outputs.VERSION }}' --body 'Created by the `Release` Github action' | |
env: | |
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} |