name: Upload Python Package on: push: # Sequence of patterns matched against refs/tags tags: - v[0-9]+.[0-9]+.* # add .* to allow dev releases permissions: {} jobs: deploy: permissions: contents: write # to create a release (actions/create-release) name: pipenv PyPI Upload runs-on: ubuntu-latest env: CI: "1" steps: - name: Checkout code uses: actions/checkout@v4 - name: Create Release id: create_release uses: ncipollo/release-action@v1 with: tag: ${{ github.ref }} name: Release ${{ github.ref_name }} draft: false prerelease: false token: ${{ secrets.GITHUB_TOKEN }} - name: Set up Python 3.10 uses: actions/setup-python@v4 with: python-version: "3.10" - name: Install dependencies run: | python -m pip install --upgrade --upgrade-strategy=eager pip setuptools build wheel twine python -m pip install -e . --upgrade python -m pipenv install --dev env: PIPENV_DEFAULT_PYTHON_VERSION: "3.10" - name: Build wheels run: | python -m pipenv run python -m build # to upload to test pypi, pass repository_url: https://test.pypi.org/legacy/ and use secrets.TEST_PYPI_TOKEN - name: Publish a Python distribution to PyPI uses: pypa/gh-action-pypi-publish@release/v1 with: user: __token__ password: ${{ secrets.PYPI_TOKEN }} # repository_url: https://test.pypi.org/legacy/ packages-dir: dist/ # git push https://${{ github.actor }}:${{ secrets.GITHUB_TOKEN }}@github.com/${{ github.repository }}.git HEAD:master # we need to use a deploy key for this to get around branch protection as the default token fails - name: Pre-bump run: | git config --local user.name 'github-actions[bot]' git config --local user.email 'github-actions[bot]@users.noreply.github.com' python -m pipenv run inv release.bump-version --dev --commit - name: Push changes uses: ad-m/github-push-action@master with: github_token: ${{ secrets.REPO_TOKEN }}