|
| 1 | +name: Publish to TestPyPI |
| 2 | + |
| 3 | +on: |
| 4 | + workflow_dispatch: |
| 5 | + inputs: |
| 6 | + ref: |
| 7 | + description: "Git ref to build (tag like v0.3.4-rc1, branch, or SHA). Default: current ref." |
| 8 | + required: false |
| 9 | + default: "" |
| 10 | + |
| 11 | +permissions: |
| 12 | + contents: read |
| 13 | + id-token: write |
| 14 | + |
| 15 | +jobs: |
| 16 | + pr: |
| 17 | + uses: ./.github/workflows/pr.yml |
| 18 | + |
| 19 | + build-wheels: |
| 20 | + runs-on: ${{ matrix.os }} |
| 21 | + needs: |
| 22 | + - test |
| 23 | + - docs |
| 24 | + strategy: |
| 25 | + fail-fast: false |
| 26 | + matrix: |
| 27 | + os: [ubuntu-latest, macos-latest, windows-latest] |
| 28 | + python-version: ["3.11"] |
| 29 | + steps: |
| 30 | + - name: Checkout |
| 31 | + uses: actions/checkout@v4 |
| 32 | + with: |
| 33 | + fetch-depth: 0 |
| 34 | + |
| 35 | + - name: Set up Python ${{ matrix.python-version }} |
| 36 | + uses: actions/setup-python@v5 |
| 37 | + with: |
| 38 | + python-version: ${{ matrix.python-version }} |
| 39 | + |
| 40 | + - name: Install Rust |
| 41 | + uses: dtolnay/rust-toolchain@stable |
| 42 | + |
| 43 | + - name: Install uv |
| 44 | + uses: astral-sh/setup-uv@v3 |
| 45 | + |
| 46 | + - name: Build wheels (Rust-enabled) |
| 47 | + uses: PyO3/maturin-action@v1 |
| 48 | + with: |
| 49 | + command: build |
| 50 | + args: --release --out dist |
| 51 | + working-directory: rust-base32 |
| 52 | + manylinux: auto |
| 53 | + |
| 54 | + - name: Upload wheels |
| 55 | + uses: actions/upload-artifact@v4 |
| 56 | + with: |
| 57 | + name: wheels-${{ matrix.os }} |
| 58 | + path: rust-base32/dist/*.whl |
| 59 | + |
| 60 | + build-sdist: |
| 61 | + runs-on: ubuntu-latest |
| 62 | + needs: |
| 63 | + - test |
| 64 | + - docs |
| 65 | + steps: |
| 66 | + - name: Checkout |
| 67 | + uses: actions/checkout@v4 |
| 68 | + with: |
| 69 | + fetch-depth: 0 |
| 70 | + |
| 71 | + - name: Set up Python |
| 72 | + uses: actions/setup-python@v5 |
| 73 | + with: |
| 74 | + python-version: "3.11" |
| 75 | + |
| 76 | + - name: Install uv |
| 77 | + uses: astral-sh/setup-uv@v3 |
| 78 | + |
| 79 | + - name: Sync deps (including build tools) |
| 80 | + run: | |
| 81 | + uv sync --all-extras --dev |
| 82 | +
|
| 83 | + - name: Build sdist |
| 84 | + run: | |
| 85 | + make build-sdist |
| 86 | +
|
| 87 | + - name: Upload sdist |
| 88 | + uses: actions/upload-artifact@v4 |
| 89 | + with: |
| 90 | + name: sdist |
| 91 | + path: dist/*.tar.gz |
| 92 | + |
| 93 | + publish: |
| 94 | + runs-on: ubuntu-latest |
| 95 | + needs: |
| 96 | + - build-wheels |
| 97 | + - build-sdist |
| 98 | + permissions: |
| 99 | + contents: read |
| 100 | + id-token: write |
| 101 | + steps: |
| 102 | + - name: Download all artifacts |
| 103 | + uses: actions/download-artifact@v4 |
| 104 | + with: |
| 105 | + path: dist |
| 106 | + |
| 107 | + - name: Flatten dist directory |
| 108 | + shell: bash |
| 109 | + run: | |
| 110 | + mkdir -p out |
| 111 | + find dist -type f \( -name "*.whl" -o -name "*.tar.gz" \) -maxdepth 4 -print -exec cp {} out/ \; |
| 112 | + ls -la out |
| 113 | +
|
| 114 | + - name: Publish to TestPyPI |
| 115 | + uses: pypa/gh-action-pypi-publish@release/v1 |
| 116 | + with: |
| 117 | + repository-url: https://test.pypi.org/legacy/ |
| 118 | + packages-dir: out |
0 commit comments