-
Notifications
You must be signed in to change notification settings - Fork 224
81 lines (73 loc) · 2.3 KB
/
python-client.yml
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
---
name: Python client checks, package build and deployment
on:
workflow_dispatch:
push:
tags:
- 'client-*'
branches:
- develop
- master
paths:
- client/**
- .github/workflows/python-client.yml
pull_request:
paths:
- client/**
- .github/workflows/python-client.yml
jobs:
lint:
name: Linting
runs-on: ubuntu-latest
steps:
- name: Clone
uses: actions/checkout@v3
- run: pip install flake8
- name: Flake8 lint Python code
run: (cd client && find src/ -type f -name '*.py' -exec flake8 --max-line-length=120 '{}' '+')
mypy:
name: Type checking
runs-on: ubuntu-latest
steps:
- name: Clone
uses: actions/checkout@v3
- run: pip install mypy
- name: Mypy type checking
run: (cd client && mypy src/)
package_and_deploy:
name: Build and deploy Ledgered Python package
runs-on: ubuntu-latest
needs: [lint, mypy]
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/*
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