diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index ee712b2..12b886f 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -140,15 +140,17 @@ jobs: matrix: include: ${{ fromJSON( github.event_name == 'pull_request' && - '[{"arch":"arm64","runner":"macos-latest","python_arch":"arm64","primary":true}]' || + '[{"arch":"arm64","runner":"macos-latest","python_arch":"arm64","deployment_target":"11.0","wheel_platform":"macosx_11_0_arm64","primary":true}]' || inputs.macos_arm64 && inputs.macos_x86_64 && - '[{"arch":"arm64","runner":"macos-latest","python_arch":"arm64","primary":true},{"arch":"x86_64","runner":"macos-15-intel","python_arch":"x64","primary":false}]' || + '[{"arch":"arm64","runner":"macos-latest","python_arch":"arm64","deployment_target":"11.0","wheel_platform":"macosx_11_0_arm64","primary":true},{"arch":"x86_64","runner":"macos-15-intel","python_arch":"x64","deployment_target":"10.15","wheel_platform":"macosx_10_15_x86_64","primary":false}]' || inputs.macos_arm64 && - '[{"arch":"arm64","runner":"macos-latest","python_arch":"arm64","primary":true}]' || - '[{"arch":"x86_64","runner":"macos-15-intel","python_arch":"x64","primary":true}]' + '[{"arch":"arm64","runner":"macos-latest","python_arch":"arm64","deployment_target":"11.0","wheel_platform":"macosx_11_0_arm64","primary":true}]' || + '[{"arch":"x86_64","runner":"macos-15-intel","python_arch":"x64","deployment_target":"10.15","wheel_platform":"macosx_10_15_x86_64","primary":true}]' ) }} name: macos-${{ matrix.arch }} runs-on: ${{ matrix.runner }} + env: + MACOSX_DEPLOYMENT_TARGET: ${{ matrix.deployment_target }} steps: - name: Check out repository @@ -172,6 +174,9 @@ jobs: python -m pip install build python -m build --wheel . + - name: Verify wheel deployment target + run: test -f dist/spicedmodel-*-${{ matrix.wheel_platform }}.whl + - name: Build source distribution if: inputs.upload_artifacts && matrix.primary && !inputs.linux_x86_64 && !inputs.linux_aarch64 run: python -m build --sdist . diff --git a/.github/workflows/release.yml b/.github/workflows/release.yml new file mode 100644 index 0000000..5fa73c9 --- /dev/null +++ b/.github/workflows/release.yml @@ -0,0 +1,148 @@ +name: Release Package + +on: + workflow_dispatch: + inputs: + test: + description: Publish to TestPyPI instead of PyPI + required: false + default: false + type: boolean + +permissions: + contents: write + +jobs: + get_version: + runs-on: ubuntu-latest + outputs: + version: ${{ steps.get_version.outputs.version }} + steps: + - name: Check out repository + uses: actions/checkout@3d3c42e5aac5ba805825da76410c181273ba90b1 # v7.0.1 + + - name: Get version from pyproject.toml + id: get_version + run: | + version=$(python3 - <<'PY' + import tomllib + from pathlib import Path + + metadata = tomllib.loads(Path("pyproject.toml").read_text(encoding="utf-8")) + print(f"v{metadata['project']['version']}") + PY + ) + echo "Found version: ${version}" + echo "version=${version}" >> "$GITHUB_OUTPUT" + + tag: + runs-on: ubuntu-latest + needs: get_version + steps: + - name: Check out repository + uses: actions/checkout@3d3c42e5aac5ba805825da76410c181273ba90b1 # v7.0.1 + with: + fetch-depth: 0 + + - name: Configure Git + run: | + git config user.name "github-actions" + git config user.email "github-actions@github.com" + + - name: Check that tag is available + run: | + tag="${{ needs.get_version.outputs.version }}" + if git rev-parse "$tag" >/dev/null 2>&1; then + echo "Tag $tag already exists" + exit 1 + fi + + - name: Create and push tag + run: | + tag="${{ needs.get_version.outputs.version }}" + git tag "$tag" + git push origin "$tag" + + build_artifacts: + needs: + - get_version + - tag + uses: ./.github/workflows/ci.yml + with: + linux_x86_64: true + linux_aarch64: true + macos_arm64: true + macos_x86_64: true + windows_x86_64: true + windows_arm64: true + upload_artifacts: true + secrets: inherit + + release: + runs-on: ubuntu-latest + needs: + - get_version + - build_artifacts + permissions: + contents: write + steps: + - name: Download release artifacts + uses: actions/download-artifact@3e5f45b2cfb9172054b4087a40e8e0b5a5461e7c # v8.0.1 + with: + path: release-artifacts + merge-multiple: true + + - name: List release artifacts + run: find release-artifacts -type f | sort + + - name: Create GitHub release and upload assets + uses: softprops/action-gh-release@b4309332981a82ec1c5618f44dd2e27cc8bfbfda # v3.0.0 + with: + tag_name: ${{ needs.get_version.outputs.version }} + name: Release ${{ needs.get_version.outputs.version }} + draft: false + prerelease: false + files: release-artifacts/* + + publish_testpypi: + runs-on: ubuntu-latest + if: inputs.test + needs: build_artifacts + steps: + - name: Download distribution artifacts + uses: actions/download-artifact@3e5f45b2cfb9172054b4087a40e8e0b5a5461e7c # v8.0.1 + with: + path: dist + merge-multiple: true + + - name: List distributions + run: find dist -type f | sort + + - name: Publish package distributions to TestPyPI + uses: pypa/gh-action-pypi-publish@dc37677b2e1c63e2034f94d8a5b11f265b73ba33 # v1.14.2 + with: + user: __token__ + password: ${{ secrets.TEST_PYPI_API_TOKEN }} + repository-url: https://test.pypi.org/legacy/ + + publish_pypi: + runs-on: ubuntu-latest + if: ${{ !inputs.test }} + needs: + - build_artifacts + - release + steps: + - name: Download distribution artifacts + uses: actions/download-artifact@3e5f45b2cfb9172054b4087a40e8e0b5a5461e7c # v8.0.1 + with: + path: dist + merge-multiple: true + + - name: List distributions + run: find dist -type f | sort + + - name: Publish package distributions to PyPI + uses: pypa/gh-action-pypi-publish@dc37677b2e1c63e2034f94d8a5b11f265b73ba33 # v1.14.2 + with: + user: __token__ + password: ${{ secrets.PYPI_API_TOKEN }} diff --git a/pyproject.toml b/pyproject.toml index 4c6e840..c860e26 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -4,7 +4,7 @@ build-backend = "scikit_build_core.build" [project] name = "spicedmodel" -version = "1.0.0" +version = "1.1.0" description = "Python wrapper for the Scalable Plasma Ion Composition and Electron Density (SPICED) model" readme = "README.md" license = "MIT" diff --git a/spicedmodel/__init__.py b/spicedmodel/__init__.py index 01f62d2..0091c55 100644 --- a/spicedmodel/__init__.py +++ b/spicedmodel/__init__.py @@ -1,4 +1,4 @@ -__version__ = '1.0.0' +__version__ = '1.1.0' from . import _CFunctions from .Mav import Mav diff --git a/tests/test_golden.py b/tests/test_golden.py index 7db77da..6c7c19d 100644 --- a/tests/test_golden.py +++ b/tests/test_golden.py @@ -13,7 +13,7 @@ # reverse-transformed DC output. That cancellation varies slightly between # compilers even when the complete model output is stable. FOURIER_RTOL = 2e-4 -FOURIER_ATOL = 2e-3 +FOURIER_ATOL = 4e-3 def _array(section):