-
-
Notifications
You must be signed in to change notification settings - Fork 74
42 lines (39 loc) · 1.39 KB
/
publish-to-pypi.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
name: Publish Python 🐍 distributions 📦 to PyPI and TestPyPI
# publish wheels and source to test.pypi.org on releases/* branch
# publish wheels and source to pypi.org when pushing v* tag on master or releasees/* branch
on:
push:
branches:
- master
- releases/*
tags:
- v*
jobs:
build-n-publish:
name: Build and publish Python 🐍 distributions 📦 to PyPI and TestPyPI
runs-on: ubuntu-20.04
steps:
- name: Checkout 🛎️
uses: actions/checkout@v4
- name: Set up Python 3.9🐍
uses: actions/setup-python@v2
with:
python-version: 3.9
- name: Install dependency
run: python -m pip install -U pip wheel setuptools setuptools_scm[toml] twine build
- name: Build release assets
run: |
python -m build --sdist --wheel
- name: twine check
run: python -m twine check dist/*
- name: Publish distribution 📦 to Test PyPI
if: startsWith(github.event.ref, 'refs/heads/releases/')
uses: pypa/gh-action-pypi-publish@master
with:
password: ${{ secrets.testpypi_password }}
repository_url: https://test.pypi.org/legacy/
- name: Publish distribution 📦 to PyPI
if: startsWith(github.event.ref, 'refs/tags')
uses: pypa/gh-action-pypi-publish@master
with:
password: ${{ secrets.pypi_password }}