diff --git a/.github/workflows/release.yml b/.github/workflows/release.yml new file mode 100644 index 00000000..d3857ea1 --- /dev/null +++ b/.github/workflows/release.yml @@ -0,0 +1,85 @@ +name: Publish Python Package + +on: + workflow_dispatch: + release: + types: + - published + +jobs: + build_sdist: + name: Build SDist + runs-on: ubuntu-latest + steps: + - uses: actions/checkout@v4 + with: + submodules: true + + - name: Build SDist + run: pipx run build --sdist + + - name: Check metadata + run: pipx run twine check dist/* + + - uses: actions/upload-artifact@v4 + with: + name: cibw-sdist + path: dist/*.tar.gz + + build_wheels: + name: Build wheels on ${{ matrix.os }} with Python ${{ matrix.python-version }} + runs-on: ${{ matrix.os }} + strategy: + fail-fast: false + matrix: + os: [ubuntu-latest, windows-latest, macos-latest] + python-version: ["3.12"] + + steps: + - uses: actions/checkout@v4 + with: + submodules: true + + - uses: actions/setup-python@v5 + with: + python-version: ${{ matrix.python-version }} + + - uses: pypa/cibuildwheel@v2.17 + env: + CIBW_ARCHS_MACOS: arm64 x86_64 + CIBW_SKIP: cp27-* cp34-* cp35-* cp36-* *musllinux* + CIBW_BUILD: cp37-* cp38-* cp39-* cp310-* cp311-* cp312-* + + - name: Verify clean directory + run: git diff --exit-code + shell: bash + + - name: Upload wheels + uses: actions/upload-artifact@v4 + with: + name: cibw-wheels-${{ matrix.os }}-py${{ matrix.python-version }} + path: wheelhouse/*.whl + + upload_all: + name: Upload release + needs: [build_wheels, build_sdist] + runs-on: ubuntu-latest + environment: + name: pypi + url: https://pypi.org/p/musica + permissions: + id-token: write + + steps: + - uses: actions/setup-python@v5 + with: + python-version: "3.x" + + - uses: actions/download-artifact@v4 + with: + pattern: cibw-* + path: dist + merge-multiple: true + + - name: Publish package distributions to PyPI + uses: pypa/gh-action-pypi-publish@release/v1 diff --git a/pyproject.toml b/pyproject.toml index d1fe56ba..0feccafd 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -47,4 +47,7 @@ regex = 'musica-distribution VERSION\s+(?P[0-9.]+)' path = "musica/_version.py" template = ''' version = "${version}" -''' \ No newline at end of file +''' + +[tool.cibuildwheel.macos.environment] +MACOSX_DEPLOYMENT_TARGET = "10.15"