Skip to content

fix(release-python): __version__ をファイル直接 grep で読む(v0.1.0 publish 失敗の修復)#30

Open
aromarious wants to merge 1 commit into
mainfrom
fix/release-python-version-check
Open

fix(release-python): __version__ をファイル直接 grep で読む(v0.1.0 publish 失敗の修復)#30
aromarious wants to merge 1 commit into
mainfrom
fix/release-python-version-check

Conversation

@aromarious

Copy link
Copy Markdown
Owner

概要

Step 13c の初回 PyPI publish (python-v0.1.0 tag push) が "Verify tag matches package version" ステップで失敗した件の修正。

失敗ログ

Run set -euo pipefail
...
Traceback (most recent call last):
  File \"<string>\", line 1, in <module>
    from cao_holidays import __version__; print(__version__)
ModuleNotFoundError: No module named 'cao_holidays'
##[error]Process completed with exit code 1.

原因

`uv run --no-sync python -c "from cao_holidays import version"` で実行していたが、`--no-sync` は依存 install をスキップするため `cao_holidays` モジュールがインストールされておらず import 不能。

修正

`version` の値は `src/cao_holidays/init.py` がそのまま真の場所(`pyproject.toml` の `[tool.hatch.version] path = "src/cao_holidays/init.py"`)。Python import を経由せずファイル直接 grepで値を取り出す:

```bash
pkg_version=$(grep -E '^version' src/cao_holidays/init.py | sed -E 's/."([^\"]+)"./\1/')
```

これで:

  • `uv sync` 不要(高速、~20s 短縮)
  • 依存 install の状態に左右されない
  • 同一ファイルを使うので integrity も維持

影響範囲

  • 公開済みの PyPI / GitHub Release: 影響なし。failure は verify 時点だったので publish も Release 作成もまだ走っていない(失敗ログでも step 4 以降に進んでいない)
  • npm の cao-holidays: 一切無関係
  • JS テスト: 一切無関係

merge 後

  1. main に取り込まれた状態で python-v0.1.0 tag を delete + 新しい main HEAD で retag
  2. retag を push → release-python.yml が再起動 → verify step が grep ベースで通る → uv build → PyPI Trusted Publishing で publish → GitHub Release 自動作成
  3. `pip install cao-holidays==0.1.0` で fresh install 確認

テスト計画

  • ローカル: `grep -E '^version' packages/python/src/cao_holidays/init.py | sed -E 's/."([^\"]+)"./\1/'` → `0.1.0` 正しく抽出を確認
  • CI 緑 (`Build & test (Python 3.11/3.12/3.13)` + `Build & test (Node 22/24)` skip + CodeQL)
  • merge 後、retag → release-python.yml が verify step 通過 → publish 成功

関連

🤖 Generated with Claude Code

…rks pre-sync

The Step 13c first publish attempt for python-v0.1.0 failed at the
"Verify tag matches package version" step. The step ran
`uv run --no-sync python -c "from cao_holidays import __version__"`,
but `--no-sync` skips installing the package, so cao_holidays was
never importable and the step exited 1 with ModuleNotFoundError.

Replace the import-based version read with a direct grep over
src/cao_holidays/__init__.py — the same file pyproject.toml's
[tool.hatch.version] uses as the source of truth. This makes the
verify step work without any sync (faster) and removes the implicit
dep on uv install order.

The publish itself never ran (failed at verify); PyPI and GitHub
Releases are still in the pre-publish state. After this fix lands
on main, the python-v0.1.0 tag will be retagged at the new HEAD and
pushed again to retry the release.

Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant