Skip to content

Generate docs with AsciiDoctor and deploy #91

Generate docs with AsciiDoctor and deploy

Generate docs with AsciiDoctor and deploy #91

Workflow file for this run

name: Build and Test Java 9 Jigsaw Examples
on:
push:
pull_request:
workflow_dispatch:
jobs:
build:
name: Build on ${{ matrix.os }}
runs-on: ${{ matrix.os }}
strategy:
fail-fast: false
matrix:
os: [ubuntu-latest, macos-latest, windows-latest]
steps:
- name: Disable CRLF conversion
run: git config --global core.autocrlf false
- name: Checkout repository
uses: actions/checkout@v4
- name: Install shellcheck (Ubuntu)
if: runner.os == 'Linux'
run: |
sudo apt-get update
sudo apt-get install -y shellcheck
- name: Install shellcheck (macOS)
if: runner.os == 'macOS'
run: brew install shellcheck
- name: Install shellcheck (Windows)
if: runner.os == 'Windows'
run: choco install shellcheck --no-progress
- name: Run shellcheck on shell scripts
shell: bash
run: cd jigsaw-examples && shellcheck -ax all*.sh
- name: Set up JDK 8
uses: actions/setup-java@v4
if: runner.os != 'macOS'
with:
distribution: 'temurin'
java-version: '8'
- name: Set up JDK 11
uses: actions/setup-java@v4
with:
distribution: 'temurin'
java-version: '11'
- name: Set up JDK 17
uses: actions/setup-java@v4
with:
distribution: 'temurin'
java-version: '17'
- name: Create .envrc with Java paths (Unix)
if: runner.os != 'Windows'
run: |
arch="$(uname -m | sed -e 's/aarch/arm/g' -e 's/x86_/x/g')"
if test "$(uname)" = "Darwin"; then
JAVA11_HOME="$(ls -d $RUNNER_TOOL_CACHE/Java_Temurin-Hotspot_jdk/11*/${arch}/Contents/Home)"
JAVA17_HOME="$(ls -d $RUNNER_TOOL_CACHE/Java_Temurin-Hotspot_jdk/17*/${arch}/Contents/Home)"
echo "Using Java 11 instead of Java 8 on macOS (and do not execute tests which require a genuine Java 8)"
JAVA8_HOME=$JAVA11_HOME
else
JAVA11_HOME="$(ls -d $RUNNER_TOOL_CACHE/Java_Temurin-Hotspot_jdk/11*/${arch})"
JAVA17_HOME="$(ls -d $RUNNER_TOOL_CACHE/Java_Temurin-Hotspot_jdk/17*/${arch})"
JAVA8_HOME="$(ls -d $RUNNER_TOOL_CACHE/Java_Temurin-Hotspot_jdk/8*/${arch})"
fi
cat > .envrc << EOF
# Environment configuration for Java 9 Jigsaw Examples
# Auto-generated by GitHub Actions
# Path to JDK 17 or later (required for example_gradle-project with Gradle 9.x)
export JAVA17_HOME=$JAVA17_HOME
# Path to JDK 11 (required for most examples, JDK 17 is also fine)
export JAVA_HOME=$JAVA11_HOME
# Path to JDK 8 (only needed for example_compile-target-jdk8)
export JAVA8_HOME=$JAVA8_HOME
# Add Java to PATH to ensure it is the first Java version found by any shell execution
export PATH="$JAVA_HOME/bin:$PATH"
EOF
echo "=== Created .envrc file ==="
cat .envrc
- name: Create .envrc with Java paths (Windows)
if: runner.os == 'Windows'
shell: bash
run: |
arch="x64"
JAVA8_HOME="$(cygpath -u "$(ls -d /c/hostedtoolcache/windows/Java_Temurin-Hotspot_jdk/8*/${arch})")"
JAVA11_HOME="$(cygpath -u "$(ls -d /c/hostedtoolcache/windows/Java_Temurin-Hotspot_jdk/11*/${arch})")"
JAVA17_HOME="$(cygpath -u "$(ls -d /c/hostedtoolcache/windows/Java_Temurin-Hotspot_jdk/17*/${arch})")"
cat > .envrc << EOF
# Environment configuration for Java 9 Jigsaw Examples
# Auto-generated by GitHub Actions
# Path to JDK 17 or later (required for example_gradle-project with Gradle 9.x)
export JAVA17_HOME=$JAVA17_HOME
# Path to JDK 11 (required for most examples, JDK 17 is also fine)
export JAVA_HOME=$JAVA11_HOME
# Path to JDK 8 (only needed for example_compile-target-jdk8)
export JAVA8_HOME=$JAVA8_HOME
# Add Java to PATH to ensure it is the first Java version found by any shell execution
export PATH="$JAVA_HOME/bin:$PATH"
EOF
echo "=== Created .envrc file ==="
cat .envrc
- name: Verify Java setup
shell: bash
run: |
set -eu
source .envrc
echo "=== Verifying JDK 8 ==="
PATH="$JAVA8_HOME/bin:$PATH"
java -version
echo "✓ JDK 8 is available at: $JAVA8_HOME"
echo ""
echo "=== Verifying JDK 11 ==="
PATH="$JAVA_HOME/bin:$PATH"
java -version
echo "✓ JDK 11 is available at: $JAVA_HOME"
echo ""
echo "=== Verifying JDK 17 ==="
PATH="$JAVA17_HOME/bin:$PATH"
java -version
echo "✓ JDK 17 is available at: $JAVA17_HOME"
- name: Compile all Samples
shell: bash
run: |
source .envrc
cd jigsaw-examples
./allcompile.sh
- name: Run all Samples
shell: bash
run: |
source .envrc
cd jigsaw-examples
./allrun.sh
- name: Collect failure information
if: failure()
shell: bash
run: |
echo "Environment:"
env | sort
docs:
name: Generate and Deploy Documentation
runs-on: ubuntu-latest
needs: build
if: success()
permissions:
contents: read
pull-requests: write
pages: write
id-token: write
steps:
- name: Checkout repository
uses: actions/checkout@v4
- name: Set up JDK 17
uses: actions/setup-java@v4
with:
distribution: 'temurin'
java-version: '17'
- name: Generate documentation
run: ./mvnw verify
- name: Create index.html from README.html
run: cp target/generated-docs/README.html target/generated-docs/index.html
- name: Upload documentation artifact
uses: actions/upload-artifact@v4
with:
name: generated-docs
path: target/generated-docs
retention-days: 30
- name: Deploy to Netlify (Preview)
if: github.event_name == 'pull_request'
uses: nwtgck/actions-netlify@v3
with:
publish-dir: './target/generated-docs'
production-deploy: false
github-token: ${{ secrets.GITHUB_TOKEN }}
deploy-message: "Deploy from GitHub Actions - PR #${{ github.event.pull_request.number }}"
enable-pull-request-comment: true
enable-commit-comment: false
overwrites-pull-request-comment: true
env:
NETLIFY_AUTH_TOKEN: ${{ secrets.NETLIFY_AUTH_TOKEN }}
NETLIFY_SITE_ID: ${{ secrets.NETLIFY_SITE_ID }}
- name: Deploy to Netlify (Branch Preview)
if: github.event_name == 'push' && github.ref != 'refs/heads/main'
uses: nwtgck/actions-netlify@v3
with:
publish-dir: './target/generated-docs'
production-deploy: false
github-token: ${{ secrets.GITHUB_TOKEN }}
deploy-message: "Deploy from GitHub Actions - branch ${{ github.ref_name }}"
alias: ${{ github.ref_name }}
env:
NETLIFY_AUTH_TOKEN: ${{ secrets.NETLIFY_AUTH_TOKEN }}
NETLIFY_SITE_ID: ${{ secrets.NETLIFY_SITE_ID }}
- name: Upload to GitHub Pages
if: github.event_name == 'push'
uses: actions/upload-pages-artifact@v3
with:
path: ./target/generated-docs
- name: Deploy to GitHub Pages
if: github.event_name == 'push' && github.ref == 'refs/heads/main'
uses: actions/deploy-pages@v4
id: deployment