Skip to content

add project+version handling #32

add project+version handling

add project+version handling #32

Workflow file for this run

name: CI-CD
on:
push:
release:
pull_request:
jobs:
test:
name: Py${{ matrix.PYTHON_VERSION }}
runs-on: ubuntu-latest
defaults:
run:
shell: bash -l {0}
env:
CI: 'true'
OS: 'linux'
PYTHON_VERSION: ${{ matrix.PYTHON_VERSION }}
strategy:
fail-fast: false
matrix:
PYTHON_VERSION: ['3.9', '3.10', '3.11']
steps:
- name: Checkout Pull Requests
uses: actions/checkout@v6
- name: Install Environment Dependencies
run: |
sudo apt-get update --fix-missing
sudo apt-get install -y libgit2-dev xvfb x11-utils libxkbcommon-x11-0 libxcb-icccm4 libxcb-image0 libxcb-keysyms1 libxcb-randr0 libxcb-render-util0 libxcb-xinerama0 libxcb-xfixes0 xdotool
- name: Setup miniconda
uses: conda-incubator/setup-miniconda@v3
with:
miniconda-version: "latest"
python-version: ${{ matrix.PYTHON_VERSION }}
channel-priority: false # "strict"
channels: "conda-forge"
mamba-version: "*"
show-channel-urls: true
- name: Setup environment
run: |
mamba install spyder
pip install -e .
conda list
generate_artifacts:
needs: test
runs-on: ubuntu-latest
defaults:
run:
shell: bash -l {0}
steps:
- name: Checkout Pull Requests
uses: actions/checkout@v6
- name: Install Environment Dependencies
shell: bash
run: |
sudo apt-get update --fix-missing
- name: Setup miniconda
uses: conda-incubator/setup-miniconda@v3
with:
miniconda-version: "latest"
python-version: 3.9
channel-priority: false # "strict"
channels: "conda-forge"
mamba-version: "*"
show-channel-urls: true
- name: Compute Version
id: computed_version
run: |
if [[ ${{ github.event.release.tag_name != '' }} != false ]]
then
echo ::set-output name=VERSION::$(echo $GITHUB_REF | cut -d / -f 3)
else
echo ::set-output name=VERSION::$(echo "0.0.0")
fi
- name: Apply version
run: |
echo Version is ${{ steps.computed_version.outputs.VERSION }}
cd scripts
python package_tool.py --tag-version ${{ steps.computed_version.outputs.VERSION }}
cd ..
- name: Setup environment
run: |
pip install sphinx sphinx-rtd-theme myst-parser sphinx-markdown-tables
pip install --upgrade myst-parser
pip install check-manifest
pip install twine
pip install -e .
- name: Run Manifest Check
run: |
echo 'Check manifest of Pylab-ML'
check-manifest
- name: Build Sphinx
run: |
sphinx-build -b html docs/source/ docs/build/html
- name: Fix output file permissions
run: |
sudo chown -R $USER:$USER docs
- name: Upload docs to Github artifact
uses: actions/upload-artifact@v6
with:
path: docs/build/html/*
name: docs-output
- name: Deploy preview
uses: rossjrw/pr-preview-action@v1
with:
source-dir: ./docs/build/html
- uses: JamesIves/github-pages-deploy-action@v4
with:
folder: ./docs/build/html
branch: gh-pages
clean-exclude: pr-preview
- name: Generate distribution sdist files
run: |
cd scripts
python -m pip install build
python package_tool.py
cd ..
- name: Check distribution files
run: |
twine check output/*
- name: Upload Build Artifacts
uses: actions/upload-artifact@v4
with:
name: output
path: ./output
publish:
if: ${{ github.event.release.tag_name != '' }}
needs: generate_artifacts
runs-on: ubuntu-latest
defaults:
run:
shell: bash -l {0}
steps:
- name: Install
run: |
python -m pip install twine
- name: Get artifacts from build job
uses: actions/download-artifact@v3
with:
name: output
path: |
output
- name: Extend Release Assets
uses: alexellis/upload-assets@0.3.0
env:
GITHUB_TOKEN: ${{ github.token }}
with:
asset_paths: '["output/*"]'
- name: Upload to PyPi using twine
run: |
for i in `find output/ -type f`; do twine upload -u __token__ -p ${{ secrets.PYPI_TOKEN }} $i; done