From d2c8332629c24203c010c54f228ed7bb7e26f77d Mon Sep 17 00:00:00 2001 From: Lucas PASCAL Date: Tue, 9 Jan 2024 11:39:45 +0100 Subject: [PATCH] test --- .github/workflows/python-client.yml | 51 +++++++++++++++++++++++------ 1 file changed, 41 insertions(+), 10 deletions(-) diff --git a/.github/workflows/python-client.yml b/.github/workflows/python-client.yml index 3b16e18d..0ec9ce94 100644 --- a/.github/workflows/python-client.yml +++ b/.github/workflows/python-client.yml @@ -38,14 +38,45 @@ jobs: - name: Mypy type checking run: (cd client && mypy src/) - packaging: + package_and_deploy: + name: Build and deploy Ledgered Python package + runs-on: ubuntu-latest needs: [lint, mypy] - name: Build, test and deploy the Python package - uses: LedgerHQ/ledger-app-workflows/.github/workflows/reusable_pypi_deployment.yml@v1 - with: - package_directory: "client/" - stable_deployment: true - check_changelog_version: ${{ startsWith(github.ref,'refs/tags/') }} - publish: ${{ github.event_name == 'push' }} - secrets: - pypi_token: secrets.PYPI_PUBLIC_API_TOKEN + steps: + + - name: Clone + uses: actions/checkout@v3 + with: + fetch-depth: 0 + + # Fetching dependencies from test.pypi,org or pypi.org depending on the package destination: + # tag -> pypi.org, not tag -> test.pypi.org + - name: Build Python package + run: | + pip install --upgrade pip build twine + cd client/ + python -m build; \ + python -m twine check dist/* + pip install .; \ + echo "TAG_VERSION=$(python -c 'from ledger_app_clients.ethereum import __version__; print(__version__)')" >> "$GITHUB_ENV" + + - name: Check version against CHANGELOG + if: startsWith(github.ref, 'refs/tags/') + run: | + CHANGELOG_VERSION=$(grep -Po '(?<=## \[)(\d+\.)+[^\]]' client/CHANGELOG.md | head -n 1) + if [ "${{ env.TAG_VERSION }}" == "${CHANGELOG_VERSION}" ]; \ + then \ + echo 'Package and CHANGELOG versions match!'; \ + exit 0; \ + else \ + echo "Tag '${{ env.TAG_VERSION }}' and CHANGELOG '${CHANGELOG_VERSION}' versions mismatch!"; \ + exit 1; \ + fi + + - name: Publish Python package on pypi.org + if: success() && github.event_name == 'push' + run: (cd client && python -m twine upload --verbose dist/*) + env: + TWINE_USERNAME: __token__ + TWINE_PASSWORD: ${{ secrets.PYPI_PUBLIC_API_TOKEN }} + TWINE_NON_INTERACTIVE: 1