Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add autorelease workflow #11

Open
philippmwirth opened this issue Nov 14, 2023 · 0 comments
Open

Add autorelease workflow #11

philippmwirth opened this issue Nov 14, 2023 · 0 comments

Comments

@philippmwirth
Copy link
Contributor

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.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant