Skip to content

Add autorelease workflow #11

@philippmwirth

Description

@philippmwirth

To simplify the release workflow we could create a GitHub action that automatically bumps the version and releases the package to PyPI. An example script could look like this:

name: Deploy to PyPI

on:
  workflow_dispatch:
    inputs:
      version-type:
        description: 'Version bump type (major, minor, patch)'
        required: true
        default: 'patch'

jobs:
  deploy:
    runs-on: ubuntu-latest
    steps:
      - name: Check out repository
        uses: actions/checkout@v2

      - name: Set up Python
        uses: actions/setup-python@v2
        with:
          python-version: '3.7'

      - name: Install Poetry
        run: |
          curl -sSL https://install.python-poetry.org | python3 -
          echo "$HOME/.local/bin" >> $GITHUB_PATH

      - name: Bump version
        run: poetry version ${{ github.event.inputs.version-type }}

      - name: Push changes
        run: |
          git config --local user.email "[email protected]"
          git config --local user.name "GitHub Action"
          git commit -am "Increase version [skip ci]"
          git push

      - name: Publish to PyPI
        run: poetry publish --build --username __token__ --password ${{ secrets.PYPI_API_TOKEN }}

Note: With branch protection enabled we would need to find a way to enable the action committing directly to main. I think there's the option to exclude GitHub actions from branch protection rules or we could use a PAT.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions