Skip to content

Commit 3fb0648

Browse files
committedJun 21, 2024·
(docs) GitHub Pages
1 parent 6027a46 commit 3fb0648

File tree

4 files changed

+72
-2
lines changed

4 files changed

+72
-2
lines changed
 

‎.editorconfig

+3
Original file line numberDiff line numberDiff line change
@@ -15,3 +15,6 @@ indent_size = 2
1515

1616
[*.{yml,yaml}]
1717
indent_size = 2
18+
19+
[*.lua]
20+
indent_size = 2

‎.github/workflows/ci.yaml

+54-2
Original file line numberDiff line numberDiff line change
@@ -76,6 +76,9 @@ jobs:
7676
distribution: temurin
7777
java-version: 21
7878

79+
- name: Set up Git Hub Pages
80+
uses: actions/configure-pages@v5
81+
7982
- name: Cache Gradle packages
8083
uses: actions/cache@v4
8184
with:
@@ -91,16 +94,40 @@ jobs:
9194
- name: Install PCRE
9295
run: sudo apt-get install -y libpcre2-8-0
9396

94-
- name: Build
97+
- name: Build artifacts
9598
run: ./gradlew build jacocoAggregatedTestReport -Dpcre2.library.path=/usr/lib/x86_64-linux-gnu
9699

100+
- name: Build docs
101+
run: |
102+
sudo apt-get install -y pandoc
103+
104+
mkdir -p build/gh-pages
105+
pandoc -f gfm -t html5 -s --shift-heading-level-by=-1 --lua-filter=gh-pages/filter.lua \
106+
-o build/gh-pages/index.html README.md
107+
pandoc -f gfm -t html5 -s --shift-heading-level-by=-1 --lua-filter=gh-pages/filter.lua \
108+
-o build/gh-pages/pcre2-api.html PCRE2_API.md
109+
110+
mkdir -p build/gh-pages/docs
111+
pandoc -f markdown -t html5 -s --shift-heading-level-by=-1 --lua-filter=gh-pages/filter.lua \
112+
-o build/gh-pages/docs/index.html gh-pages/docs/index.md
113+
cp -a api/build/docs/. build/gh-pages/docs/api
114+
cp -a lib/build/docs/. build/gh-pages/docs/lib
115+
cp -a jna/build/docs/. build/gh-pages/docs/jna
116+
cp -a ffm/build/docs/. build/gh-pages/docs/ffm
117+
cp -a regex/build/docs/. build/gh-pages/docs/regex
118+
97119
- name: Codecov
98120
uses: codecov/codecov-action@v4
99121
with:
100122
token: ${{ secrets.CODECOV_TOKEN }}
101123
file: build/reports/jacoco/jacocoAggregatedTestReport/jacoco.xml
102124

103-
- name: Publish
125+
- name: Upload GitHub Pages artifact
126+
uses: actions/upload-pages-artifact@v3
127+
with:
128+
path: build/gh-pages
129+
130+
- name: Publish artifacts
104131
if: ${{ github.event_name == 'push' && github.ref_name == 'main' }}
105132
env:
106133
GPG_PRIVATE_KEY: ${{ secrets.GPG_PRIVATE_KEY }}
@@ -109,3 +136,28 @@ jobs:
109136
OSSRH_USERNAME: ${{ secrets.OSSRH_USERNAME }}
110137
OSSRH_TOKEN: ${{ secrets.OSSRH_TOKEN }}
111138
run: ./gradlew publish -Ppcre4j.version=${{ github.ref_name }}-SNAPSHOT
139+
140+
publish-github-pages:
141+
if: ${{ github.event_name == 'push' && github.ref_name == 'main' }}
142+
143+
runs-on: ubuntu-latest
144+
145+
permissions:
146+
contents: read
147+
pages: write
148+
id-token: write
149+
150+
needs:
151+
- package
152+
153+
environment:
154+
name: github-pages
155+
url: ${{ steps.publish-github-pages.outputs.page_url }}
156+
157+
steps:
158+
- name: Set up Git Hub Pages
159+
uses: actions/configure-pages@v5
160+
161+
- name: Publish GitHub Pages
162+
id: publish-github-pages
163+
uses: actions/deploy-pages@v4

‎gh-pages/docs/index.md

+7
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
# PCRE4J Package Index
2+
3+
- [`org.pcre4j.api`](./api)
4+
- [`org.pcre4j.lib`](./lib)
5+
- [`org.pcre4j.jna`](./jna)
6+
- [`org.pcre4j.ffm`](./ffm)
7+
- [`org.pcre4j.regex`](./ffm)

‎gh-pages/filter.lua

+8
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
function Link(el)
2+
if string.match(el.target, "%.md") then
3+
el.target = string.gsub(el.target, "%.md", ".html")
4+
el.target = string.lower(el.target)
5+
el.target = string.gsub(el.target, "_", "-")
6+
end
7+
return el
8+
end

0 commit comments

Comments
 (0)
Please sign in to comment.