Skip to content

Commit

Permalink
ci: update build ci to incorporate multiple os and multiple python ve…
Browse files Browse the repository at this point in the history
…rsions (#55)

* update ci to build sdist and to build wheels on multiple platforms

* update python version

* fix CIBU_BUILD error

* update python version

* skip building wheels for testing

* skip building wheels for testing

* skip building wheels for testing

* update workflow

* disable ubuntu for quick test

* exclude checkpoints

* now build on both ubuntu and macosx
  • Loading branch information
yanghan234 authored Dec 5, 2024
1 parent 5cc5ea9 commit a4f58fd
Show file tree
Hide file tree
Showing 2 changed files with 56 additions and 21 deletions.
75 changes: 55 additions & 20 deletions .github/workflows/python-publish.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -11,65 +11,100 @@ name: Upload Python Package
on:
release:
types: [published]
workflow_dispatch:
inputs:
target-repo:
description: 'Target repository (pypi or testpypi)'
required: true
default: 'testpypi'

permissions:
contents: read

jobs:
release-build:
build_sdist:
runs-on: ubuntu-latest

steps:
- uses: actions/checkout@v4
with:
fetch-depth: 0
- name: Check out repo
uses: actions/checkout@v4

- uses: actions/setup-python@v5
- name: Install Python
uses: actions/setup-python@v5
with:
python-version: "3.x"

- name: Build release distributions
- name: Build source distribution
run: |
# NOTE: put your own distribution build steps here.
python -m pip install build cibuildwheel
cibuildwheel --output-dir dist/
pip install build
python -m build --sdist
- name: Upload distributions
- uses: actions/upload-artifact@v4
with:
name: dist-sdist
path: dist/*.tar.gz

build_wheels:
strategy:
matrix:
os: [ubuntu-latest, macos-14]
python-version: ['39', '310', '311', '312']
runs-on: ${{ matrix.os }}

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

- name: Build wheels
uses: pypa/cibuildwheel@v2.16.5
env:
CIBW_BUILD: cp${{ matrix.python-version }}-*

- name: Upload artifacts
uses: actions/upload-artifact@v4
with:
name: release-dists
path: dist/
name: dist-${{ matrix.os }}-${{ matrix.python-version }}
path: ./wheelhouse/*.whl

pypi-publish:
runs-on: ubuntu-latest
needs:
- release-build
- build_sdist
- build_wheels
permissions:
# IMPORTANT: this permission is mandatory for trusted publishing
id-token: write

# Dedicated environments with protections for publishing are strongly recommended.
# For more information, see: https://docs.github.com/en/actions/deployment/targeting-different-environments/using-environments-for-deployment#deployment-protection-rules
environment:
name: pypi
name: ${{ github.event.inputs.target-repo == 'pypi' && 'pypi' || 'testpypi' }}
# OPTIONAL: uncomment and update to include your PyPI project URL in the deployment status:
# url: https://pypi.org/p/YOURPROJECT
#
# ALTERNATIVE: if your GitHub Release name is the PyPI project version string
# ALTERNATIVE: exactly, uncomment the following line instead:
# url: https://pypi.org/project/YOURPROJECT/${{ github.event.release.name }}
url: https://pypi.org/project/mattersim/${{ github.event.release.name }}
url: ${{ github.event.inputs.target-repo == 'pypi' && 'https://pypi.org/project/mattersim/' || 'https://test.pypi.org/project/mattersim/' }}${{ github.event.release.name }}

steps:
- name: Set up Python
uses: actions/setup-python@v2
with:
python-version: '3.12'

- name: Retrieve release distributions
uses: actions/download-artifact@v4
with:
name: release-dists
path: dist/
pattern: dist-*
merge-multiple: true
path: dist

- name: Publish release distributions to PyPI
uses: pypa/gh-action-pypi-publish@release/v1
with:
verbose: true
skip-existing: true
packages-dir: dist/
password: ${{ secrets.PYPI_TOKEN }}
repository-url: https://upload.pypi.org/legacy/
password: ${{ github.event.inputs.target-repo == 'pypi' && secrets.PYPI_TOKEN || secrets.TEST_PYPI_TOKEN }}
repository-url: ${{ github.event.inputs.target-repo == 'pypi' && 'https://upload.pypi.org/legacy/' || 'https://test.pypi.org/legacy/' }}
2 changes: 1 addition & 1 deletion MANIFEST.in
Original file line number Diff line number Diff line change
Expand Up @@ -18,5 +18,5 @@ include src

# Exclude directories
exclude docs
exclude pretrained_models
exclude pretrained_models/*.pth
exclude tests

0 comments on commit a4f58fd

Please sign in to comment.