version 0.17.0 #124
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
name: package builds | |
on: | |
push: | |
branches: [master] | |
pull_request: | |
branches: [master] | |
types: [opened, reopened, synchronize] | |
env: | |
PYTHON_VERSION: "3.12" | |
jobs: | |
# if on pull req. add a timestamp to the version (treat it as a test release) | |
Determine-Build-Type: | |
runs-on: ubuntu-latest | |
env: | |
BASE_VER: Nil | |
steps: | |
- name: Check out repository code | |
uses: actions/checkout@v3 | |
- name: Obtain the base version | |
run: | | |
_BV=$(sh .github/get_version.sh) | |
echo "BASE_VER=${_BV}" >> $GITHUB_ENV | |
- name: Determine the final version | |
id: make_final_version | |
run: | | |
if [ ${{ github.event_name }} == 'pull_request' ]; then | |
export VER_SUFFIX="rc$(date +'%Y%m%d%H%M%S')" | |
else | |
export VER_SUFFIX="" | |
fi | |
echo "val=${{ env.BASE_VER }}${VER_SUFFIX}" >> $GITHUB_OUTPUT | |
outputs: | |
package_ver: ${{ steps.make_final_version.outputs.val }} | |
# build multiplatform wheels | |
Build-Wheels: | |
runs-on: ${{ matrix.os }} | |
needs: [Determine-Build-Type] | |
strategy: | |
matrix: | |
os: [ubuntu-latest, macos-latest, windows-latest] | |
steps: | |
- name: Check out repository code | |
uses: actions/checkout@v3 | |
- name: Set up Python | |
uses: actions/setup-python@v4 | |
with: | |
python-version: ${{ env.PYTHON_VERSION }} | |
- name: Install dependencies | |
run: python -m pip install --upgrade pip -r env/pip_dev.txt | |
- name: Update the codebase by a build version | |
run: | | |
sh .github/update_version.sh "${{ needs.Determine-Build-Type.outputs.package_ver }}" | |
echo $(sh .github/get_version.sh) | |
- name: Build a Wheel Package | |
run: python -m build --wheel . | |
- name: Save the artifacts | |
uses: actions/[email protected] | |
with: | |
name: wheel_${{ matrix.os }} | |
path: ./dist | |
# prepare tarball with sources | |
Prepare-Tarball: | |
runs-on: ubuntu-latest | |
needs: [Determine-Build-Type] | |
steps: | |
- name: Check out repository code | |
uses: actions/checkout@v3 | |
- name: Set up Python | |
uses: actions/setup-python@v4 | |
with: | |
python-version: ${{ env.PYTHON_VERSION }} | |
- name: Install dependencies | |
run: | | |
python -m pip install --upgrade pip -r env/pip_dev.txt | |
- name: Update the codebase by a build version | |
run: | | |
sh .github/update_version.sh "${{ needs.Determine-Build-Type.outputs.package_ver }}" | |
echo $(sh .github/get_version.sh) | |
- name: Prepare a Source Distro | |
run: python -m build --sdist . | |
- name: Check if the package can be uploaded to PyPI | |
run: python -m twine check dist/* | |
- name: Save the artifacts | |
uses: actions/[email protected] | |
with: | |
name: dist_tarball | |
path: ./dist | |
# previous job used Ubuntu OS, but PyPI requires ManyLinux distro, hence we | |
# need to convert it properly | |
Convert-Ubuntu-To-Manylinux: | |
runs-on: ubuntu-latest | |
needs: [Build-Wheels, Prepare-Tarball] | |
steps: | |
- name: Set up Python | |
uses: actions/setup-python@v4 | |
with: | |
python-version: ${{ env.PYTHON_VERSION }} | |
- name: Install dependencies | |
run: | | |
python -m pip install --upgrade pip auditwheel | |
- name: Download artifacts | |
uses: actions/[email protected] | |
with: | |
name: wheel_ubuntu-latest | |
path: ./dist | |
- name: Convert Ubuntu to ManyLinux | |
run: | | |
auditwheel show dist/network_diffusion-*-linux_x86_64.whl | |
auditwheel repair --wheel-dir dist dist/network_diffusion-*-linux_x86_64.whl | |
- name: Remove Ubuntu based build | |
run: rm dist/network_diffusion-*-linux_x86_64.whl | |
- name: Save artifacts | |
uses: actions/[email protected] | |
with: | |
name: wheel_manylinux | |
path: ./dist | |
# move produced artifacts into a single directory | |
Consolidate-Artifacts: | |
runs-on: ubuntu-latest | |
needs: [Convert-Ubuntu-To-Manylinux] | |
steps: | |
- name: Download artifacts | |
uses: actions/[email protected] | |
- name: Create the dist directory | |
run: mkdir -p dist | |
- name: Move builds to dist | |
run: | | |
mv dist_tarball/* dist/ | |
mv wheel_macos-latest/* dist/ | |
mv wheel_manylinux/* dist/ | |
mv wheel_windows-latest/* dist/ | |
- name: Upload consolidated dist directory as artifact | |
uses: actions/[email protected] | |
with: | |
name: consolidated_dist | |
path: ./dist | |
# download builds and send them to Python Package Index | |
Publish-Package: | |
runs-on: ubuntu-latest | |
needs: [Consolidate-Artifacts] | |
steps: | |
- name: Download artifacts | |
uses: actions/[email protected] | |
with: | |
name: consolidated_dist | |
path: ./dist | |
- name: Publish on PyPI | |
uses: pypa/[email protected] | |
with: | |
user: __token__ | |
password: ${{ secrets.PYPI_API_TOKEN }} | |
# create a GitHub release and tag current commit | |
Create-Tag-Release: | |
runs-on: ubuntu-latest | |
needs: [Determine-Build-Type, Consolidate-Artifacts] | |
steps: | |
- name: Check out repository code | |
uses: actions/checkout@v3 | |
- name: Add tag | |
uses: rickstaa/[email protected] | |
with: | |
tag: ${{ needs.Determine-Build-Type.outputs.package_ver }} | |
message: "Added tag" | |
- name: Download artifacts | |
uses: actions/[email protected] | |
with: | |
name: consolidated_dist | |
path: ./dist | |
- name: Add GitHub release | |
uses: softprops/[email protected] | |
with: | |
tag_name: ${{ needs.Determine-Build-Type.outputs.package_ver }} | |
files: | | |
./dist/*.whl | |
./dist/*.tar.gz |