Skip to content

Commit 8fa999c

Browse files
committed
add workflow to publish to PyPI
1 parent 3f9956c commit 8fa999c

File tree

1 file changed

+42
-0
lines changed

1 file changed

+42
-0
lines changed

.github/workflows/publish.yml

Lines changed: 42 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,42 @@
1+
name: Publish Python Package
2+
3+
on:
4+
release:
5+
types: [published]
6+
workflow_dispatch:
7+
8+
jobs:
9+
#test: ## dont publish without passing test
10+
publish:
11+
runs-on: ubuntu-latest
12+
#needs: [test]
13+
steps:
14+
- uses: actions/checkout@v2
15+
- name: Set up Python
16+
uses: actions/setup-python@v2
17+
with:
18+
python-version: '3.9'
19+
- uses: actions/cache@v2
20+
name: Configure pip caching
21+
with:
22+
path: ~/.cache/pip
23+
key: ${{ runner.os }}-publish-pip-${{ hashFiles('**/setup.py') }}
24+
restore-keys: |
25+
${{ runner.os }}-publish-pip-
26+
- name: Build package
27+
env:
28+
VERSION: ${{ github.event.release.tag_name }}
29+
run: |
30+
pip install setuptools
31+
python setup.py sdist
32+
rm dist/*.orig #clean sdist_upip noise
33+
- name: Publish to Test PyPI
34+
uses: pypa/gh-action-pypi-publish@release/v1
35+
with:
36+
password: ${{ secrets.TEST_PYPI_API_TOKEN }}
37+
repository_url: https://test.pypi.org/legacy/
38+
- name: Publish to PyPI
39+
uses: pypa/gh-action-pypi-publish@release/v1
40+
if: github.event.release.tag_name
41+
with:
42+
password: ${{ secrets.PYPI_API_TOKEN }}

0 commit comments

Comments
 (0)