Skip to content

Commit 89bfc1a

Browse files
committed
release on PR merge
1 parent 5af4959 commit 89bfc1a

File tree

1 file changed

+49
-0
lines changed

1 file changed

+49
-0
lines changed

.github/workflows/publish-to-pypi.yml

+49
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,49 @@
1+
name: Publish Python Package
2+
3+
on:
4+
push:
5+
branches:
6+
- master
7+
8+
jobs:
9+
build-and-publish:
10+
runs-on: ubuntu-latest
11+
12+
steps:
13+
- name: Checkout code
14+
uses: actions/checkout@v2
15+
16+
- name: Set up Python
17+
uses: actions/setup-python@v2
18+
with:
19+
python-version: '3.x'
20+
21+
- name: Install dependencies
22+
run: pip install -r requirements.txt
23+
24+
- name: Get current version
25+
id: get_version
26+
run: |
27+
VERSION=$(python -c "exec(open('setup.py').read()); print(__version__)")
28+
echo "VERSION=$VERSION" >> $GITHUB_ENV
29+
30+
- name: Build the package
31+
run: |
32+
python setup.py sdist bdist_wheel
33+
34+
- name: Publish to PyPI
35+
env:
36+
TWINE_USERNAME: ${{ secrets.PYPI_USERNAME }}
37+
TWINE_PASSWORD: ${{ secrets.PYPI_PASSWORD }}
38+
run: |
39+
pip install twine
40+
twine upload dist/*
41+
42+
- name: Create Git tag
43+
if: success()
44+
run: |
45+
git config user.name "GitHub Actions"
46+
git config user.email "[email protected]"
47+
git tag -a v${{ env.VERSION }} -m "Release version ${{ env.VERSION }}"
48+
git push origin v${{ env.VERSION }}
49+

0 commit comments

Comments
 (0)