diff --git a/.github/workflows/CI_PublishTestPyPI.yml b/.github/workflows/CI_PublishTestPyPI.yml new file mode 100644 index 00000000..106d7168 --- /dev/null +++ b/.github/workflows/CI_PublishTestPyPI.yml @@ -0,0 +1,84 @@ +name: CI Python Build & Publish to TestPyPI (Trusted) + +on: + push: + tags: ["v*"] + pull_request: + branches: [main] + workflow_dispatch: + +jobs: + build-wheels: + runs-on: ${{ matrix.os }} + strategy: + matrix: + include: + # Linux builds + - os: ubuntu-latest + cibw_archs: "auto" + deployment_target: "" + openblas_path: "" + py_tag: "cp310" + # macOS Intel builds + - os: macos-13 # Intel Mac + cibw_archs: "x86_64" + deployment_target: "13.0" + openblas_path: "/usr/local/opt/openblas" + py_tag: "cp310" + # macOS Apple Silicon builds + - os: macos-latest # Apple Silicon Mac + cibw_archs: "arm64" + deployment_target: "15.0" + openblas_path: "/opt/homebrew/opt/openblas" + py_tag: "cp310" + steps: + - uses: actions/checkout@v4 + - name: remove python/.gitignore + shell: bash + run: | + rm -f python/.gitignore + - uses: pypa/cibuildwheel@v3.1.4 + env: + CIBW_DEPENDENCY_VERSIONS: "latest" + CIBW_BUILD_VERBOSITY: 1 + CIBW_MANYLINUX_X86_64_IMAGE: "manylinux_2_28" + CIBW_BUILD: "${{ matrix.py_tag }}-*" + CIBW_ENVIRONMENT_MACOS: "MACOSX_DEPLOYMENT_TARGET=${{ matrix.deployment_target || '11.0' }} SPARSEIR_USE_BLAS=1" + CIBW_ARCHS: ${{ matrix.cibw_archs }} + CIBW_SKIP: "*-manylinux_i686 *-musllinux_i686" + # Install OpenBLAS using micromamba (conda-forge) - separate for manylinux and musllinux + CIBW_BEFORE_ALL_MANYLINUX: "curl -Ls https://micro.mamba.pm/api/micromamba/linux-64/latest | tar -xvj bin/micromamba && ./bin/micromamba create -y -p /opt/openblas && ./bin/micromamba install -y -c conda-forge openblas -p /opt/openblas --no-deps" + CIBW_BEFORE_ALL_MUSLLINUX: "apk add --no-cache bzip2 && curl -Ls https://micro.mamba.pm/api/micromamba/linux-64/latest | tar -xvj bin/micromamba && ./bin/micromamba create -y -p /opt/openblas && ./bin/micromamba install -y -c conda-forge openblas -p /opt/openblas --no-deps" + CIBW_BEFORE_ALL_MACOS: "brew install openblas" + # Set environment variables to help CMake find OpenBLAS + CIBW_ENVIRONMENT_MANYLINUX: "SPARSEIR_USE_BLAS=1" + CIBW_ENVIRONMENT_MUSLLINUX: "SPARSEIR_USE_BLAS=1" + with: + package-dir: ./python + output-dir: dist + - uses: actions/upload-artifact@v4 + with: + name: wheels-${{ matrix.os }}-${{ matrix.cibw_archs }}-${{ matrix.py_tag }} + path: dist/* + + publish-testpypi: + needs: build-wheels + runs-on: ubuntu-latest + environment: + name: testpypi + permissions: + id-token: write # ← Trusted Publishing に必須 + contents: read + steps: + - uses: actions/download-artifact@v4 + with: + path: dist + merge-multiple: true + - name: Publish to TestPyPI (Trusted) + uses: pypa/gh-action-pypi-publish@release/v1 + with: + packages-dir: dist + repository-url: https://test.pypi.org/legacy/ + verbose: true + skip-existing: true + attestations: false # Disable attestations due to Sigstore service issues \ No newline at end of file diff --git a/.github/workflows/PublishPyPI.yml b/.github/workflows/PublishPyPI.yml index ce6ac2b7..bec17abd 100644 --- a/.github/workflows/PublishPyPI.yml +++ b/.github/workflows/PublishPyPI.yml @@ -3,8 +3,6 @@ name: Python Build & Publish (Trusted) on: push: tags: ["v*"] # 例: v0.1.0 を push で発火 - #pull_request: # for debugging - # branches: [main] # for debugging workflow_dispatch: jobs: @@ -106,11 +104,11 @@ jobs: name: wheels-${{ matrix.os }}-${{ matrix.cibw_archs }}-${{ matrix.py_tag }} path: dist/* - publish-testpypi: + publish-pypi: needs: build-wheels runs-on: ubuntu-latest environment: - name: testpypi + name: pypi permissions: id-token: write # ← Trusted Publishing に必須 contents: read @@ -119,11 +117,11 @@ jobs: with: path: dist merge-multiple: true - - name: Publish to TestPyPI (Trusted) + - name: Publish to PyPI (Trusted) uses: pypa/gh-action-pypi-publish@release/v1 with: packages-dir: dist - repository-url: https://test.pypi.org/legacy/ + repository-url: https://pypi.org/legacy/ verbose: true skip-existing: true attestations: false # Disable attestations due to Sigstore service issues \ No newline at end of file diff --git a/python/pyproject.toml b/python/pyproject.toml index e405df2a..f024c94b 100644 --- a/python/pyproject.toml +++ b/python/pyproject.toml @@ -1,6 +1,6 @@ [project] name = "pylibsparseir" -version = "0.1.2" +version = "0.1.0" description = "Python bindings for the libsparseir library, providing efficient sparse intermediate representation for many-body physics calculations" readme = "README.md" requires-python = ">=3.10"