ci: fix publish version check — read _version.py without importing

This commit is contained in:
CloakHQ
2026-03-08 23:49:10 +01:00
parent e615349f1e
commit 858c0d0e85
2 changed files with 10 additions and 4 deletions
+5 -4
View File
@@ -34,7 +34,7 @@ jobs:
pytest tests/ -v -m "not slow"
- uses: actions/setup-node@v4
with:
node-version: 20
node-version: 22
- name: JavaScript tests
run: cd js && npm ci && npm run build && npm test
@@ -49,7 +49,7 @@ jobs:
- name: Check tag matches package versions
run: |
TAG="${GITHUB_REF_NAME#v}"
PY=$(python -c 'from cloakbrowser._version import __version__; print(__version__)')
PY=$(python -c 'import re; print(re.search(r"__version__\s*=\s*[\"'\'']([^\"'\'']+)", open("cloakbrowser/_version.py").read()).group(1))')
JS=$(python -c 'import json; print(json.load(open("js/package.json"))["version"])')
echo "Tag: $TAG | Python: $PY | npm: $JS"
[ "$TAG" = "$PY" ] || { echo "ERROR: tag v$TAG != _version.py $PY"; exit 1; }
@@ -83,7 +83,8 @@ jobs:
- uses: actions/checkout@v4
- uses: actions/setup-node@v4
with:
node-version: 20
node-version: 22
registry-url: 'https://registry.npmjs.org'
- name: Build
run: cd js && npm ci && npm run build
- name: Publish to npm
@@ -102,7 +103,7 @@ jobs:
- uses: actions/checkout@v4
- name: Extract version
run: |
VERSION=$(python -c 'from cloakbrowser._version import __version__; print(__version__)')
VERSION=$(python -c 'import re; print(re.search(r"__version__\s*=\s*[\"'\'']([^\"'\'']+)", open("cloakbrowser/_version.py").read()).group(1))')
echo "VERSION=$VERSION" >> $GITHUB_ENV
- uses: docker/setup-buildx-action@v3
- uses: docker/login-action@v3