forked from FederatedAI/FATE
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
👷 Add github action for PyPI release
1. use github action to release fate_client and fate_test to PyPI Signed-off-by: weiwee <[email protected]>
- Loading branch information
Showing
1 changed file
with
94 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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 }} |