|
| 1 | +# SPDX-FileCopyrightText: 2026 geisserml <geisserml@gmail.com> |
| 2 | +# SPDX-License-Identifier: BSD-3-Clause |
| 3 | + |
| 4 | +name: Build |
| 5 | +on: |
| 6 | + workflow_dispatch: |
| 7 | + inputs: |
| 8 | + cibw_py_ver: |
| 9 | + type: string |
| 10 | + default: 'cp314' |
| 11 | + publish: |
| 12 | + type: boolean |
| 13 | + default: false |
| 14 | + prerelease: |
| 15 | + type: boolean |
| 16 | + default: false |
| 17 | + |
| 18 | +jobs: |
| 19 | + |
| 20 | + build: |
| 21 | + strategy: |
| 22 | + fail-fast: false |
| 23 | + matrix: |
| 24 | + cibw_os: ["manylinux", "musllinux"] |
| 25 | + cibw_arch: ["x86_64", "i686", "aarch64", "armv7l", "ppc64le", "s390x", "riscv64", "loongarch64"] |
| 26 | + |
| 27 | + uses: ./.github/workflows/cibw_one.yaml |
| 28 | + with: |
| 29 | + os: ${{ (matrix.cibw_arch == 'aarch64' || matrix.cibw_arch == 'armv7l') && 'ubuntu-24.04-arm' || 'ubuntu-latest' }} |
| 30 | + cibw_os: ${{ matrix.cibw_os }} |
| 31 | + cibw_arch: ${{ matrix.cibw_arch }} |
| 32 | + cibw_py_ver: ${{ inputs.cibw_py_ver }} |
| 33 | + |
| 34 | + |
| 35 | + sdist: |
| 36 | + runs-on: ubuntu-latest |
| 37 | + steps: |
| 38 | + |
| 39 | + - name: Check out the repo |
| 40 | + uses: actions/checkout@v6 |
| 41 | + with: |
| 42 | + persist-credentials: false |
| 43 | + fetch-depth: 0 |
| 44 | + |
| 45 | + - name: Set up Python |
| 46 | + uses: actions/setup-python@v6 |
| 47 | + with: |
| 48 | + python-version: '3.14' |
| 49 | + pip-install: build setuptools |
| 50 | + |
| 51 | + - name: Package sdist |
| 52 | + run: python3 -m build -sxn |
| 53 | + |
| 54 | + - name: Upload sdist |
| 55 | + uses: actions/upload-artifact@v7 |
| 56 | + with: |
| 57 | + path: ./dist/*.tar.gz |
| 58 | + name: sdist |
| 59 | + |
| 60 | + |
| 61 | + publish: |
| 62 | + needs: [build, sdist] |
| 63 | + if: ${{ inputs.publish && !cancelled() && !contains(needs.*.result, 'failure') }} |
| 64 | + runs-on: ubuntu-latest |
| 65 | + |
| 66 | + environment: release # PyPI upload via "trusted publishing" |
| 67 | + permissions: |
| 68 | + id-token: write # PyPI upload via "trusted publishing", and GH attestation |
| 69 | + attestations: write # GH attestation |
| 70 | + |
| 71 | + steps: |
| 72 | + |
| 73 | + - name: Download sdist |
| 74 | + uses: actions/download-artifact@v8 |
| 75 | + with: |
| 76 | + path: dist/ |
| 77 | + name: sdist |
| 78 | + |
| 79 | + - name: Determine version from sdist |
| 80 | + id: get_version |
| 81 | + run: # q&d |
| 82 | + VERSION=$(ls dist/*.tar.gz) |
| 83 | + VERSION=${VERSION##*-} |
| 84 | + VERSION=${VERSION%%.*} |
| 85 | + echo "version=$VERSION" >> "$GITHUB_OUTPUT" |
| 86 | + |
| 87 | + - name: Download wheels |
| 88 | + uses: actions/download-artifact@v8 |
| 89 | + with: |
| 90 | + path: dist/ |
| 91 | + merge-multiple: true |
| 92 | + pattern: cibw-* |
| 93 | + |
| 94 | + - name: Isolate non-PyPI builds |
| 95 | + run: | |
| 96 | + mkdir gh_only |
| 97 | + mv dist/*linux_*_loongarch64*.whl gh_only/ |
| 98 | + |
| 99 | + - name: Publish to TestPyPI |
| 100 | + uses: pypa/gh-action-pypi-publish@release/v1 |
| 101 | + with: |
| 102 | + repository-url: https://test.pypi.org/legacy/ |
| 103 | + packages-dir: dist/ |
| 104 | + attestations: false |
| 105 | + verbose: true |
| 106 | + |
| 107 | + - name: Attest build provenance |
| 108 | + id: provenance |
| 109 | + uses: actions/attest-build-provenance@v4 |
| 110 | + with: |
| 111 | + subject-path: 'dist/*, gh_only/*' |
| 112 | + |
| 113 | + - name: Rename provenance file |
| 114 | + run: mv "$SRC_PATH" gn-attestation.json |
| 115 | + env: |
| 116 | + SRC_PATH: ${{ steps.provenance.outputs.bundle-path }} |
| 117 | + |
| 118 | + - name: Publish to GitHub |
| 119 | + uses: ncipollo/release-action@v1 |
| 120 | + with: |
| 121 | + immutableCreate: true |
| 122 | + artifacts: 'dist/*.whl,gh_only/*.whl,dist/*.tar.gz,gn-attestation.json' |
| 123 | + token: ${{ secrets.GITHUB_TOKEN }} |
| 124 | + tag: ${{ steps.get_version.outputs.version }} |
| 125 | + prerelease: ${{ inputs.prerelease }} |
| 126 | + |
| 127 | + - name: Publish to PyPI |
| 128 | + uses: pypa/gh-action-pypi-publish@release/v1 |
| 129 | + with: |
| 130 | + packages-dir: dist/ |
0 commit comments