Skip to content

Merge pull request #1040 from koliyo/feature/add-missing-introducer-s… #100

Merge pull request #1040 from koliyo/feature/add-missing-introducer-s…

Merge pull request #1040 from koliyo/feature/add-missing-introducer-s… #100

name: Extract And Publish Documentation
defaults:
run:
shell: bash -eo pipefail {0}
on:
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 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
jobs:
build:
if: github.repository == 'hylo-lang/hylo'
runs-on: macos-latest
steps:
- uses: actions/checkout@v3
- uses: actions/cache@v3
with:
path: .build
key: ${{ runner.os }}-spm-${{ hashFiles('**/Package.resolved') }}
restore-keys: |
${{ runner.os }}-spm-
- name: Setup swift
uses: swift-actions/setup-swift@v1
with:
swift-version: 5.8
- run: swift --version
- name: Setup LLVM
uses: KyleMayes/install-llvm-action@v1
with:
version: "15.0"
- run: llvm-config --version
- name: Prepare Shell Environment
# The format of the ${GITHUB_ENV} file is extremely restrictive; it apparently only supports
# lines of the form:
#
# <variable-name>=<one-line-of-text>
#
# And a multiline version
# (https://docs.github.com/en/actions/using-workflows/workflow-commands-for-github-actions#multiline-strings).
# It is not interpreted directly by a shell, so any quotes or other special characters are
# taken literally.
# FIXME: REF_URL_COMPONENT computation is probably wrong for some refs.
run: |
echo "PKG_CONFIG_PATH=$PWD
REPO_SANS_OWNER=${GITHUB_REPOSITORY##*/}
REF_URL_COMPONENT=${GITHUB_REF##*/}
EXTRACTION_TARGETS=$(
swift package dump-package |
jq '.targets | map(select(.type | test("^(regular|executable)$"))) | .[].name' |
xargs
)
" >> "${GITHUB_ENV}"
- name: Generate LLVM pkgconfig file
run: |
swift package resolve
.build/checkouts/Swifty-LLVM/Tools/make-pkgconfig.sh llvm.pc
cat llvm.pc
- name: Extract with DocC
run: |
export PKG_CONFIG_PATH
for TARGET in ${EXTRACTION_TARGETS}; do
mkdir -p _site/docc/"$TARGET"
Tools/retry-once swift package --allow-writing-to-directory ./_site \
generate-documentation \
--target "$TARGET" \
--output-path _site/docc/"${TARGET}" \
--experimental-documentation-coverage --level brief \
--enable-inherited-docs \
--transform-for-static-hosting \
--hosting-base-path "${REPO_SANS_OWNER}/docc/${TARGET}" \
--source-service github \
--source-service-base-url "https://github.com/${GITHUB_REPOSITORY}/blob/${REF_URL_COMPONENT}" \
--checkout-path "$(pwd)"
done
- name: Extract with Jazzy
run: |
export PKG_CONFIG_PATH
gem install jazzy
for TARGET in ${EXTRACTION_TARGETS}; do
mkdir -p _site/jazzy/"$TARGET"
jazzy \
--source-host-files-url "https://github.com/${GITHUB_REPOSITORY}/blob/${REF_URL_COMPONENT}" \
--module $(echo "$TARGET" | sed -e 's/-/_/g') \
--module-version "${{ github.event.release.tag_name }}" \
--copyright "© $(date '+%Y') The Hylo Authors. (Last updated: $(date '+%Y-%m-%d'))" \
--config .jazzy.yml \
--output _site/jazzy/"$TARGET" \
--min-acl private
done
- name: Generate Index Page
run: |
Tools/gyb.py \
--line-directive '<!-- file: %(file)s line: %(line)s -->' \
-DROOT_URL="https://hylo-lang.org/${REPO_SANS_OWNER}" \
-DEXTRACTION_TARGETS="${EXTRACTION_TARGETS}" \
-DGITHUB_REPOSITORY="${GITHUB_REPOSITORY}" \
Tools/doc-index.html.gyb -o _site/index.html
- name: Setup Pages
uses: actions/configure-pages@v3
- name: Fix permissions
run: |
chmod -v -R +rX "_site/" | while read -r line; do
echo "::warning title=Invalid file permissions automatically fixed::$line"
done
- name: Upload artifact
uses: actions/upload-pages-artifact@v2
# Deployment job
deploy:
if: github.repository == 'hylo-lang/hylo'
environment:
name: github-pages
url: ${{ steps.deployment.outputs.page_url }}
runs-on: ubuntu-latest
needs: build
steps:
- name: Deploy to GitHub Pages
id: deployment
uses: actions/deploy-pages@v2