diff --git a/.github/actions/sync-version-from-dispatch/action.yml b/.github/actions/sync-version-from-dispatch/action.yml new file mode 100644 index 0000000..4f09014 --- /dev/null +++ b/.github/actions/sync-version-from-dispatch/action.yml @@ -0,0 +1,60 @@ +name: Sync version from dispatch payload +description: >- + Rewrite the package version in pyproject.toml and agent_assembly/__init__.py + to match the upstream agent-assembly release tag carried in the + repository_dispatch client_payload, BEFORE maturin reads pyproject.toml. + + Without this, maturin would build whatever version is currently checked in + on master (which lags the upstream bumper), so the wheel filename would + collide with an already-published PyPI version. See AAASM-2459 for the + alpha-4 incident that motivated this action. + + When `release_tag` is empty (workflow_dispatch dry-run mode), the step is a + no-op and the files keep whatever version is on master — useful for local + CI smoke tests. + +inputs: + release_tag: + description: >- + Upstream agent-assembly release tag from + `github.event.client_payload.release_tag` (e.g. `v0.0.1-alpha.4`). + Empty string is allowed and treated as a no-op (dry-run). + required: true + +runs: + using: composite + steps: + - name: Sync pyproject.toml + __init__.py version + shell: bash + env: + AASM_TAG: ${{ inputs.release_tag }} + run: | + set -euo pipefail + if [ -z "${AASM_TAG}" ]; then + echo "AASM_TAG is empty (workflow_dispatch dry-run) — leaving version files untouched." + exit 0 + fi + # PEP-440 conversion from git tag form: + # v0.0.1-alpha.4 -> 0.0.1a4 + # v0.0.1-beta.2 -> 0.0.1b2 (not used today; future-proofing) + # v0.0.1-rc.1 -> 0.0.1rc1 (not used today; future-proofing) + # v1.2.3 -> 1.2.3 + pep440="${AASM_TAG#v}" + pep440="${pep440//-alpha./a}" + pep440="${pep440//-beta./b}" + pep440="${pep440//-rc./rc}" + echo "Mapped upstream tag '${AASM_TAG}' to PEP-440 version '${pep440}'" + + # pyproject.toml: line 7 currently `version = "0.0.2"`. sed in place. + sed -i.bak "s|^version = \"[^\"]*\"|version = \"${pep440}\"|" pyproject.toml + rm -f pyproject.toml.bak + + # __version__ lives in agent_assembly/__init__.py (verified for AAASM-2459). + sed -i.bak "s|^__version__ = \"[^\"]*\"|__version__ = \"${pep440}\"|" agent_assembly/__init__.py + rm -f agent_assembly/__init__.py.bak + + echo "--- pyproject.toml version line ---" + grep -n '^version = ' pyproject.toml + echo "--- agent_assembly/__init__.py __version__ line ---" + grep -n '^__version__ = ' agent_assembly/__init__.py + echo "Version sync complete: building wheel as agent-assembly==${pep440}" diff --git a/.github/workflows/release-python.yml b/.github/workflows/release-python.yml index d0765e7..ae6c284 100644 --- a/.github/workflows/release-python.yml +++ b/.github/workflows/release-python.yml @@ -44,6 +44,10 @@ jobs: - uses: actions/setup-python@v6 with: python-version: ${{ env.PYTHON_VERSION }} + - name: Sync version from dispatch payload + uses: ./.github/actions/sync-version-from-dispatch + with: + release_tag: ${{ github.event.client_payload.release_tag }} - name: Build source distribution uses: PyO3/maturin-action@v1 with: @@ -86,6 +90,10 @@ jobs: rm -f agent_assembly/bin/aasm-x86_64-unknown-linux-gnu.tar.gz chmod +x agent_assembly/bin/aasm echo "Bundled aasm binary into wheel" + - name: Sync version from dispatch payload + uses: ./.github/actions/sync-version-from-dispatch + with: + release_tag: ${{ github.event.client_payload.release_tag }} - name: Build wheel uses: PyO3/maturin-action@v1 with: @@ -154,6 +162,10 @@ jobs: rm -f agent_assembly/bin/aasm-aarch64-unknown-linux-gnu.tar.gz chmod +x agent_assembly/bin/aasm echo "Bundled aasm binary into wheel" + - name: Sync version from dispatch payload + uses: ./.github/actions/sync-version-from-dispatch + with: + release_tag: ${{ github.event.client_payload.release_tag }} - name: Build wheel uses: PyO3/maturin-action@v1 with: @@ -216,6 +228,10 @@ jobs: echo "Bundled aasm binary into wheel" - name: Install protoc (macOS) run: brew install protobuf + - name: Sync version from dispatch payload + uses: ./.github/actions/sync-version-from-dispatch + with: + release_tag: ${{ github.event.client_payload.release_tag }} - name: Build wheel uses: PyO3/maturin-action@v1 with: @@ -259,6 +275,10 @@ jobs: echo "Bundled aasm binary into wheel" - name: Install protoc (macOS) run: brew install protobuf + - name: Sync version from dispatch payload + uses: ./.github/actions/sync-version-from-dispatch + with: + release_tag: ${{ github.event.client_payload.release_tag }} - name: Build wheel uses: PyO3/maturin-action@v1 with: