0.1.2 #40
Workflow file for this run
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: Publish | |
on: | |
release: | |
types: | |
- created | |
# Sets permissions of the GITHUB_TOKEN to allow deployment to GitHub Pages | |
permissions: | |
contents: write | |
pages: write | |
id-token: write | |
# Allow only one concurrent deployment, skipping runs queued between the run in-progress and latest queued. | |
# However, do NOT cancel in-progress runs as we want to allow these production deployments to complete. | |
concurrency: | |
group: "pages" | |
cancel-in-progress: false | |
env: | |
CACHE_NUMBER: 1 # increase to reset cache manually | |
CONDA_ENV_FILE: './env.yaml' | |
CONDA_ENV_NAME: 'powermanim' | |
jobs: | |
deploy: | |
strategy: | |
fail-fast: false | |
matrix: | |
python-version: ['3.11'] | |
include: | |
- os: ubuntu-20.04 | |
label: linux-64 | |
prefix: /usr/share/miniconda3/envs/ | |
concurrency: | |
group: ${{ github.workflow }}-${{ github.ref }} | |
name: ${{ matrix.label }}-py${{ matrix.python-version }} | |
runs-on: ${{ matrix.os }} | |
steps: | |
- name: Install Latex | |
run: sudo apt-get install -y texlive texlive-latex-extra | |
- name: Parametrize conda env name | |
run: echo "PY_CONDA_ENV_NAME=${{ env.CONDA_ENV_NAME }}-${{ matrix.python-version }}" >> $GITHUB_ENV | |
- name: echo conda env name | |
run: echo ${{ env.PY_CONDA_ENV_NAME }} | |
- name: Parametrize conda prefix | |
run: echo "PY_PREFIX=${{ matrix.prefix }}${{ env.PY_CONDA_ENV_NAME }}" >> $GITHUB_ENV | |
- name: echo conda prefix | |
run: echo ${{ env.PY_PREFIX }} | |
# extract the first two digits from the release note | |
- name: Set release notes tag | |
run: | | |
export RELEASE_TAG_VERSION=${{ github.event.release.tag_name }} | |
echo "RELEASE_TAG_VERSION=${RELEASE_TAG_VERSION%.*}">> $GITHUB_ENV | |
- name: Echo release notes tag | |
run: | | |
echo "${RELEASE_TAG_VERSION}" | |
- uses: actions/checkout@v3 | |
with: | |
fetch-depth: 0 | |
# Remove the python version pin from the env.yml which could be inconsistent | |
- name: Remove explicit python version from the environment | |
shell: bash -l {0} | |
run: | | |
sed -Ei '/^\s*-?\s*python\s*([#=].*)?$/d' ${{ env.CONDA_ENV_FILE }} | |
cat ${{ env.CONDA_ENV_FILE }} | |
- name: Setup Mambaforge | |
uses: conda-incubator/setup-miniconda@v2 | |
with: | |
miniforge-variant: Mambaforge | |
miniforge-version: latest | |
activate-environment: ${{ env.PY_CONDA_ENV_NAME }} | |
python-version: ${{ matrix.python-version }} | |
use-mamba: true | |
- uses: actions/cache@v2 | |
name: Conda cache | |
with: | |
path: ${{ env.PY_PREFIX }} | |
key: ${{ matrix.label }}-conda-${{ matrix.python-version }}-${{ env.CACHE_NUMBER }}-${{ env.PY_CONDA_ENV_NAME }}-${{ hashFiles(env.CONDA_ENV_FILE) }}-${{hashFiles('./setup.cfg') }} | |
id: conda_cache | |
- uses: actions/cache@v2 | |
name: Pip cache | |
with: | |
path: ~/.cache/pip | |
key: ${{ matrix.label }}-pip-${{ matrix.python-version }}-${{ env.CACHE_NUMBER }}-${{ env.PY_CONDA_ENV_NAME }}-${{ hashFiles(env.CONDA_ENV_FILE) }}-${{hashFiles('./setup.cfg') }} | |
- uses: actions/cache@v2 | |
name: Pre-commit cache | |
with: | |
path: ~/.cache/pre-commit | |
key: ${{ matrix.label }}-pre-commit-${{ hashFiles('.pre-commit-config.yaml') }}-${{ matrix.python-version }}-${{ env.CACHE_NUMBER }}-${{ env.PY_CONDA_ENV_NAME }}-${{ hashFiles(env.CONDA_ENV_FILE) }}-${{hashFiles('./setup.cfg') }} | |
# Ensure the hack for the python version worked | |
- name: Ensure we have the right Python | |
shell: bash -l {0} | |
run: | | |
echo "Installed Python: $(python --version)" | |
echo "Expected: ${{ matrix.python-version }}" | |
python --version | grep "Python ${{ matrix.python-version }}" | |
# https://stackoverflow.com/questions/70520120/attributeerror-module-setuptools-distutils-has-no-attribute-version | |
# https://github.com/pytorch/pytorch/pull/69904 | |
- name: Downgrade setuptools due to a but in PyTorch 1.10.1 | |
shell: bash -l {0} | |
run: | | |
pip install setuptools==59.5.0 --upgrade | |
- name: Update conda environment | |
run: mamba env update -n ${{ env.PY_CONDA_ENV_NAME }} -f ${{ env.CONDA_ENV_FILE }} | |
if: steps.conda_cache.outputs.cache-hit != 'true' | |
# Update pip env whether or not there was a conda cache hit | |
- name: Update pip environment | |
shell: bash -l {0} | |
run: pip install -e ".[dev]" | |
if: steps.conda_cache.outputs.cache-hit == 'true' | |
- run: pip3 list | |
shell: bash -l {0} | |
- run: mamba info | |
- run: mamba list | |
# Ensure the hack for the python version worked | |
- name: Ensure we have the right Python | |
shell: bash -l {0} | |
run: | | |
echo "Installed Python: $(python --version)" | |
echo "Expected: ${{ matrix.python-version }}" | |
python --version | grep "Python ${{ matrix.python-version }}" | |
- name: Run pre-commits | |
shell: bash -l {0} | |
run: | | |
pre-commit install | |
pre-commit run -v --all-files --show-diff-on-failure | |
- name: Test and generate anim | |
shell: bash -l {0} | |
run: | | |
pytest -v | |
- name: Build website pages | |
shell: bash -l {0} | |
run: | | |
build_anims | |
- name: Setup Hugo | |
uses: peaceiris/actions-hugo@v2 | |
with: | |
hugo-version: '0.97.3' | |
extended: true | |
- name: Build | |
working-directory: ./docs | |
run: hugo --minify | |
- name: Deploy to GitHub Pages | |
if: success() | |
uses: crazy-max/ghaction-github-pages@v3 | |
with: | |
target_branch: gh-pages | |
build_dir: docs/public | |
env: | |
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} | |
# Uncomment to publish on PyPI on release | |
- name: Check working directory status | |
run: git status | |
- name: Restore working directory (env.yaml Python version) | |
run: git checkout . | |
- name: Build SDist and wheel | |
run: pipx run build | |
- name: Check metadata | |
run: pipx run twine check dist/* | |
- name: Publish distribution 📦 to PyPI | |
uses: pypa/gh-action-pypi-publish@release/v1 | |
with: | |
user: __token__ | |
password: ${{ secrets.PYPI_API_TOKEN }} |