Skip to content

Commit

Permalink
modified publish workflow (#952)
Browse files Browse the repository at this point in the history
* modified publish workflow using same as https://github.com/aprsa/ndpolator/blob/main/.github/workflows/on_release.yaml
* address build wheel warnings
* bump ubuntu runner to 24.04
* upgrade cibuildwheel
* skip failing builds
  • Loading branch information
kecnry authored Oct 7, 2024
1 parent fbde243 commit 22fa0db
Show file tree
Hide file tree
Showing 2 changed files with 59 additions and 47 deletions.
101 changes: 54 additions & 47 deletions .github/workflows/publish.yml
Original file line number Diff line number Diff line change
@@ -1,52 +1,59 @@
name: Release

on:
# NOTE: PR trigger is to ensure changes do not break packaging.
pull_request:
release:
types: [released]

concurrency:
group: ${{ github.workflow }}-${{ github.ref }}
cancel-in-progress: true
workflow_dispatch:
pull_request:
release:
types: [created]

jobs:
build-n-publish:
name: Build and publish Python distributions to PyPI
runs-on: ubuntu-latest
permissions:
id-token: write # IMPORTANT: this permission is mandatory for trusted publishing
if: github.repository == 'phoebe-project/phoebe2'

steps:
- uses: actions/checkout@v4
with:
fetch-depth: 0

- uses: actions/setup-python@v5
with:
python-version: '3.10'

- name: Install python-build and twine
run: python -m pip install build "twine>=3.3"

- name: Build package
run: python -m build --sdist --wheel .

- name: List result
run: ls -l dist

- name: Check dist
run: python -m twine check --strict dist/*

- name: Test package
run: |
cd ..
python -m venv testenv
testenv/bin/pip install pytest phoebe2/dist/*.whl
testenv/bin/python -c "import phoebe"
# NOTE: Do not run this part for PR testing.
- name: Publish distribution to PyPI
uses: pypa/gh-action-pypi-publish@release/v1
if: github.event_name != 'pull_request'
build-sdist:
name: Package source distribution
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- name: Build sdist tarball
run: |
pipx run build --sdist
- uses: actions/upload-artifact@v4
with:
name: cibw-sdist
path: dist/*.tar.gz

build-wheels:
name: Build wheels on ${{ matrix.os }}
runs-on: ${{ matrix.os }}
strategy:
matrix:
os: [ubuntu-24.04, macos-13, macos-14]
steps:
- name: Checkout the sources
uses: actions/checkout@v4
- name: Build wheels
uses: pypa/[email protected]
env:
CIBW_SKIP: pp37-* pp38-* pp39-* pp31*-macosx*
- uses: actions/upload-artifact@v4
with:
name: cibw-wheels-${{ matrix.os }}-${{ strategy.job-index }}
path: ./wheelhouse/*.whl

publish-to-pypi:
if: github.event_name != 'pull_request'
needs: [build-sdist, build-wheels]
name: Publish release to PyPI
runs-on: ubuntu-latest
environment:
name: pypi
url: https://pypi.org/p/phoebe
permissions:
id-token: write
steps:
- name: Gather sdist tarball and wheels
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
5 changes: 5 additions & 0 deletions pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -89,11 +89,16 @@ packages = [
"phoebe.parameters.solver",
"phoebe.parameters.figure",
"phoebe.frontend",
"phoebe.frontend.default_bundles",
"phoebe.constraints",
"phoebe.dynamics",
"phoebe.distortions",
"phoebe.algorithms",
"phoebe.atmospheres",
"phoebe.atmospheres.tables.extinction",
"phoebe.atmospheres.tables.passbands",
"phoebe.atmospheres.tables.wd",
"phoebe.lib",
"phoebe.backend",
"phoebe.solverbackends",
"phoebe.solverbackends.ebai",
Expand Down

0 comments on commit 22fa0db

Please sign in to comment.