Skip to content

Commit

Permalink
(docs) GitHub Pages
Browse files Browse the repository at this point in the history
  • Loading branch information
alexey-pelykh committed Jun 21, 2024
1 parent 6027a46 commit 3fb0648
Show file tree
Hide file tree
Showing 4 changed files with 72 additions and 2 deletions.
3 changes: 3 additions & 0 deletions .editorconfig
Original file line number Diff line number Diff line change
Expand Up @@ -15,3 +15,6 @@ indent_size = 2

[*.{yml,yaml}]
indent_size = 2

[*.lua]
indent_size = 2
56 changes: 54 additions & 2 deletions .github/workflows/ci.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -76,6 +76,9 @@ jobs:
distribution: temurin
java-version: 21

- name: Set up Git Hub Pages
uses: actions/configure-pages@v5

- name: Cache Gradle packages
uses: actions/cache@v4
with:
Expand All @@ -91,16 +94,40 @@ jobs:
- name: Install PCRE
run: sudo apt-get install -y libpcre2-8-0

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

- name: Build docs
run: |
sudo apt-get install -y pandoc
mkdir -p build/gh-pages
pandoc -f gfm -t html5 -s --shift-heading-level-by=-1 --lua-filter=gh-pages/filter.lua \
-o build/gh-pages/index.html README.md
pandoc -f gfm -t html5 -s --shift-heading-level-by=-1 --lua-filter=gh-pages/filter.lua \
-o build/gh-pages/pcre2-api.html PCRE2_API.md
mkdir -p build/gh-pages/docs
pandoc -f markdown -t html5 -s --shift-heading-level-by=-1 --lua-filter=gh-pages/filter.lua \
-o build/gh-pages/docs/index.html gh-pages/docs/index.md
cp -a api/build/docs/. build/gh-pages/docs/api
cp -a lib/build/docs/. build/gh-pages/docs/lib
cp -a jna/build/docs/. build/gh-pages/docs/jna
cp -a ffm/build/docs/. build/gh-pages/docs/ffm
cp -a regex/build/docs/. build/gh-pages/docs/regex
- name: Codecov
uses: codecov/codecov-action@v4
with:
token: ${{ secrets.CODECOV_TOKEN }}
file: build/reports/jacoco/jacocoAggregatedTestReport/jacoco.xml

- name: Publish
- name: Upload GitHub Pages artifact
uses: actions/upload-pages-artifact@v3
with:
path: build/gh-pages

- name: Publish artifacts
if: ${{ github.event_name == 'push' && github.ref_name == 'main' }}
env:
GPG_PRIVATE_KEY: ${{ secrets.GPG_PRIVATE_KEY }}
Expand All @@ -109,3 +136,28 @@ jobs:
OSSRH_USERNAME: ${{ secrets.OSSRH_USERNAME }}
OSSRH_TOKEN: ${{ secrets.OSSRH_TOKEN }}
run: ./gradlew publish -Ppcre4j.version=${{ github.ref_name }}-SNAPSHOT

publish-github-pages:
if: ${{ github.event_name == 'push' && github.ref_name == 'main' }}

runs-on: ubuntu-latest

permissions:
contents: read
pages: write
id-token: write

needs:
- package

environment:
name: github-pages
url: ${{ steps.publish-github-pages.outputs.page_url }}

steps:
- name: Set up Git Hub Pages
uses: actions/configure-pages@v5

- name: Publish GitHub Pages
id: publish-github-pages
uses: actions/deploy-pages@v4
7 changes: 7 additions & 0 deletions gh-pages/docs/index.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
# PCRE4J Package Index

- [`org.pcre4j.api`](./api)
- [`org.pcre4j.lib`](./lib)
- [`org.pcre4j.jna`](./jna)
- [`org.pcre4j.ffm`](./ffm)
- [`org.pcre4j.regex`](./ffm)
8 changes: 8 additions & 0 deletions gh-pages/filter.lua
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
function Link(el)
if string.match(el.target, "%.md") then
el.target = string.gsub(el.target, "%.md", ".html")
el.target = string.lower(el.target)
el.target = string.gsub(el.target, "_", "-")
end
return el
end

0 comments on commit 3fb0648

Please sign in to comment.