Skip to content

Build and Publish

Build and Publish #7

Workflow file for this run

name: Build and Publish
on:
# Allows running this workflow manually from the Actions tab
workflow_dispatch:
inputs:
version:
description: "Version of Slicer documentation to build and publish"
required: true
permissions:
# Needed in the publish step to update gh-pages branch
contents: write
jobs:
build-and-publish:
env:
JCFR_TEST_BRANCH: speedup-doxygen-generation-2
runs-on: ubuntu-latest
steps:
- name: Collect Inputs
id: collect_inputs
run: |
echo "EVENT_NAME [$EVENT_NAME]"
if [[ "$EVENT_NAME" == "workflow_dispatch" ]]; then
version=${{ github.event.inputs.version }}
else
echo "::error ::Unsupported EVENT_NAME [$EVENT_NAME]"
exit 1
fi
echo "version=$version" >> $GITHUB_OUTPUT
env:
EVENT_NAME: ${{ github.event_name }}
- uses: actions/checkout@v4
with:
ref: gh-pages
path: gh-pages
- uses: actions/checkout@v4
with:
repository: jcfr/Slicer
path: Slicer
ref: ${{ env.JCFR_TEST_BRANCH }} # ${{ steps.collect_inputs.outputs.version }}
- uses: ssciwr/doxygen-install@v1
with:
version: "1.10.0"
# The "dot" binary is provided by Graphviz
- uses: ts-graphviz/setup-graphviz@v2
- uses: actions/checkout@v4
with:
repository: Slicer/slicer-apidocs-builder
path: slicer-apidocs-builder
ref: 1744509e91fa66186d34e4c6968ee684131c51d1
- uses: actions/setup-python@v5
with:
python-version: '3.13'
cache: 'pip'
- name: Install slicer-apidocs-builder
run: |
pip install ./slicer-apidocs-builder
- name: Generate Documentation
run: |
slicer-apidocs-builder \
--skip-publish \
--slicer-repo-dir Slicer \
--slicer-repo-branch "$SLICER_REPO_BRANCH" \
--slicer-repo-tag "${SLICER_REPO_TAG}"
env:
SLICER_REPO_BRANCH: ${{ env.JCFR_TEST_BRANCH }} # ${{ steps.collect_inputs.outputs.version }}
SLICER_REPO_TAG: ""
- name: Parse and annotate Doxygen warnings
run: |
WARNING_LOG_FILE=/tmp/Slicer-Slicer-$SLICER_REPO_BRANCH-build/Utilities/Doxygen/UserDoxygenWarnings.txt
echo "WARNING_LOG_FILE [$WARNING_LOG_FILE]"
if [ -f $WARNING_LOG_FILE ]; then
while IFS= read -r line; do
# Extract file, line number, and warning message
FILE=$(echo "$line" | grep -oP "^[^:]+")
LINE=$(echo "$line" | grep -oP ":(\d+):" | tr -d ":")
MESSAGE=$(echo "$line" | grep -oP "warning:.*")
# Annotate in GitHub Actions
if [[ -n "$FILE" && -n "$LINE" && -n "$MESSAGE" ]]; then
echo "::warning file=$FILE,line=$LINE::$MESSAGE"
fi
done < $WARNING_LOG_FILE
else
echo "No Doxygen warnings log found."
fi
env:
SLICER_REPO_BRANCH: ${{ env.JCFR_TEST_BRANCH }} # ${{ steps.collect_inputs.outputs.version }}
- uses: actions/create-github-app-token@c1a285145b9d317df6ced56c09f525b5c2b6f755 # v1.11.1
id: app-token
with:
app-id: ${{ vars.SLICER_APP_ID }}
private-key: ${{ secrets.SLICER_APP_PRIVATE_KEY }}
- name: Rename Directory
run: |
from=/tmp/Slicer-Slicer-$JCFR_TEST_BRANCH-src
to=/tmp/Slicer-Slicer-$SLICER_REPO_BRANCH-src
echo "from [$from] to [$to]"
mv $from $to
from=/tmp/Slicer-Slicer-$JCFR_TEST_BRANCH-build
to=/tmp/Slicer-Slicer-$SLICER_REPO_BRANCH-build
echo "from [$from] to [$to]"
mv $from $to
env:
SLICER_REPO_BRANCH: ${{ steps.collect_inputs.outputs.version }}
- name: Publish documentation
run: |
slicer-apidocs-builder \
--skip-build \
--slicer-repo-name ${SLICER_REPO_NAME} \
--slicer-repo-branch "${SLICER_REPO_BRANCH}" \
--slicer-repo-tag "${SLICER_REPO_TAG}" \
--publish-github-repo-name "Slicer/${PUBLISH_GITHUB_PROJECT_NAME}" \
--publish-github-repo-branch gh-pages
env:
PUBLISH_GITHUB_PROJECT_NAME: apidocs.slicer.org
PUBLISH_GITHUB_TOKEN: ${{ steps.app-token.outputs.token }}
SLICER_REPO_NAME: Slicer/Slicer
SLICER_REPO_BRANCH: ${{ steps.collect_inputs.outputs.version }}
SLICER_REPO_TAG: ""