From 0a3c5836676b8b8c4592d36305a3856c87975f94 Mon Sep 17 00:00:00 2001 From: nichinichisou Date: Wed, 15 Jul 2026 01:18:55 +0800 Subject: [PATCH] ci: prepare PyPI release workflow --- .github/workflows/wheels.yml | 55 ++++++++------ Cargo.lock | 126 +-------------------------------- Cargo.toml | 2 +- tests/test_release_workflow.py | 42 +++++++++++ 4 files changed, 77 insertions(+), 148 deletions(-) create mode 100644 tests/test_release_workflow.py diff --git a/.github/workflows/wheels.yml b/.github/workflows/wheels.yml index 88436fb..8596ab4 100644 --- a/.github/workflows/wheels.yml +++ b/.github/workflows/wheels.yml @@ -10,15 +10,21 @@ on: permissions: contents: read +concurrency: + group: wheels-${{ github.ref }} + cancel-in-progress: false + jobs: test: runs-on: ubuntu-latest steps: - - uses: actions/checkout@v4 - - uses: actions/setup-python@v5 + - uses: actions/checkout@34e114876b0b11c390a56381ad16ebd13914f8d5 # v4 + - uses: actions/setup-python@a26af69be951a213d495a4c3e4e4022e16d87065 # v5 with: python-version: "3.10" - - uses: dtolnay/rust-toolchain@stable + - uses: dtolnay/rust-toolchain@4be7066ada62dd38de10e7b70166bc74ed198c30 # stable + with: + toolchain: 1.94.1 - run: python -m pip install pytest maturin ruff tomli - name: Verify release tag matches package version if: startsWith(github.ref, 'refs/tags/') @@ -34,18 +40,19 @@ jobs: matrix: target: [x86_64, aarch64] steps: - - uses: actions/checkout@v4 - - uses: PyO3/maturin-action@v1 + - uses: actions/checkout@34e114876b0b11c390a56381ad16ebd13914f8d5 # v4 + - uses: PyO3/maturin-action@e83996d129638aa358a18fbd1dfb82f0b0fb5d3b # v1 with: target: ${{ matrix.target }} manylinux: auto args: --release --out dist + rust-toolchain: 1.94.1 sccache: true - - uses: actions/upload-artifact@v4 + - uses: actions/upload-artifact@ea165f8d65b6e75b540449e92b4886f43607fa02 # v4 with: name: wheels-linux-${{ matrix.target }} path: dist/*.whl - - uses: actions/setup-python@v5 + - uses: actions/setup-python@a26af69be951a213d495a4c3e4e4022e16d87065 # v5 if: matrix.target == 'x86_64' with: python-version: "3.10" @@ -57,17 +64,18 @@ jobs: windows: runs-on: windows-latest steps: - - uses: actions/checkout@v4 - - uses: PyO3/maturin-action@v1 + - uses: actions/checkout@34e114876b0b11c390a56381ad16ebd13914f8d5 # v4 + - uses: PyO3/maturin-action@e83996d129638aa358a18fbd1dfb82f0b0fb5d3b # v1 with: target: x64 args: --release --out dist + rust-toolchain: 1.94.1 sccache: true - - uses: actions/upload-artifact@v4 + - uses: actions/upload-artifact@ea165f8d65b6e75b540449e92b4886f43607fa02 # v4 with: name: wheels-windows-x86_64 path: dist/*.whl - - uses: actions/setup-python@v5 + - uses: actions/setup-python@a26af69be951a213d495a4c3e4e4022e16d87065 # v5 with: python-version: "3.10" - shell: pwsh @@ -85,17 +93,18 @@ jobs: target: aarch64 runs-on: ${{ matrix.runner }} steps: - - uses: actions/checkout@v4 - - uses: PyO3/maturin-action@v1 + - uses: actions/checkout@34e114876b0b11c390a56381ad16ebd13914f8d5 # v4 + - uses: PyO3/maturin-action@e83996d129638aa358a18fbd1dfb82f0b0fb5d3b # v1 with: target: ${{ matrix.target }} args: --release --out dist + rust-toolchain: 1.94.1 sccache: true - - uses: actions/upload-artifact@v4 + - uses: actions/upload-artifact@ea165f8d65b6e75b540449e92b4886f43607fa02 # v4 with: name: wheels-macos-${{ matrix.target }} path: dist/*.whl - - uses: actions/setup-python@v5 + - uses: actions/setup-python@a26af69be951a213d495a4c3e4e4022e16d87065 # v5 with: python-version: "3.10" - run: python -m pip install dist/*.whl @@ -109,11 +118,11 @@ jobs: python: ["3.10", "3.14"] runs-on: ubuntu-latest steps: - - uses: actions/checkout@v4 - - uses: actions/setup-python@v5 + - uses: actions/checkout@34e114876b0b11c390a56381ad16ebd13914f8d5 # v4 + - uses: actions/setup-python@a26af69be951a213d495a4c3e4e4022e16d87065 # v5 with: python-version: ${{ matrix.python }} - - uses: actions/download-artifact@v4 + - uses: actions/download-artifact@d3f86a106a0bac45b974a628896c90dbdf5c8093 # v4 with: name: wheels-linux-x86_64 path: dist @@ -122,7 +131,7 @@ jobs: - run: python -c "import _allium_deck_native, allium_deck, sekai_deck_recommend_cpp" publish: - if: startsWith(github.ref, 'refs/tags/v') + if: github.event_name == 'push' && startsWith(github.ref, 'refs/tags/v') needs: [test, smoke] runs-on: ubuntu-latest environment: pypi @@ -130,12 +139,14 @@ jobs: id-token: write contents: write steps: - - uses: actions/download-artifact@v4 + - uses: actions/download-artifact@d3f86a106a0bac45b974a628896c90dbdf5c8093 # v4 with: pattern: wheels-* path: dist merge-multiple: true - - uses: pypa/gh-action-pypi-publish@release/v1 - - uses: softprops/action-gh-release@v2 + - uses: pypa/gh-action-pypi-publish@cef221092ed1bacb1cc03d23a2d87d1d172e277b # release/v1 + with: + skip-existing: true + - uses: softprops/action-gh-release@3bb12739c298aeb8a4eeaf626c5b8d85266b0e65 # v2 with: files: dist/*.whl diff --git a/Cargo.lock b/Cargo.lock index 3e30878..ff364a9 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -5,9 +5,8 @@ version = 4 [[package]] name = "allium-deck" version = "0.0.4" -source = "git+https://github.com/empty-sekai/allium-deck.git?rev=41495933b2afb86b49242b6cd769f32810db7308#41495933b2afb86b49242b6cd769f32810db7308" +source = "git+https://github.com/empty-sekai/allium-deck.git?rev=2cf7e77736c1d545f0858ec96711feae9e6fcbed#2cf7e77736c1d545f0858ec96711feae9e6fcbed" dependencies = [ - "postcard", "serde", "serde_json", "thiserror", @@ -22,83 +21,18 @@ dependencies = [ "serde_json", ] -[[package]] -name = "atomic-polyfill" -version = "1.0.3" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "8cf2bce30dfe09ef0bfaef228b9d414faaf7e563035494d7fe092dba54b300f4" -dependencies = [ - "critical-section", -] - [[package]] name = "autocfg" version = "1.5.1" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "f2032f911046de80f0a198e0901378627c33f59ea0ac00e363d481118bd70a53" -[[package]] -name = "byteorder" -version = "1.5.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "1fd0f2584146f6f2ef48085050886acf353beff7305ebd1ae69500e27c67f64b" - [[package]] name = "cfg-if" version = "1.0.4" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "9330f8b2ff13f34540b44e946ef35111825727b38d33286ef986142615121801" -[[package]] -name = "cobs" -version = "0.3.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "0fa961b519f0b462e3a3b4a34b64d119eeaca1d59af726fe450bbba07a9fc0a1" -dependencies = [ - "thiserror", -] - -[[package]] -name = "critical-section" -version = "1.2.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "790eea4361631c5e7d22598ecd5723ff611904e3344ce8720784c93e3d83d40b" - -[[package]] -name = "embedded-io" -version = "0.4.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "ef1a6892d9eef45c8fa6b9e0086428a2cca8491aca8f787c534a3d6d0bcb3ced" - -[[package]] -name = "embedded-io" -version = "0.6.1" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "edd0f118536f44f5ccd48bcb8b111bdc3de888b58c74639dfb034a357d0f206d" - -[[package]] -name = "hash32" -version = "0.2.1" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "b0c35f58762feb77d74ebe43bdbc3210f09be9fe6742234d573bacc26ed92b67" -dependencies = [ - "byteorder", -] - -[[package]] -name = "heapless" -version = "0.7.17" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "cdc6457c0eb62c71aac4bc17216026d8410337c4126773b9c5daba343f17964f" -dependencies = [ - "atomic-polyfill", - "hash32", - "rustc_version", - "serde", - "spin", - "stable_deref_trait", -] - [[package]] name = "heck" version = "0.5.0" @@ -126,15 +60,6 @@ version = "0.2.186" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "68ab91017fe16c622486840e4c83c9a37afeff978bd239b5293d61ece587de66" -[[package]] -name = "lock_api" -version = "0.4.14" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "224399e74b87b5f3557511d98dff8b14089b3dadafcab6bb93eab67d3aace965" -dependencies = [ - "scopeguard", -] - [[package]] name = "memchr" version = "2.8.3" @@ -162,19 +87,6 @@ version = "1.13.1" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "c33a9471896f1c69cecef8d20cbe2f7accd12527ce60845ff44c153bb2a21b49" -[[package]] -name = "postcard" -version = "1.1.3" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "6764c3b5dd454e283a30e6dfe78e9b31096d9e32036b5d1eaac7a6119ccb9a24" -dependencies = [ - "cobs", - "embedded-io 0.4.0", - "embedded-io 0.6.1", - "heapless", - "serde", -] - [[package]] name = "proc-macro2" version = "1.0.106" @@ -256,33 +168,12 @@ dependencies = [ "proc-macro2", ] -[[package]] -name = "rustc_version" -version = "0.4.1" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "cfcb3a22ef46e85b45de6ee7e79d063319ebb6594faafcf1c225ea92ab6e9b92" -dependencies = [ - "semver", -] - [[package]] name = "rustversion" version = "1.0.23" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "cf54715a573b99ac80df0bc206da022bcd442c974952c7b9720069370852e21f" -[[package]] -name = "scopeguard" -version = "1.2.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "94143f37725109f92c262ed2cf5e59bce7498c01bcc1502d7b9afe439a4e9f49" - -[[package]] -name = "semver" -version = "1.0.28" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "8a7852d02fc848982e0c167ef163aaff9cd91dc640ba85e263cb1ce46fae51cd" - [[package]] name = "serde" version = "1.0.228" @@ -326,21 +217,6 @@ dependencies = [ "zmij", ] -[[package]] -name = "spin" -version = "0.9.8" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "6980e8d7511241f8acf4aebddbb1ff938df5eebe98691418c4468d0b72a96a67" -dependencies = [ - "lock_api", -] - -[[package]] -name = "stable_deref_trait" -version = "1.2.1" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "6ce2be8dc25455e1f91df71bfa12ad37d7af1092ae736f3a6cd0e37bc7810596" - [[package]] name = "syn" version = "2.0.118" diff --git a/Cargo.toml b/Cargo.toml index 0e4916b..abf4d37 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -10,7 +10,7 @@ name = "_native" crate-type = ["cdylib"] [dependencies] -allium-deck = { git = "https://github.com/empty-sekai/allium-deck.git", rev = "41495933b2afb86b49242b6cd769f32810db7308" } +allium-deck = { git = "https://github.com/empty-sekai/allium-deck.git", rev = "2cf7e77736c1d545f0858ec96711feae9e6fcbed" } pyo3 = { version = "0.23", features = ["abi3-py310"] } serde_json = "1" diff --git a/tests/test_release_workflow.py b/tests/test_release_workflow.py new file mode 100644 index 0000000..9dbb04e --- /dev/null +++ b/tests/test_release_workflow.py @@ -0,0 +1,42 @@ +from __future__ import annotations + +import re +from pathlib import Path + + +ROOT = Path(__file__).resolve().parents[1] +WORKFLOW = ROOT / ".github" / "workflows" / "wheels.yml" + + +def workflow_text() -> str: + return WORKFLOW.read_text(encoding="utf-8") + + +def test_only_push_tags_can_publish() -> None: + workflow = workflow_text() + assert "if: github.event_name == 'push' && startsWith(github.ref, 'refs/tags/v')" in workflow + + +def test_all_actions_are_pinned_to_full_commit_sha() -> None: + uses = re.findall(r"^\s*- uses: (\S+)", workflow_text(), flags=re.MULTILINE) + assert uses + for action in uses: + assert re.search(r"@[0-9a-f]{40}$", action), action + + +def test_release_toolchain_and_pypi_retry_are_fixed() -> None: + workflow = workflow_text() + assert "toolchain: 1.94.1" in workflow + assert "skip-existing: true" in workflow + + +def test_python_abi_floor_remains_310() -> None: + pyproject = (ROOT / "pyproject.toml").read_text(encoding="utf-8") + cargo = (ROOT / "Cargo.toml").read_text(encoding="utf-8") + assert 'requires-python = ">=3.10,<4"' in pyproject + assert 'features = ["abi3-py310"]' in cargo + + +def test_native_binding_pins_the_reviewed_deck_004_release_commit() -> None: + cargo = (ROOT / "Cargo.toml").read_text(encoding="utf-8") + assert 'rev = "2cf7e77736c1d545f0858ec96711feae9e6fcbed"' in cargo