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
78 changes: 78 additions & 0 deletions .github/workflows/main.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,78 @@
name: Release Python Package

on:
# This allows you to run this workflow manually from the Actions tab
workflow_dispatch:
inputs:
version_type:
description: 'Version type (major, minor, or patch)'
required: true
type: choice
options:
- patch
- minor
- major

jobs:
release:
runs-on: ubuntu-latest
# Grant permissions to write to the repository for committing the version bump and creating a tag.
permissions:
contents: write
steps:
- name: Check out repository
uses: actions/checkout@v4
with:
# This token is needed to push changes back to the repo
token: ${{ secrets.GITHUB_TOKEN }}

- name: Set up Python
uses: actions/setup-python@v5
with:
python-version: '3.12'

- name: Install Poetry
run: pipx install poetry

- name: Configure Poetry
run: poetry config virtualenvs.in-project true

- name: Install dependencies
run: poetry install --no-root

- name: Configure Git
run: |
git config user.name "github-actions[bot]"
git config user.email "github-actions[bot]@users.noreply.github.com"

- name: Bump version number
id: version_bump
run: |
poetry version ${{ github.event.inputs.version_type }}

# Extract the new version number to use in later steps
NEW_VERSION=$(poetry version --short)
echo "new_version=$NEW_VERSION" >> "$GITHUB_OUTPUT"

- name: Commit and push version change
run: |
git add pyproject.toml
git commit -m "Bump version to v${{ steps.version_bump.outputs.new_version }}"
git push

- name: Tag the commit
run: |
git tag "v${{ steps.version_bump.outputs.new_version }}"
git push origin "v${{ steps.version_bump.outputs.new_version }}"

- name: Create GitHub Release
id: create_release
uses: comnoco/create-release@v2
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} # This token is provided by Actions, you do not need to create your own token
with:
tag_name: "v${{ steps.version_bump.outputs.new_version }}"
release_name: "Release v${{ steps.version_bump.outputs.new_version }}"
body: ""
draft: false
prerelease: false