@@ -4,6 +4,8 @@ name: Python client checks, package build and deployment
44on :
55 workflow_dispatch :
66 push :
7+ tags :
8+ - ' client-*'
79 branches :
810 - develop
911 - master
2224 steps :
2325 - name : Clone
2426 uses : actions/checkout@v3
25- - run : pip install flake8
27+ - run : pip install flake8 flake8-pyproject
2628 - name : Flake8 lint Python code
27- run : (cd client && find src/ -type f -name '*.py' -exec flake8 --max-line-length=120 '{}' '+' )
29+ run : (cd client && flake8 src/)
2830
2931 mypy :
3032 name : Type checking
@@ -36,58 +38,43 @@ jobs:
3638 - name : Mypy type checking
3739 run : (cd client && mypy src/)
3840
39- get-develop-version :
40- name : Get develop version
41+ package_and_deploy :
42+ name : Build and deploy Ethereum Client Python package
4143 runs-on : ubuntu-latest
42- if : ${{ github.event_name == 'pull_request' && github.base_ref == 'develop' }}
43- outputs :
44- develop_version : ${{ steps.get-version.outputs.develop_version }}
44+ needs : [lint, mypy]
4545 steps :
46- - name : Check Out Code
47- uses : actions/checkout@v3
48- with :
49- ref : develop
50- - name : Set up Python
51- uses : actions/setup-python@v4
52- with :
53- python-version : 3.12.0
54- - name : Get version
55- id : get-version
56- env :
57- PYTHONPATH : client/src/ledger_app_clients
58- run : |
59- echo "develop_version=$(python -c 'from ethereum import __version__; print(__version__)')" >> $GITHUB_OUTPUT
6046
61- version-check :
62- name : Check Version when opening a PR against develop
63- runs-on : ubuntu-latest
64- needs : get-develop-version
65- steps :
66- - name : Check Out Code
67- uses : actions/checkout@v3
68- - name : Set up Python
69- uses : actions/setup-python@v4
70- with :
71- python-version : 3.12.0
72- - name : Check Version Bump
73- env :
74- DEVELOP_VERSION : ${{needs.get-develop-version.outputs.develop_version}}
75- PYTHONPATH : client/src/ledger_app_clients
76- run : |
77- current_version=$(python -c "from ethereum import __version__; print(__version__)")
78- if [[ "$current_version" == "$DEVELOP_VERSION" ]]; then
79- echo "Version in __init__.py hasn't been bumped. Please bump the version before merging."
80- exit 1
81- fi
47+ - name : Clone
48+ uses : actions/checkout@v3
49+ with :
50+ fetch-depth : 0
8251
83- packaging :
84- needs : [lint, mypy]
85- name : Build, test and deploy the Python package
86- uses : LedgerHQ/ledger-app-workflows/.github/workflows/reusable_pypi_deployment.yml@v1
87- with :
88- package_directory : " client/"
89- stable_deployment : ${{ github.ref == 'refs/heads/master' }}
90- check_changelog_version : true
91- publish : ${{ github.event_name == 'push' }}
92- secrets :
93- pypi_token : ${{ github.ref == 'refs/heads/master' && secrets.PYPI_PUBLIC_API_TOKEN || secrets.TEST_PYPI_PUBLIC_API_TOKEN }}
52+ - name : Build Python package
53+ run : |
54+ pip install --upgrade pip build twine
55+ cd client/
56+ python -m build;
57+ python -m twine check dist/*
58+ pip install .;
59+ echo "TAG_VERSION=$(python -c 'from ledger_app_clients.ethereum import __version__; print(__version__)')" >> "$GITHUB_ENV"
60+
61+ - name : Check version against CHANGELOG
62+ if : startsWith(github.ref, 'refs/tags/')
63+ run : |
64+ CHANGELOG_VERSION=$(grep -Po '(?<=## \[)(\d+\.)+[^\]]' client/CHANGELOG.md | head -n 1)
65+ if [ "${{ env.TAG_VERSION }}" == "${CHANGELOG_VERSION}" ];
66+ then
67+ echo 'Package and CHANGELOG versions match!';
68+ exit 0;
69+ else
70+ echo "Tag '${{ env.TAG_VERSION }}' and CHANGELOG '${CHANGELOG_VERSION}' versions mismatch!";
71+ exit 1;
72+ fi
73+
74+ - name : Publish Python package on pypi.org
75+ if : success() && github.event_name == 'push'
76+ run : (cd client && python -m twine upload --verbose dist/*)
77+ env :
78+ TWINE_USERNAME : __token__
79+ TWINE_PASSWORD : ${{ secrets.PYPI_PUBLIC_API_TOKEN }}
80+ TWINE_NON_INTERACTIVE : 1
0 commit comments