labelformat icon indicating copy to clipboard operation
labelformat copied to clipboard

Add autorelease workflow

Open philippmwirth opened this issue 2 years ago • 0 comments

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.

philippmwirth avatar Nov 14 '23 07:11 philippmwirth