-
-
Notifications
You must be signed in to change notification settings - Fork 87
43 lines (41 loc) · 1.34 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
43
name: Publish Python 🐍 distributions 📦 to PyPI
on:
push:
branches:
- master
- releases/*
- rel-*
tags:
- v*
jobs:
build-n-publish:
name: Build and publish Python 🐍 distributions 📦 to PyPI
runs-on: ubuntu-20.04
steps:
- name: Checkout 🛎️
uses: actions/checkout@v3
with:
fetch-depth: 50
- name: Fetch release tag
run: git fetch --depth=1 origin +refs/tags/*:refs/tags/*
- name: Set up Python 3.10🐍
uses: actions/setup-python@v4
with:
python-version: '3.10'
- name: Install build and twine
run: python -m pip install build twine --user
- name: Build release assets
run: python -m build ./
- name: twine check
run: python -m twine check dist/*
- name: Publish distribution 📦 to Test PyPI when releases branch
if: ${{ startsWith(github.event.ref, 'refs/heads/releases') }}
uses: pypa/gh-action-pypi-publish@release/v1
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@release/v1
with:
password: ${{ secrets.pypi_password }}