-
Notifications
You must be signed in to change notification settings - Fork 26
47 lines (39 loc) · 1.48 KB
/
python-publish.yml
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
# This workflow runs when a tagged release is created or it is triggered manually.
# For more information see:
# - Python docs: https://packaging.python.org/en/latest/guides/publishing-package-distribution-releases-using-github-actions-ci-cd-workflows/
# - GitHub action: https://github.com/marketplace/actions/pypi-publish
# - GitHub docs: https://docs.github.com/en/actions/automating-builds-and-tests/building-and-testing-python#publishing-to-package-registries
# The source distribution (sdist) is built with the `build` package
# (https://pypa-build.readthedocs.io/en/stable/index.html).
# The sdist is attempted uploaded to TestPyPI and PyPI whenever the workflow is run
name: Upload to PyPI
on:
release:
types: [published]
workflow_dispatch:
jobs:
deploy:
runs-on: ubuntu-latest
environment: release
permissions:
# IMPORTANT: this permission is mandatory for trusted publishing
id-token: write
steps:
- uses: actions/checkout@v4
- name: Set up Python
uses: actions/setup-python@v5
with:
python-version: '3.x'
- name: Install dependencies
run: |
python -m pip install --upgrade pip
pip install build
- name: Build package
run: |
python -m build
- name: Publish package to TestPyPI
uses: pypa/gh-action-pypi-publish@release/v1
with:
repository-url: https://test.pypi.org/legacy/
- name: Publish package to PyPI
uses: pypa/gh-action-pypi-publish@release/v1