-
Notifications
You must be signed in to change notification settings - Fork 59
165 lines (142 loc) · 5.54 KB
/
doc-extraction.yml
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
name: Extract And Publish Documentation
defaults:
run:
shell: 'bash -eo pipefail {0}'
on:
push:
branches: [ main, fix-doc-generation ]
# 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-15
env:
llvm_url_prefix: https://github.com/hylo-lang/llvm-build/releases/download/20240303-215025
llvm_package_basename: llvm-17.0.6-arm64-apple-darwin23.3.0-MinSizeRel
swift-version: '5.10'
steps:
- uses: actions/checkout@v4
with:
submodules: true
show-progress: false
- name: Install Jazzy
run: |
sudo gem install jazzy
- name: Setup swift
uses: SwiftyLab/setup-swift@latest
with:
swift-version: ${{ env.swift-version }}
cache-snapshot: false # Workaround for https://github.com/SwiftyLab/setup-swift/issues/315
- name: Install LLVM and create its pkgconfig file
# 7z doesn't support decompressing from a stream or we'd do this all as one statement. Maybe
# we should find a way to use zstd on windows.
run: >-
curl --no-progress-meter -L -O
-H "Authorization: token ${{ secrets.GITHUB_TOKEN }}"
${{ env.llvm_url_prefix }}/${{ env.llvm_package_basename }}.tar.zst
tar -x --zstd -f ${{ env.llvm_package_basename }}.tar.zst
PATH="${{ github.workspace }}/${{ env.llvm_package_basename }}/bin:$PATH"
./Tools/make-pkgconfig.sh llvm.pc
- name: Prepare shell environment
run: |
echo "PKG_CONFIG_PATH=${{ github.workspace }}
REPO_SANS_OWNER=${GITHUB_REPOSITORY##*/}
REF_URL_COMPONENT=${GITHUB_REF##*/}
HYLO_ENABLE_DOC_GENERATION=1
" >> "${GITHUB_ENV}"
- uses: actions/cache@v4
with:
path: .build
key: ${{ runner.os }}-debug-spm-${{ hashFiles('./**/Package.resolved') }}
restore-keys: |
${{ runner.os }}-debug-spm-
- name: Compute the Extraction Targets
# 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 "EXTRACTION_TARGETS=$(
swift package dump-package |
jq '.targets | map(select(.type | test("^(regular|executable)$"))) | .[].name' |
xargs
)
" >> "${GITHUB_ENV}"
- name: Generate Index Page
run: |
mkdir -p _site
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: 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
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: Setup Pages
uses: actions/configure-pages@v5
- 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@v3
# 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@v4