update readme and update pypi #53
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: Build and Deploy Sphinx Docs | |
on: | |
push: | |
branches: | |
- main | |
workflow_dispatch: | |
jobs: | |
deploy: | |
runs-on: ubuntu-latest | |
steps: | |
- name: Checkout repository | |
uses: actions/checkout@v2 | |
with: | |
fetch-depth: 0 # Fetch all history for all branches and tags | |
- name: Set up Python | |
uses: actions/setup-python@v2 | |
with: | |
python-version: '3.10' | |
- name: Install dependencies | |
run: | | |
python -m pip install --upgrade pip | |
pip install -r requirements.txt | |
- name: Extract current release version | |
id: current_version | |
run: | | |
grep -oP "(?<=release = ')[^']+" docs/conf.py > current_version.txt | |
echo "Current version: $(cat current_version.txt)" | |
- name: Check if there is a previous commit | |
id: check_previous_commit | |
run: | | |
if git rev-parse HEAD~1 >/dev/null 2>&1; then | |
echo "Previous commit exists" | |
echo "previous_commit_exists=true" >> $GITHUB_ENV | |
else | |
echo "No previous commit found" | |
echo "previous_commit_exists=false" >> $GITHUB_ENV | |
fi | |
- name: Extract previous release version | |
id: previous_version | |
run: | | |
if [ "${{ env.previous_commit_exists }}" == "true" ]; then | |
if git ls-tree HEAD~1 -- docs/conf.py >/dev/null 2>&1; then | |
# docs/conf.py exists in the previous commit | |
git show HEAD~1:docs/conf.py | grep -oP "(?<=release = ')[^']+" > previous_version.txt | |
else | |
# docs/conf.py does not exist in the previous commit | |
echo "0.0.0" > previous_version.txt | |
fi | |
else | |
echo "0.0.0" > previous_version.txt # Fake previous release version | |
fi | |
echo "Previous version: $(cat previous_version.txt)" | |
- name: Compare release versions | |
id: compare_versions | |
run: | | |
if [ "$(cat current_version.txt)" != "$(cat previous_version.txt)" ]; then | |
echo "Release version changed or first run" | |
echo "release_version_changed=true" >> $GITHUB_ENV | |
else | |
echo "Release version unchanged" | |
echo "release_version_changed=false" >> $GITHUB_ENV | |
fi | |
- name: Build HTML | |
if: env.release_version_changed == 'true' | |
run: | | |
cd docs/ | |
make html | |
- name: Deploy to GitHub Pages | |
if: env.release_version_changed == 'true' | |
uses: peaceiris/actions-gh-pages@v3 | |
with: | |
github_token: ${{ secrets.ACTIONS_DEPLOY_KEY }} | |
publish_dir: docs/_build/html | |