Skip to content

Commit

Permalink
Upload package in CI via PyPI trusted publisher
Browse files Browse the repository at this point in the history
  • Loading branch information
justinmayer committed Jul 2, 2023
1 parent 84ddb97 commit 5f63b53
Showing 1 changed file with 17 additions and 10 deletions.
27 changes: 17 additions & 10 deletions .github/workflows/main.yml
Original file line number Diff line number Diff line change
Expand Up @@ -46,10 +46,10 @@ jobs:
with:
retry: true

- name: Install poetry
- name: Install Poetry
run: pipx install poetry

- name: Setup Python
- name: Set up Python
uses: actions/setup-python@v4
with:
python-version: "3.9"
Expand All @@ -64,38 +64,45 @@ jobs:
- name: Run linters
run: poetry run invoke lint --diff


deploy:
name: Deploy
environment: Deployment
needs: [test, lint]
runs-on: ubuntu-latest
if: github.ref=='refs/heads/main' && github.event_name!='pull_request'

permissions:
contents: write
id-token: write

steps:
- uses: actions/checkout@v3
with:
token: ${{ secrets.GH_TOKEN }}

- name: Setup Python
- name: Set up Python
uses: actions/setup-python@v4
with:
python-version: "3.9"

- name: Check release
id: check_release
continue-on-error: true
run: |
python -m pip install --upgrade pip
python -m pip install poetry githubrelease httpx==0.16.1 autopub
python -m pip install autopub[github]
autopub check
- name: Publish
if: steps.check_release.outcome=='success'
if: ${{ steps.check_release.outputs.autopub_release=='true' }}
env:
GITHUB_TOKEN: ${{ secrets.GH_TOKEN }}
PYPI_PASSWORD: ${{ secrets.PYPI_PASSWORD }}
run: |
git remote set-url origin https://[email protected]/${{ github.repository }}
autopub prepare
poetry build
autopub commit
autopub build
autopub githubrelease
poetry publish -u __token__ -p $PYPI_PASSWORD
- name: Upload package to PyPI
if: ${{ steps.check_release.outputs.autopub_release=='true' }}
uses: pypa/gh-action-pypi-publish@release/v1

0 comments on commit 5f63b53

Please sign in to comment.