Skip to content

Commit

Permalink
👷 Add github action for PyPI release
Browse files Browse the repository at this point in the history
1. use github action to release fate_client and fate_test to PyPI

Signed-off-by: weiwee <[email protected]>
  • Loading branch information
sagewe committed Jul 29, 2021
1 parent 745d07e commit 9a518b8
Showing 1 changed file with 94 additions and 0 deletions.
94 changes: 94 additions & 0 deletions .github/workflows/pypi.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,94 @@
# use pypi/<version>/develop to test build and publish to pypitest
# use pypi/<version>/release to publish pypi

name: build-wheel

on:
push:
branches:
- 'pypi/**/develop'
- 'pypi/**/release'

jobs:
build:
name: Build fate client and fate_test
strategy:
fail-fast: true
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v2

- name: Extract version and name
shell: bash
run: |
# extract version and name from patterm: pypi/<version>/<name>
echo ::set-output name=version::$(echo ${GITHUB_REF} | sed -E -e 's/refs\/heads\/pypi\/(.*)\/(develop|release)/\1/g')
echo ::set-output name=name::$(echo ${GITHUB_REF} | sed -E -e 's/refs\/heads\/pypi\/(.*)\/(develop|release)/\2/g')
id: extract

- uses: actions/setup-python@v2
with:
python-version: 3.6

- name: Prepare poetry
uses: abatilo/[email protected]
with:
poetry-version: 1.1.6

- name: Build fate_client
run: |
cd python/fate_client
rm -f setup.py
# clear README.rst
echo "# fate client" > README.rst
# bump fate client version
poetry version ${{steps.extract.outputs.version}}
# build package, saved in dist/
poetry build
- name: Build fate_test
run: |
cd python/fate_test &&
# clear README.rst
echo "# fate test" > README.rst
# bump fate test version
poetry version ${{steps.extract.outputs.version}}
# update dependency version
sed -E -i "s/(fate_client\s*=\s*)(.*)/\1\"${{steps.extract.outputs.version}}\"/g" pyproject.toml
cat pyproject.toml
# build package, saved in dist/
poetry build
- name: List dist files
run: ls -lh python/fate_client/dist/ python/fate_test/dist/

- name: Twine check
run: |
pip install -U twine
twine check python/fate_client/dist/*
twine check python/fate_test/dist/*
- name: Upload to artifact
uses: actions/upload-artifact@v2
with:
path: |
python/fate_client/dist/*
python/fate_test/dist/*
- name: Upload to PyPI Test
if: ${{ steps.extract.outputs.name == 'develop' }}
run: |
twine upload --repository testpypi python/fate_client/dist/*
twine upload --repository testpypi python/fate_test/dist/*
env:
TWINE_USERNAME: __token__
TWINE_PASSWORD: ${{ secrets.pypitest_token }}

- name: Upload to PyPI
if: ${{ steps.extract.outputs.name == 'release' }}
run: |
twine upload --repository testpypi python/fate_client/dist/*
twine upload --repository testpypi python/fate_test/dist/*
env:
TWINE_USERNAME: __token__
TWINE_PASSWORD: ${{ secrets.pypi_token }}

0 comments on commit 9a518b8

Please sign in to comment.