-
Notifications
You must be signed in to change notification settings - Fork 0
75 lines (61 loc) · 2.22 KB
/
publish-pypi.yaml
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
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
name: Publish to PyPI
on:
release:
types:
- released
- prereleased
workflow_dispatch:
inputs:
pypi_repo:
description: PyPI repository to use
required: true
type: choice
options: ["testpypi", "pypi"]
env:
# Disable creating virtual envs instead CI/CD due to being unnecessary.
POETRY_VIRTUALENVS_CREATE: "false"
jobs:
build_sdist:
runs-on: ubuntu-22.04
permissions:
contents: read
steps:
- name: Checkout
uses: actions/checkout@f43a0e5ff2bd294095638e18286ca9a3d1956744 # v3.6.0
- name: Setup Python
uses: actions/setup-python@61a6322f88396a6271a6ee3565807d608ecaddd1 # v4.7.0
with:
python-version-file: '.github/requirements/.python_version'
- name: Install Dependencies
run: |
python -m pip install "poetry==$(cat .github/requirements/.poetry_version)"
- name: Build
run: python3 -m poetry build -f sdist -o ./dist
- name: Upload Build
uses: actions/upload-artifact@0b7f8abb1508181956e8e162db84b466c27e18ce # v3.1.2
with:
name: "dist"
path: "dist/"
if-no-files-found: error
retention-days: 5
publish:
runs-on: ubuntu-22.04
environment: publish-pypi
needs:
- build_sdist
permissions:
id-token: write # Required for PyPI trusted publishing
steps:
- uses: actions/download-artifact@9bc31d5ccc31df68ecc42ccf4149144866c47d8a # v3.0.2
with:
name: dist
path: dist
- name: Publish to PyPI
if: github.event_name == 'release' || (github.event_name == 'workflow_dispatch' && github.event.inputs.pypi_repo == 'pypi')
uses: pypa/gh-action-pypi-publish@b7f401de30cb6434a1e19f805ff006643653240e # v1.8.10
# Installation: python3 -m pip install --index-url https://test.pypi.org/simple/ --extra-index-url https://pypi.org/simple/ requests-hardened
- name: Publish to TestPyPI
if: github.event_name == 'workflow_dispatch' && github.event.inputs.pypi_repo == 'testpypi'
uses: pypa/gh-action-pypi-publish@b7f401de30cb6434a1e19f805ff006643653240e # v1.8.10
with:
repository-url: https://test.pypi.org/legacy/