chore(release): cut v0.7.1 (#582) #38
Workflow file for this run
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| name: release-moraine | |
| on: | |
| push: | |
| tags: | |
| - "v*" | |
| workflow_dispatch: | |
| inputs: | |
| tag: | |
| description: "Tag to release (for example v0.7.1)" | |
| required: true | |
| type: string | |
| target: | |
| description: "PyPI publish target for manual dispatches; tag-triggered runs publish to PyPI automatically." | |
| required: false | |
| type: choice | |
| default: skip | |
| options: | |
| - skip | |
| - test-pypi | |
| - pypi | |
| jobs: | |
| release: | |
| name: build-and-upload-${{ matrix.target }} | |
| runs-on: ${{ matrix.os }} | |
| permissions: | |
| contents: write | |
| strategy: | |
| fail-fast: false | |
| matrix: | |
| include: | |
| - os: ubuntu-latest | |
| target: x86_64-unknown-linux-gnu | |
| # pypa manylinux_2_28 image: AlmaLinux 8, glibc 2.28 floor. | |
| # Honours the wheel's `manylinux_2_28_x86_64` tag so the | |
| # resulting binary runs on RHEL 9 / Ubuntu 20.04+ / Debian 12+ | |
| # / AL2023 — see issue #246. | |
| cargo_container: quay.io/pypa/manylinux_2_28_x86_64 | |
| - os: ubuntu-24.04-arm | |
| target: aarch64-unknown-linux-gnu | |
| cargo_container: quay.io/pypa/manylinux_2_28_aarch64 | |
| - os: macos-14 | |
| target: aarch64-apple-darwin | |
| cargo_container: "" | |
| - os: macos-15-intel | |
| target: x86_64-apple-darwin | |
| cargo_container: "" | |
| steps: | |
| - name: Checkout | |
| uses: actions/checkout@v4 | |
| with: | |
| ref: ${{ github.event_name == 'workflow_dispatch' && github.event.inputs.tag || github.ref }} | |
| - name: Install Rust toolchain | |
| uses: dtolnay/rust-toolchain@stable | |
| with: | |
| targets: ${{ matrix.target }} | |
| - name: Install Bun | |
| uses: oven-sh/setup-bun@v2 | |
| with: | |
| bun-version: latest | |
| - name: Verify Bun | |
| run: bun --version | |
| - name: Build release archive | |
| env: | |
| # Linux legs wrap cargo in the pypa manylinux container so the | |
| # binaries link against glibc 2.28, not the ubuntu-24.04 runner's | |
| # glibc 2.39 (issue #246). macOS sets this empty; the script | |
| # falls back to a native host build. | |
| MORAINE_CARGO_CONTAINER: ${{ matrix.cargo_container }} | |
| run: scripts/package-moraine-release.sh "${{ matrix.target }}" dist | |
| - name: Upload assets to release | |
| uses: softprops/action-gh-release@v2 | |
| with: | |
| tag_name: ${{ github.event_name == 'workflow_dispatch' && github.event.inputs.tag || github.ref_name }} | |
| files: | | |
| dist/moraine-bundle-${{ matrix.target }}.tar.gz | |
| dist/moraine-bundle-${{ matrix.target }}.sha256 | |
| overwrite_files: true | |
| generate_release_notes: true | |
| env: | |
| GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} | |
| publish-pypi: | |
| name: publish-pypi | |
| needs: release | |
| # Tag-triggered runs publish to PyPI after release assets are uploaded. | |
| # Manual dispatches keep the explicit test-pypi / pypi switch for | |
| # rehearsals and re-runs. See RFC #219 and docs/operations/pypi-release.md. | |
| if: github.event_name == 'push' || (github.event_name == 'workflow_dispatch' && (github.event.inputs.target == 'test-pypi' || github.event.inputs.target == 'pypi')) | |
| runs-on: ubuntu-latest | |
| permissions: | |
| id-token: write # OIDC for PyPI/TestPyPI trusted publishing | |
| contents: read # for gh release download | |
| steps: | |
| - name: Checkout | |
| uses: actions/checkout@v4 | |
| with: | |
| ref: ${{ github.event_name == 'workflow_dispatch' && github.event.inputs.tag || github.ref_name }} | |
| - name: Setup Python | |
| uses: actions/setup-python@v5 | |
| with: | |
| python-version: '3.12' | |
| - name: Resolve tag and PEP 440 version | |
| id: meta | |
| env: | |
| TAG: ${{ github.event_name == 'workflow_dispatch' && github.event.inputs.tag || github.ref_name }} | |
| # The wheel builder's --version must be PEP 440 compliant so | |
| # twine / pypi accept the upload. Git tags use dash-separated | |
| # pre-release segments (v0.3.1-rc.1); translate them to the | |
| # canonical form here rather than in every call site. | |
| run: | | |
| python3 - <<'PY' >>"$GITHUB_OUTPUT" | |
| import os, re | |
| tag = os.environ["TAG"] | |
| version = tag[1:] if re.match(r"^v\d", tag) else tag | |
| # e.g. 0.3.1-rc.1 -> 0.3.1rc1, 0.4.0-beta.2 -> 0.4.0b2 | |
| for pre, canon in (("rc", "rc"), ("beta", "b"), ("alpha", "a")): | |
| version = re.sub(rf"-{pre}\.?(\d+)", rf"{canon}\1", version) | |
| # .dev / .post kept as-is; stdlib re is fine for these cases. | |
| print(f"tag={tag}") | |
| print(f"version={version}") | |
| PY | |
| - name: Download bundle artifacts from GH Release | |
| env: | |
| GH_TOKEN: ${{ secrets.GITHUB_TOKEN }} | |
| run: | | |
| mkdir -p dist | |
| gh release download "${{ steps.meta.outputs.tag }}" \ | |
| --repo "$GITHUB_REPOSITORY" \ | |
| --pattern 'moraine-bundle-*.tar.gz' \ | |
| --dir dist/ | |
| - name: Build wheels + stub sdist | |
| env: | |
| VERSION: ${{ steps.meta.outputs.version }} | |
| run: | | |
| mkdir -p dist/wheels | |
| for target in x86_64-unknown-linux-gnu aarch64-unknown-linux-gnu aarch64-apple-darwin x86_64-apple-darwin; do | |
| python3 scripts/build-python-wheels.py \ | |
| --target "$target" \ | |
| --bundle "dist/moraine-bundle-$target.tar.gz" \ | |
| --out-dir dist/wheels \ | |
| --version "$VERSION" | |
| done | |
| python3 scripts/build-python-sdist.py \ | |
| --out-dir dist/wheels \ | |
| --version "$VERSION" | |
| ls -la dist/wheels | |
| - name: Publish to TestPyPI | |
| if: github.event.inputs.target == 'test-pypi' | |
| uses: pypa/gh-action-pypi-publish@release/v1 | |
| with: | |
| packages-dir: dist/wheels/ | |
| repository-url: https://test.pypi.org/legacy/ | |
| # skip-existing avoids a hard failure on rehearsal tag rebuilds | |
| # where the same version has already been pushed. | |
| skip-existing: true | |
| verbose: true | |
| - name: Publish to PyPI | |
| if: github.event_name == 'push' || github.event.inputs.target == 'pypi' | |
| uses: pypa/gh-action-pypi-publish@release/v1 | |
| with: | |
| packages-dir: dist/wheels/ | |
| skip-existing: false | |
| verbose: true | |
| - name: Upload built wheels as workflow artifact | |
| uses: actions/upload-artifact@v4 | |
| with: | |
| name: moraine-pypi-artifacts-${{ steps.meta.outputs.version }} | |
| path: dist/wheels/* | |
| retention-days: 30 |