You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@avro.apache.org by mg...@apache.org on 2023/04/13 11:10:39 UTC

[avro] 01/01: AVRO-3686: Update the website on changes in doc/ folder in master branch

This is an automated email from the ASF dual-hosted git repository.

mgrigorov pushed a commit to branch update-site
in repository https://gitbox.apache.org/repos/asf/avro.git

commit d2b9937dadc0563f2cbcbc613828e95be006fe85
Author: Martin Tzvetanov Grigorov <mg...@apache.org>
AuthorDate: Wed Apr 12 14:31:34 2023 +0300

    AVRO-3686: Update the website on changes in doc/ folder in master branch
    
    Signed-off-by: Martin Tzvetanov Grigorov <mg...@apache.org>
---
 .github/workflows/docs.yaml | 221 ++++++++++++++++++++++++++++++++++++++++++++
 lang/c/build.sh             |   5 +
 2 files changed, 226 insertions(+)

diff --git a/.github/workflows/docs.yaml b/.github/workflows/docs.yaml
new file mode 100644
index 000000000..e34e7a21e
--- /dev/null
+++ b/.github/workflows/docs.yaml
@@ -0,0 +1,221 @@
+name: Deploy Avro site
+
+on:
+  push:
+    branches:
+      - master
+    paths:
+      - .github/workflows/docs.yaml
+      - doc/**
+
+concurrency:
+  group: ${{ github.workflow }}-${{ github.ref }}
+  cancel-in-progress: true
+
+jobs:
+  build-website:
+    name: Build website
+    runs-on: ubuntu-latest
+    steps:
+      - name: Checkout docs sources
+        uses: actions/checkout@v3
+        with:
+          submodules: recursive
+
+      - uses: actions/setup-node@v3
+        with:
+          node-version: 16
+
+      - name: Install NPM dependencies
+        run: |
+          set -x
+          cd doc
+          npm install
+
+      - name: Setup Hugo
+        uses: peaceiris/actions-hugo@v2
+        with:
+          hugo-version: 0.111.3
+          extended: true
+
+      - name: Build docs
+        run: |
+          set -x
+          cd doc
+          hugo --minify --destination ../website --baseURL=/
+
+      - uses: actions/upload-artifact@v3
+        with:
+          name: website
+          path: website
+
+  build-api-c:
+    name: Build C API docs
+    runs-on: ubuntu-latest
+    steps:
+      - name: Checkout
+        uses: actions/checkout@v3
+
+      - name: Build C docs
+        run: |
+          set -x
+          sudo apt-get update -q
+          sudo apt-get install -q -y cmake liblzma-dev libsnappy-dev libjansson-dev zlib1g-dev pkg-config asciidoc source-highlight libsource-highlight-dev
+          cd lang/c
+          ./build.sh clean docs
+
+      - uses: actions/upload-artifact@v3
+        with:
+          name: api-c
+          path: build/c/docs
+
+  build-api-cpp:
+    name: Build C++ API docs
+    runs-on: ubuntu-latest
+    steps:
+      - name: Checkout
+        uses: actions/checkout@v3
+
+      - name: Build C++ docs
+        run: |
+          set -x
+          sudo apt-get update -q
+          sudo apt-get install -q -y gcc g++ libboost-all-dev cmake doxygen
+          cd lang/c++
+          ./build.sh clean doc
+
+      - uses: actions/upload-artifact@v3
+        with:
+          name: api-c++
+          path: lang/c++/doc/html
+
+  build-api-csharp:
+    name: Build C# API docs
+    runs-on: ubuntu-latest
+    steps:
+      - name: Checkout
+        uses: actions/checkout@v3
+
+      - name: Build C# docs
+        run: |
+          set -x
+          sudo apt-get update -q
+          sudo apt-get install -q -y wget libzstd-dev libicu-dev doxygen
+          sudo wget https://dot.net/v1/dotnet-install.sh
+          bash ./dotnet-install.sh --channel "7.0" --install-dir "$HOME/.dotnet"
+          cd lang/csharp
+          mkdir -p build/doc
+          doxygen Avro.dox
+
+      - uses: actions/upload-artifact@v3
+        with:
+          name: api-csharp
+          path: lang/csharp/build/doc/html
+
+  build-api-java:
+    name: Build Java API docs
+    runs-on: ubuntu-latest
+    steps:
+      - name: Checkout
+        uses: actions/checkout@v3
+
+      - name: Cache Local Maven Repository
+        uses: actions/cache@v3
+        with:
+          path: ~/.m2/repository
+          key: ${{ runner.os }}-maven-${{ hashFiles('**/pom.xml') }}
+          restore-keys: |
+            ${{ runner.os }}-maven-
+
+      - name: Setup Temurin JDK
+        uses: actions/setup-java@v3
+        with:
+          distribution: 'temurin'
+          java-version: 8
+
+      - name: Build Java docs
+        run: |
+          set -x
+          cd lang/java
+          mvn javadoc::aggregate
+
+      - uses: actions/upload-artifact@v3
+        with:
+          name: api-java
+          path: lang/java/target/site/apidocs
+
+  push-website:
+    name: Push website
+    needs: [build-website, build-api-c, build-api-cpp, build-api-csharp, build-api-java]
+    runs-on: ubuntu-latest
+    steps:
+      - name: Checkout asf-site branch
+        uses: actions/checkout@v3
+        with:
+          ref: asf-site
+          path: asf-site
+
+      - name: Download website
+        uses: actions/download-artifact@v3
+        with:
+          name: website
+          path: website
+
+      - name: Download api-c
+        uses: actions/download-artifact@v3
+        with:
+          name: api-c
+          path: api-c
+
+      - name: Download api-c++
+        uses: actions/download-artifact@v3
+        with:
+          name: api-c++
+          path: api-c++
+
+      - name: Download api-csharp
+        uses: actions/download-artifact@v3
+        with:
+          name: api-csharp
+          path: api-csharp
+
+      - name: Download api-java
+        uses: actions/download-artifact@v3
+        with:
+          name: api-java
+          path: api-java
+
+      - name: Copy & push the generated HTML
+        run: |
+          set -x
+
+          mkdir -p website/docs/++version++/api/c
+          mkdir -p website/docs/++version++/api/cpp/html
+          mkdir -p website/docs/++version++/api/csharp/html
+          mkdir -p website/docs/++version++/api/java
+
+          mv api-c/* website/docs/++version++/api/c/
+          mv api-c++/* website/docs/++version++/api/cpp/html/
+          mv api-csharp/* website/docs/++version++/api/csharp/html/
+          mv api-java/* website/docs/++version++/api/java/
+          rmdir api-c api-c++ api-csharp api-java
+
+          cd asf-site
+          rsync \
+            -a \
+            --delete \
+            --exclude '/.git/' \
+            ../website/ \
+            ./
+          echo "publish:
+                  whoami: asf-site
+                  " > .asf.yaml
+          touch .nojekyll
+          git status --porcelain
+          if [ "$(git status --porcelain)" != "" ]; then
+            git config user.name "github-actions[bot]"
+            git config user.email "github-actions[bot]@users.noreply.github.com"
+            git add --all
+            git commit -m 'Publish built docs triggered by ${{ github.sha }}'
+            git push || git push --force
+          fi
diff --git a/lang/c/build.sh b/lang/c/build.sh
index 6753e778d..5464ef3fd 100755
--- a/lang/c/build.sh
+++ b/lang/c/build.sh
@@ -69,6 +69,11 @@ do
       make -C $build_dir test
       ;;
 
+    docs)
+      prepare_build
+      make -C $build_dir docs
+      ;;
+
     dist)
       prepare_build
       cp ../../share/VERSION.txt $root_dir