diff --git a/.github/workflows/release.yaml b/.github/workflows/release.yaml index a5f24cd..7080a73 100644 --- a/.github/workflows/release.yaml +++ b/.github/workflows/release.yaml @@ -14,6 +14,15 @@ on: - 'minor' - 'patch' + repository: + description: 'Repository to publish to' + required: true + default: 'testpypi' + type: choice + options: + - 'pypi' + - 'testpypi' + jobs: release: runs-on: ubuntu-latest @@ -37,6 +46,8 @@ jobs: - name: Bump version run: | poetry run python handle_versioning.py ${{ github.event.inputs.version }} + git config user.name "${{ github.actor }}" + git config user.email "${{ github.actor }}@users.noreply.github.com" git add pyproject.toml git commit -m "Bump version to ${{ github.event.inputs.version }}" git push @@ -47,7 +58,15 @@ jobs: git tag $current_version git push origin $current_version - - name: Publish to PyPI + - name: Build package + run: | + poetry build + + - name: Publish to TestPyPI or PyPI + uses: pypa/gh-action-pypi-publish@release/v1 + with: + repository-url: ${{ github.event.inputs.repository == 'pypi' && 'https://upload.pypi.org/legacy/' || 'https://test.pypi.org/legacy/' }} + username: __token__ + password: ${{ github.event.inputs.repository == 'pypi' && secrets.PYPI_API_TOKEN || secrets.TEST_PYPI_API_TOKEN }} env: - POETRY_PYPI_TOKEN: ${{ secrets.POETRY_PYPI_TOKEN }} - run: poetry publish --build + POETRY_PYPI_TOKEN: ${{ github.event.inputs.repository == 'pypi' && secrets.PYPI_POETRY_TOKEN || secrets.TEST_PYPI_POETRY_TOKEN }}