Version 0.9.1 #25
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: Release | |
on: | |
push: | |
tags: | |
- v* | |
jobs: | |
checks: | |
runs-on: ubuntu-latest | |
steps: | |
- uses: actions/checkout@v4 | |
- uses: actions/setup-python@v5 | |
with: | |
python-version: '3.10' | |
- run: | | |
# Assert git and python versions match | |
pip install -e . | |
pip install -r examples/requirements.txt | |
VERSION_PY=$(python3 -c "from xplt import __version__;print('v' + __version__)") | |
echo "Python version: $VERSION_PY" | |
VERSION_GIT=$(git describe --tags) | |
echo "Git version tag: $VERSION_GIT" | |
if [ "$VERSION_GIT" != "$VERSION_PY" ] ; then | |
echo "Version mismatch!" | |
exit 1 | |
fi | |
pypi-test: | |
needs: checks | |
runs-on: ubuntu-latest | |
steps: | |
- uses: actions/checkout@v4 | |
- uses: actions/setup-python@v5 | |
with: | |
python-version: '3.10' | |
- run: | | |
pip install build | |
- name: Build | |
run: | | |
python -m build | |
- name: Publish to Test PyPI | |
uses: pypa/gh-action-pypi-publish@release/v1 | |
with: | |
password: ${{ secrets.TEST_PYPI_API_TOKEN }} | |
repository-url: https://test.pypi.org/legacy/ | |
ready: | |
needs: [checks, pypi-test] | |
runs-on: ubuntu-latest | |
steps: | |
- uses: actions/checkout@v4 | |
- run: | | |
VERSION=$(git describe --tags) | |
echo "Version: $VERSION" | |
if [[ $VERSION =~ v[0-9]+(\.[0-9]+)*$ ]] ; then | |
echo "Ready for publication" | |
else | |
echo "Not publishing dirty versions" | |
exit 1 | |
fi | |
docs-publish: | |
needs: ready | |
runs-on: ubuntu-latest | |
env: | |
PAGES_BRANCH: gh-pages | |
steps: | |
- uses: actions/checkout@v4 | |
with: | |
fetch-depth: 0 | |
- uses: actions/setup-python@v5 | |
with: | |
python-version: '3.10' | |
- name: Install dependencies | |
run: | | |
pip install -e . | |
pip install -r docs/requirements.txt | |
- name: Sphinx build | |
run: | | |
sphinx-build docs _build/html | |
VERSION=$(python -c "from docs.conf import version;print('.'.join(version.split('.')[:2]))") | |
echo "VERSION=$VERSION" >> $GITHUB_ENV | |
- name: Deploy docs | |
run: | | |
git config user.name "GitHub Actions" | |
git config user.email "<>" | |
git checkout $PAGES_BRANCH | |
# Copy to version folder | |
rm -rf $VERSION | |
cp -r _build/html $VERSION | |
# Update docs | |
./update.py | |
cat versions.json | |
# Commit and push | |
git add $VERSION latest versions.json | |
git commit -m "Deploy docs/$VERSION" | |
git push origin $PAGES_BRANCH | |
pypi-publish: | |
needs: ready | |
runs-on: ubuntu-latest | |
steps: | |
- uses: actions/checkout@v4 | |
- uses: actions/setup-python@v5 | |
with: | |
python-version: '3.10' | |
- run: | | |
pip install build | |
- name: Build | |
run: | | |
python -m build | |
- name: Publish to PyPI | |
if: startsWith(github.ref, 'refs/tags') | |
uses: pypa/gh-action-pypi-publish@release/v1 | |
with: | |
password: ${{ secrets.PYPI_API_TOKEN }} | |