-
Notifications
You must be signed in to change notification settings - Fork 1
48 lines (44 loc) · 1.46 KB
/
Copy pathpublish-python-package.yml
File metadata and controls
48 lines (44 loc) · 1.46 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
name: publish-python-package
# Manual only. Never publishes on push or tag.
on:
workflow_dispatch:
inputs:
target:
description: "Publish target"
required: true
type: choice
options:
- testpypi
- pypi
jobs:
publish:
runs-on: ubuntu-latest
# Uses the GitHub environment matching the chosen target (testpypi / pypi),
# so environment protection rules and secrets apply.
environment: ${{ inputs.target }}
steps:
- uses: actions/checkout@v4
- uses: actions/setup-python@v5
with:
python-version: '3.11'
- name: Install build tooling
run: python -m pip install --upgrade pip build twine
- name: Build sdist and wheel
run: |
rm -rf dist build *.egg-info src/*.egg-info
python -m build
- name: twine check
run: python -m twine check dist/*
- name: Publish to TestPyPI
if: ${{ inputs.target == 'testpypi' }}
env:
TWINE_USERNAME: __token__
# Token comes from the repository/environment secret; never echoed.
TWINE_PASSWORD: ${{ secrets.TEST_PYPI_API_TOKEN }}
run: python -m twine upload --repository-url https://test.pypi.org/legacy/ dist/*
- name: Publish to PyPI
if: ${{ inputs.target == 'pypi' }}
env:
TWINE_USERNAME: __token__
TWINE_PASSWORD: ${{ secrets.PYPI_API_TOKEN }}
run: python -m twine upload dist/*