2022-12-19 13:55:18 +00:00
|
|
|
---
|
2022-12-19 15:06:37 +00:00
|
|
|
name: Deploy to (Test-) PyPI
|
2022-12-19 13:55:18 +00:00
|
|
|
|
|
|
|
on:
|
|
|
|
push:
|
|
|
|
tags: ["*"]
|
|
|
|
release:
|
|
|
|
types:
|
|
|
|
- published
|
|
|
|
|
|
|
|
permissions:
|
|
|
|
contents: read
|
|
|
|
|
|
|
|
jobs:
|
|
|
|
release-test-pypi:
|
2022-12-19 15:06:37 +00:00
|
|
|
# Upload to Test PyPI on every pushed tag.
|
2022-12-19 13:55:18 +00:00
|
|
|
environment: release-test-pypi
|
2022-12-19 13:57:10 +00:00
|
|
|
if: github.event_name == 'push' && startsWith(github.ref, 'refs/tags')
|
2022-12-19 15:06:37 +00:00
|
|
|
runs-on: ubuntu-latest
|
2022-12-19 13:55:18 +00:00
|
|
|
|
|
|
|
steps:
|
|
|
|
- name: Harden Runner
|
|
|
|
uses: step-security/harden-runner@v2
|
|
|
|
with:
|
|
|
|
egress-policy: block
|
2022-12-19 14:22:42 +00:00
|
|
|
# Need the real pypi.org for installations.
|
2022-12-19 13:55:18 +00:00
|
|
|
allowed-endpoints: >
|
|
|
|
files.pythonhosted.org:443
|
|
|
|
github.com:443
|
2022-12-19 14:22:42 +00:00
|
|
|
pypi.org:443
|
2022-12-19 13:55:18 +00:00
|
|
|
test.pypi.org:443
|
|
|
|
|
|
|
|
- uses: actions/checkout@v3
|
2022-12-19 14:33:05 +00:00
|
|
|
# with:
|
|
|
|
# fetch-depth: 0
|
2022-12-19 13:55:18 +00:00
|
|
|
|
2022-12-19 14:40:41 +00:00
|
|
|
- name: Build package
|
|
|
|
run: |
|
|
|
|
python -m pip install -U build twine wheel
|
|
|
|
python -m build
|
|
|
|
twine check --strict dist/*
|
2022-12-19 14:33:05 +00:00
|
|
|
|
2022-12-19 15:06:37 +00:00
|
|
|
- name: Publish package to Test PyPI
|
2022-12-19 13:55:18 +00:00
|
|
|
uses: pypa/gh-action-pypi-publish@release/v1
|
|
|
|
with:
|
|
|
|
password: ${{ secrets.TEST_PYPI_API_TOKEN }}
|
|
|
|
repository_url: https://test.pypi.org/legacy/
|
|
|
|
|
|
|
|
release-pypi:
|
2022-12-19 15:06:37 +00:00
|
|
|
# Upload to real PyPI on GitHub Releases.
|
2022-12-19 13:55:18 +00:00
|
|
|
environment: release-pypi
|
2022-12-19 13:57:10 +00:00
|
|
|
if: github.event.action == 'published'
|
2022-12-19 15:06:37 +00:00
|
|
|
runs-on: ubuntu-latest
|
2022-12-19 13:55:18 +00:00
|
|
|
|
|
|
|
steps:
|
|
|
|
- name: Harden Runner
|
|
|
|
uses: step-security/harden-runner@v2
|
|
|
|
with:
|
|
|
|
egress-policy: block
|
|
|
|
allowed-endpoints: >
|
|
|
|
files.pythonhosted.org:443
|
|
|
|
github.com:443
|
|
|
|
pypi.org:443
|
2022-12-21 09:41:58 +00:00
|
|
|
upload.pypi.org:443
|
2022-12-19 13:55:18 +00:00
|
|
|
|
|
|
|
- uses: actions/checkout@v3
|
2022-12-19 14:40:41 +00:00
|
|
|
# with:
|
|
|
|
# fetch-depth: 0
|
2022-12-19 13:55:18 +00:00
|
|
|
|
2022-12-19 14:40:41 +00:00
|
|
|
- name: Build package
|
|
|
|
run: |
|
|
|
|
python -m pip install -U build twine wheel
|
|
|
|
python -m build
|
|
|
|
twine check --strict dist/*
|
2022-12-19 13:55:18 +00:00
|
|
|
|
|
|
|
- name: Publish package to PyPI
|
|
|
|
uses: pypa/gh-action-pypi-publish@release/v1
|
|
|
|
with:
|
|
|
|
password: ${{ secrets.PYPI_API_TOKEN }}
|