-
Notifications
You must be signed in to change notification settings - Fork 59
149 lines (128 loc) · 4.65 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
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