diff --git a/.github/workflows/docs.yml b/.github/workflows/docs.yml new file mode 100644 index 0000000..c3274cd --- /dev/null +++ b/.github/workflows/docs.yml @@ -0,0 +1,63 @@ +name: Deploy Sphinx docs static content to GitHub Pages + +on: + # Runs on pushes targeting the default branch + push: + branches: ["main"] + + # Allows you to run this workflow manually from the Actions tab + workflow_dispatch: + +# Sets permissions of the GITHUB_TOKEN to allow deployment to GitHub Pages +permissions: + contents: read + pages: write + id-token: write + +# Allow one concurrent deployment +concurrency: + group: "pages" + cancel-in-progress: false + +jobs: + # Single deploy job since we're just deploying + docs-pages: + environment: + name: github-pages + url: ${{ steps.deployment.outputs.page_url }} + runs-on: ubuntu-latest + steps: + - name: Checkout + uses: actions/checkout@v4 + - name: Set up Python 3.11 + uses: actions/setup-python@v5 + with: + python-version: 3.11 + cache: 'pip' + - name: Install dependencies + run: | + python -m pip install --upgrade pip + python -m pip install -r docs/requirements.txt + python -m pip install -e . + - name: Build Sphinx Documentation + run: | + make -C docs html + rm docs/build/html/.buildinfo + + - name: Upload documentation + uses: actions/upload-artifact@v4 + with: + name: sphinx-docs + path: docs/build/html + + - name: Setup Pages + uses: actions/configure-pages@v4 + - name: Upload artifact + if: github.ref == 'refs/heads/main' + uses: actions/upload-pages-artifact@v3 + with: + # Upload build sphinx docs + path: 'docs/build/html' + - name: Deploy to GitHub Pages + id: deployment + uses: actions/deploy-pages@v4 diff --git a/.github/workflows/main.yml b/.github/workflows/main.yml index 1c6d39a..da78cc3 100644 --- a/.github/workflows/main.yml +++ b/.github/workflows/main.yml @@ -70,7 +70,7 @@ jobs: python -m pytest - package_docs: + package: needs: test runs-on: ubuntu-latest steps: @@ -91,10 +91,10 @@ jobs: - name: Git LFS Pull run: | git lfs pull - - name: Set up Python 3.9 + - name: Set up Python 3.11 uses: actions/setup-python@v5 with: - python-version: 3.9 + python-version: 3.11 - name: Install dependencies run: | python -m pip install --upgrade pip @@ -110,39 +110,16 @@ jobs: with: name: python-packages path: dist - - name: Build Sphinx Documentation - run: | - python -m pip install dist/rap_sitkcore*.whl -r docs/requirements.txt - cd docs - make html - - name: Upload documentation - if: github.event_name == 'push' - uses: actions/upload-artifact@v4 - with: - name: sphinx-docs - path: docs/_build/html - - name: Update gh-pages - if: github.ref == 'refs/heads/main' - run: | - rm docs/_build/html/.buildinfo - touch docs/_build/html/.nojekyll - git update-ref refs/heads/${TARGET_BRANCH} origin/${TARGET_BRANCH} - ./utils/update-gh-pages.sh docs/_build/html - repo_uri="https://x-access-token:${GITHUB_TOKEN}@github.com/${GITHUB_REPOSITORY}.git" - git push $repo_uri ${TARGET_BRANCH} - env: - GITHUB_TOKEN: ${{ secrets.github_token }} - TARGET_BRANCH: 'gh-pages' github_publish: if: startsWith(github.ref, 'refs/tags/v') needs: package_docs runs-on: ubuntu-latest steps: - - name: Set up Python 3.9 + - name: Set up Python 3.11 uses: actions/setup-python@v5 with: - python-version: 3.9 + python-version: 3.11 - name: Install dependencies run: | python -m pip install --upgrade pip diff --git a/utils/update-gh-pages.sh b/utils/update-gh-pages.sh deleted file mode 100755 index 1e56285..0000000 --- a/utils/update-gh-pages.sh +++ /dev/null @@ -1,87 +0,0 @@ -#!/usr/bin/env bash -# -# Copyright Bradley Lowekamp -# -# Licensed under the Apache License, Version 2.0 (the "License"); -# you may not use this file except in compliance with the License. -# You may obtain a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0.txt -# -# Unless required by applicable law or agreed to in writing, software -# distributed under the License is distributed on an "AS IS" BASIS, -# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -# See the License for the specific language governing permissions and -# limitations under the License. -# - -# This script takes a path as an argument to create a commit on the ENV:TARGET_BRANCH or "gh-pages" branch which sets -# the branch to match the contents for the provided path. - -set -eu - -target_branch=${TARGET_BRANCH:-"gh-pages"} - - -if [[ -n "${GITHUB_ACTOR+x}" ]]; then - git config user.name "$GITHUB_ACTOR" - git config user.email "${GITHUB_ACTOR}@bots.github.com" -fi - - - -die() -{ - echo "Error: $@" 1>&2 - exit 1 -} - - -usage() -{ - die "Usage: $0 path_to_branch" -} - - -if [[ ! -d "$1" ]] ; then - echo "Argument is not a directory: $1" 1>&2 - usage -fi - -branch_path="$(cd "$(dirname "$1")" && pwd)" -branch_path="$branch_path/$(basename "$1")" - -toplevel_path=$( cd "$( dirname "$0" )" && git rev-parse --show-toplevel) -cd "$toplevel_path" - - -old_branch_sha=$(git rev-list -n 1 "$target_branch" ) -echo "Current $target_branch change id: $old_branch_sha" - -branch_temp_index="$toplevel_path/$target_branch.index" -rm -rf "$branch_temp_index" - - - -new_tree=$( - GIT_WORK_TREE="$branch_path" && - GIT_INDEX_FILE="$branch_temp_index" && - export GIT_WORK_TREE GIT_INDEX_FILE && - git add --all && - git write-tree -) || die "creating new tree failed" - -rm -rf "$branch_temp_index" - -if [[ -z $(git diff-tree "$new_tree" "$old_branch_sha") ]]; then - echo "No changes to $target_branch branch." - exit 0 -fi - - -new_changeid=$(git commit-tree "$new_tree" -p "$old_branch_sha" -m "Automatic Update - -$(date)") -echo "Updating $target_branch with $new_changeid..." -git update-ref refs/heads/$target_branch $new_changeid -