Skip to content

Commit 99ba4a9

Browse files
committed
[ci][client] Eth Python client automatically infer its version from tags
1 parent b5e0c87 commit 99ba4a9

File tree

4 files changed

+14
-49
lines changed

4 files changed

+14
-49
lines changed

.github/workflows/python-client.yml

Lines changed: 3 additions & 45 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,8 @@ name: Python client checks, package build and deployment
44
on:
55
workflow_dispatch:
66
push:
7+
tags:
8+
- 'client-*'
79
branches:
810
- develop
911
- master
@@ -36,58 +38,14 @@ jobs:
3638
- name: Mypy type checking
3739
run: (cd client && mypy src/)
3840

39-
get-develop-version:
40-
name: Get develop version
41-
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 }}
45-
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
60-
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
82-
8341
packaging:
8442
needs: [lint, mypy]
8543
name: Build, test and deploy the Python package
8644
uses: LedgerHQ/ledger-app-workflows/.github/workflows/reusable_pypi_deployment.yml@v1
8745
with:
8846
package_directory: "client/"
8947
stable_deployment: true
90-
check_changelog_version: true
48+
check_changelog_version: ${{ startsWith(github.ref,'refs/tags/') }}
9149
publish: ${{ github.event_name == 'push' }}
9250
secrets:
9351
pypi_token: secrets.PYPI_PUBLIC_API_TOKEN

.gitignore

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@ build/
99

1010
# Python
1111
*.pyc
12-
12+
__version__.py
1313

1414
# JS
1515
tests/node_modules

client/pyproject.toml

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -34,8 +34,12 @@ dependencies = [
3434
[tools.setuptools]
3535
include-package-data = true
3636

37-
[tool.setuptools.dynamic]
38-
version = {attr = "ledger_app_clients.ethereum.__version__"}
37+
[tool.setuptools_scm]
38+
version_file = "src/ledger_app_clients/ethereum/__version__.py"
39+
local_scheme = "no-local-version"
40+
root = "../"
41+
git_describe_command = "git describe --dirty --tags --long --match client-*[0-9]*"
42+
fallback_version = "0.0.0"
3943

4044
[project.urls]
4145
Home = "https://github.com/LedgerHQ/app-ethereum"
Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1 +1,4 @@
1-
__version__ = "0.2.0"
1+
try:
2+
from ledger_app_clients.ethereum.__version__ import __version__ # noqa
3+
except ImportError:
4+
__version__ = "unknown version" # noqa

0 commit comments

Comments
 (0)