Skip to content

Commit 98339d3

Browse files
committed
Trusted publishing for PyPI.org
1 parent f366847 commit 98339d3

File tree

2 files changed

+18
-10
lines changed

2 files changed

+18
-10
lines changed

.github/workflows/publish-test.yaml

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -204,6 +204,11 @@ jobs:
204204
PROJECT_VESION=$(poetry version -s)
205205
echo "PROJECT_VESION=$PROJECT_VESION" >> $GITHUB_ENV
206206
207+
# Publish with "trusted publisher" mechanism:
208+
# https://docs.pypi.org/trusted-publishers/
209+
#
210+
# Requires GHA token permission (above in YAML) and PyPI magement:
211+
# https://test.pypi.org/manage/project/otdf-python/settings/publishing/
207212
- name: Publish package distributions to PyPI
208213
uses: pypa/gh-action-pypi-publish@release/v1
209214
with:
@@ -216,5 +221,6 @@ jobs:
216221
README.md,
217222
dist/*.whl
218223
body: otdf_python version ${{ env.PROJECT_VESION }}
224+
makeLatest: "false"
219225
tag: "${{ env.PROJECT_VESION }}-dev-${{ github.sha }}"
220226
# tag: v${{ env.PROJECT_VESION }}

.github/workflows/publish.yaml

Lines changed: 12 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -180,6 +180,8 @@ jobs:
180180
release:
181181
permissions:
182182
contents: write
183+
# This permission is mandatory for PyPI's trusted publishing
184+
id-token: write
183185
needs: [build_macos, build_linux_x86_64]
184186
runs-on: ubuntu-latest
185187
# if: github.ref == 'refs/heads/main'
@@ -202,16 +204,16 @@ jobs:
202204
PROJECT_VESION=$(poetry version -s)
203205
echo "PROJECT_VESION=$PROJECT_VESION" >> $GITHUB_ENV
204206
205-
- name: Install twine
206-
run: pip install twine
207-
208-
- name: Upload to PyPI
209-
env:
210-
TWINE_UPLOAD_URL: https://upload.pypi.org/legacy/
211-
PYPI_USERNAME: ${{ secrets.PYPI_USERNAME }}
212-
PYPI_PASSWORD: ${{ secrets.PYPI_PASSWORD }}
213-
run: |
214-
twine upload --password "$PYPI_PASSWORD" --user "$PYPI_USERNAME" --repository-url "$TWINE_UPLOAD_URL" dist/*
207+
# Publish with "trusted publisher" mechanism:
208+
# https://docs.pypi.org/trusted-publishers/
209+
#
210+
# Requires GHA token permission (above in YAML) and PyPI magement:
211+
# https://pypi.org/manage/project/otdf-python/settings/publishing/
212+
- name: Publish package distributions to PyPI
213+
uses: pypa/gh-action-pypi-publish@release/v1
214+
with:
215+
# repository-url: https://pypi.org/legacy/
216+
packages-dir: dist/
215217

216218
- uses: ncipollo/release-action@v1
217219
with:

0 commit comments

Comments
 (0)