Skip to content

Commit

Permalink
Fixing documentation workflow (#2594)
Browse files Browse the repository at this point in the history
* Polish documentation workflow

* Use GitHub Actions output

* Remove unnecessary download-artifact step

* Increase memory size for Java
  • Loading branch information
franciscodr committed Dec 23, 2021
1 parent 91bcc55 commit 88aece9
Show file tree
Hide file tree
Showing 16 changed files with 120 additions and 117 deletions.
19 changes: 0 additions & 19 deletions .github/scripts/publish-latest-release.sh

This file was deleted.

38 changes: 0 additions & 38 deletions .github/scripts/set-env.sh

This file was deleted.

8 changes: 0 additions & 8 deletions .github/scripts/show-env.sh

This file was deleted.

17 changes: 17 additions & 0 deletions .github/scripts/sync-docs-with-aws.sh
@@ -0,0 +1,17 @@
#!/bin/bash

# Reason: it's not possible to sync all the directories because of 'docs/0.10', 'docs/next', etc.
# and latest release appears in the root directory

set -e

cd _site/
for file in *; do
if [ -f "$file" ]; then
echo "Copying $file ..."
aws s3 cp $file s3://$S3_BUCKET/docs/$file --exclude "/CNAME" --exclude "/code/*" --exclude "/index.html" --exclude "/redirects.json" >> $BASEDIR/logs/aws_sync.log
continue
fi
echo "Sync $file ..."
aws s3 sync $file s3://$S3_BUCKET/docs/$file --delete --exclude "/CNAME" --exclude "/code/*" --exclude "/index.html" --exclude "/redirects.json" >> $BASEDIR/logs/aws_sync.log
done
@@ -1,18 +1,19 @@
#!/bin/bash

# Reason: The root directory also has docs/, docs/next/ and docs/<major.minor>.
# Reason: it's not possible to sync all the directories because of 'docs/0.10', 'docs/next', etc.
# and latest release appears in the root directory

set -e

MAIN_CONTENT=("CNAME" "code" "css" "error.html" "fonts" "img" "index.html" "js" "redirects.json")

cd _site/
for file in ${MAIN_CONTENT[*]}; do

for file in *; do
if [ -f "$file" ]; then
echo "Copying $file ..."
aws s3 cp $file s3://$S3_BUCKET/$file >> $BASEDIR/logs/aws_sync.log
continue
fi

echo "Sync $file ..."
aws s3 sync $file s3://$S3_BUCKET/$file --delete >> $BASEDIR/logs/aws_sync.log
done
84 changes: 49 additions & 35 deletions .github/workflows/publish.yml
Expand Up @@ -31,6 +31,9 @@ jobs:
matrix:
os: [ 'macos-latest', 'ubuntu-latest', 'windows-latest' ]

outputs:
arrow-version: ${{ steps.get-arrow-version.outputs.arrow-version }}

steps:
- name: Checkout
uses: actions/checkout@v2.4.0
Expand Down Expand Up @@ -58,6 +61,10 @@ jobs:
- name: Build
run: ./gradlew build

- id: get-arrow-version
name: Get Arrow version
run: echo "::set-output name=arrow-version::$(head -n 1 build/semver/version.txt| cut -d. -f1-2)"

- name: Stop Gradle daemons
run: ./gradlew --stop

Expand Down Expand Up @@ -114,85 +121,92 @@ jobs:
S3_BUCKET: ${{ secrets.S3_BUCKET }}

steps:
- uses: actions/checkout@v2
- name: Checkout
uses: actions/checkout@v2.4.0
with:
fetch-depth: 0

- name: "Setup"
run: brew install grep
- name: Set up Java
uses: actions/setup-java@v2.4.0
with:
distribution: 'zulu'
java-version: 11

- name: Set version to an environment variable
run: echo "lib_version=$(head -n 1 build/semver/version.txt)" >> $GITHUB_ENV
run: echo "LIB_VERSION=${{needs.build.outputs.arrow-version}}" >> $GITHUB_ENV

- name: "Prepare environment"
- name: Prepare environment
working-directory: arrow-site
run: |
mkdir $BASEDIR/logs
brew install tree
bundle config set --local path 'vendor/bundle'
bundle install --gemfile Gemfile
- name: "Create API doc"
- name: Create API doc
run: ./gradlew dokkaGfm

- name: "Landing page: build"
- name: Build landing page
working-directory: arrow-site
if: ${{ github.ref == 'refs/heads/main' && !contains(env.lib_version, "alpha") && !contains(env.lib_version, "beta") && !contains(env.lib_version, "rc") }}
if: ${{ github.ref == 'refs/heads/main' }}
run: |
bundle exec jekyll build -b docs -s docs
bundle exec jekyll build -b docs -s docs --config docs/_config_for_landing_page.yml
tree _site > $BASEDIR/logs/content.log
- name: "Landing page: publish"
- name: Publish landing page
working-directory: arrow-site
if: ${{ github.ref == 'refs/heads/main' && !contains(env.lib_version, "alpha") && !contains(env.lib_version, "beta") && !contains(env.lib_version, "rc") }}
if: ${{ github.ref == 'refs/heads/main' }}
run: |
echo ">>> Landing page" >> $BASEDIR/logs/aws_sync.log
${GITHUB_WORKSPACE}/.github/scripts/publish-landing-page.sh
${GITHUB_WORKSPACE}/.github/scripts/sync-main-with-aws.sh
- name: "Latest release: publish (/docs)"
- name: Build release directory (/docs)
working-directory: arrow-site
if: ${{ github.ref == 'refs/heads/main' && !contains(env.lib_version, "alpha") && !contains(env.lib_version, "beta") && !contains(env.lib_version, "rc") }}
if: ${{ github.ref == 'refs/heads/main' && !contains(env.LIB_VERSION, "alpha") && !contains(env.LIB_VERSION, "beta") && !contains(env.LIB_VERSION, "rc") }}
run: |
bundle exec jekyll build -b docs -s docs
tree _site > $BASEDIR/logs/content_docs-${{ env.LIB_VERSION }}.log
- name: Publish documentation (/docs)
working-directory: arrow-site
if: ${{ github.ref == 'refs/heads/main' && !contains(env.LIB_VERSION, "alpha") && !contains(env.LIB_VERSION, "beta") && !contains(env.LIB_VERSION, "rc") }}
run: |
echo ">>> Latest release" >> $BASEDIR/logs/aws_sync.log
${GITHUB_WORKSPACE}/.github/scripts/publish-latest-release.sh
${GITHUB_WORKSPACE}/.github/scripts/sync-docs-with-aws.sh
- name: "Latest release: build release directory (/docs/<major.minor.patch>)"
if: ${{ github.ref == 'refs/heads/main' && !contains(env.lib_version, "alpha") && !contains(env.lib_version, "beta") && !contains(env.lib_version, "rc") }}
- name: Build release directory (/docs/<major.minor>)
working-directory: arrow-site
if: ${{ github.ref == 'refs/heads/main' && !contains(env.LIB_VERSION, "alpha") && !contains(env.LIB_VERSION, "beta") && !contains(env.LIB_VERSION, "rc") }}
run: |
bundle exec jekyll build -b docs/${{ env.lib_version }} -s docs
tree _site > $BASEDIR/logs/content_docs-${{ env.lib_version }}.log
bundle exec jekyll build -b docs/${{ env.LIB_VERSION }} -s docs
tree _site > $BASEDIR/logs/content_docs-${{ env.LIB_VERSION }}.log
- name: "Latest release: publish release directory (/docs/<major.minor.patch>)"
if: ${{ github.ref == 'refs/heads/main' && !contains(env.lib_version, "alpha") && !contains(env.lib_version, "beta") && !contains(env.lib_version, "rc") }}
- name: Publish release directory (/docs/<major.minor>)
working-directory: arrow-site
if: ${{ github.ref == 'refs/heads/main' && !contains(env.LIB_VERSION, "alpha") && !contains(env.LIB_VERSION, "beta") && !contains(env.LIB_VERSION, "rc") }}
run: |
if [ "${{ env.lib_version }}" != "" ]; then
aws s3 sync _site s3://$S3_BUCKET/docs/${{ env.lib_version }} --delete --exclude "index.html" >> $BASEDIR/logs/aws_sync.log
else
exit 1
fi
aws s3 sync _site s3://$S3_BUCKET/docs/${{ env.LIB_VERSION }} --delete --exclude "/CNAME" --exclude "/code/*" --exclude "/index.html" --exclude "/redirects.json" >> $BASEDIR/logs/aws_sync.log
- name: "Next version: build (/docs/next)"
- name: Build latest version (/docs/next)
working-directory: arrow-site
if: ${{ github.ref == 'refs/heads/main' && contains(env.lib_version, "alpha") }}
if: ${{ github.ref == 'refs/heads/main' }}
run: |
bundle exec jekyll build -b docs/next -s docs
tree _site > $BASEDIR/logs/content_docs-next.log
- name: "Next version: publish (/docs/next)"
- name: Publish latest version (/docs/next)
working-directory: arrow-site
if: ${{ github.ref == 'refs/heads/main' && contains(env.lib_version, "alpha") }}
if: ${{ github.ref == 'refs/heads/main' }}
run: |
aws s3 sync _site s3://$S3_BUCKET/docs/next --delete --exclude "index.html" >> $BASEDIR/logs/aws_sync.log
aws s3 sync _site s3://$S3_BUCKET/docs/next --delete --exclude "/CNAME" --exclude "/code/*" --exclude "/index.html" --exclude "/redirects.json" >> $BASEDIR/logs/aws_sync.log
- name: "Site: publish sitemap.xml"
if: ${{ github.ref == 'refs/heads/main' && !contains(env.lib_version, "alpha") && !contains(env.lib_version, "beta") && !contains(env.lib_version, "rc") }}
- name: Publish sitemap.xml
if: ${{ github.ref == 'refs/heads/main' && !contains(env.LIB_VERSION, "alpha") && !contains(env.LIB_VERSION, "beta") && !contains(env.LIB_VERSION, "rc") }}
run: |
${GITHUB_WORKSPACE}/.github/scripts/create-sitemap.sh > sitemap.xml
aws s3 cp sitemap.xml s3://$S3_BUCKET/sitemap.xml >> $BASEDIR/logs/aws_sync.log
- name: CloudFront cache invalidation
- name: Invalidate CloudFront cache
run: aws cloudfront create-invalidation --distribution-id $AWS_CLOUDFRONT_ID --paths "/*"

- name: List S3
Expand All @@ -201,7 +215,7 @@ jobs:
- uses: actions/upload-artifact@v2
with:
name: logs
path: arrow-libs/logs
path: arrow-libs/logs.

- name: Stop Gradle daemons
run: ./gradlew --stop
2 changes: 1 addition & 1 deletion .github/workflows/pull_request.yml
Expand Up @@ -3,7 +3,7 @@ name: "pull_request"
on: pull_request

env:
JAVA_OPTS: -Xms1g -Xmx3g
JAVA_OPTS: -Xms2g -Xmx4g
GRADLE_OPTS: "-Dorg.gradle.daemon=false -Dorg.gradle.configureondemand=true -Dorg.gradle.jvmargs=-Xmx3g -XX:MaxPermSize=512m -XX:+HeapDumpOnOutOfMemoryError -Dfile.encoding=UTF-8"

jobs:
Expand Down
36 changes: 36 additions & 0 deletions arrow-site/docs/_config_for_landing_page.yml
@@ -0,0 +1,36 @@
title: Arrow
#-------------------------
name: Λrrow
#-------------------------
description: Functional companion to Kotlin's Standard Library
#-------------------------
author: The Λrrow Authors
keywords: functional-programming, kotlin-library, monads, monad-transformers, functional-data-structure, kotlin, fp-types, adt, free-monads, tagless-final, mtl, for-comprehension, category-theory
#-------------------------
url: https://arrow-kt.io
#-------------------------
github_repo: https://github.com/arrow-kt/arrow
#-------------------------
twitter_handle: "@arrow_kt"
#-------------------------
slack_kotlin_channel: "https://slack.kotlinlang.org"
slack_arrow_channel: "https://kotlinlang.slack.com/archives/C5UPMM0A0"
#-------------------------
sass:
style: compressed
#-------------------------
exclude: ['config.ru', 'Gemfile', 'Gemfile.lock', 'vendor', 'Procfile', 'Rakefile', '.bundle', 'apidocs/', 'docs/', 'css/docs-styles.scss', 'img/core/', 'img/docs/', 'img/fx/', 'img/incubator/', 'img/kotlin-stdlib.png', 'img/labels/', 'img/linting/', 'img/meta/', 'img/old-design/', 'img/optics/', 'img/quickstart/']
#-------------------------
collections:
code:
output: true
# Default Front Matter values to be set
defaults:
- scope:
type: code
values:
layout: code

# Plugins
plugins:
- jekyll-redirect-from
4 changes: 2 additions & 2 deletions arrow-site/docs/docs/core/README.md
Expand Up @@ -80,12 +80,12 @@ boilerplate and enable direct syntax including [monad comprehensions and computa
Configure Arrow for your project
<div class="setup-jdk-android" markdown="1">
<div class="jdk-item" markdown="1">
![Jdk](/img/quickstart/jdk-logo.svg "jdk")
![Jdk]({{ "/img/quickstart/jdk-logo.svg" | relative_url }} "jdk")

Make sure to have the latest version of JDK 1.8 installed.
</div>
<div class="android-item" markdown="1">
![Android](/img/quickstart/android-logo.svg "android")
![Android]({{ "/img/quickstart/android-logo.svg" | relative_url }} "android")

<!--- Module Libraries -->
Arrow supports Android starting on API 21 and up.
Expand Down
4 changes: 2 additions & 2 deletions arrow-site/docs/docs/fx/README.md
Expand Up @@ -79,12 +79,12 @@ s [Coroutines Guide](https://kotlinlang.org/docs/coroutines-guide.html) on Kotli
Configure Arrow for your project
<div class="setup-jdk-android" markdown="1">
<div class="jdk-item" markdown="1">
![Jdk](/img/quickstart/jdk-logo.svg "jdk")
![Jdk]({{ "/img/quickstart/jdk-logo.svg" | relative_url }} "jdk")

Make sure to have the latest version of JDK 1.8 installed.
</div>
<div class="android-item" markdown="1">
![Android](/img/quickstart/android-logo.svg "android")
![Android]({{ "/img/quickstart/android-logo.svg" | relative_url }} "android")

<!--- Module Libraries -->
Arrow supports Android starting on API 21 and up.
Expand Down
4 changes: 2 additions & 2 deletions arrow-site/docs/docs/optics/README.md
Expand Up @@ -81,12 +81,12 @@ traversing deep values in sealed and data classes models.s
Configure Arrow for your project
<div class="setup-jdk-android" markdown="1">
<div class="jdk-item" markdown="1">
![Jdk](/img/quickstart/jdk-logo.svg "jdk")
![Jdk]({{ "/img/quickstart/jdk-logo.svg" | relative_url }} "jdk")

Make sure to have the latest version of JDK 1.8 installed.
</div>
<div class="android-item" markdown="1">
![Android](/img/quickstart/android-logo.svg "android")
![Android]({{ "/img/quickstart/android-logo.svg" | relative_url }} "android")

<!--- Module Libraries -->
Arrow supports Android starting on API 21 and up.
Expand Down

0 comments on commit 88aece9

Please sign in to comment.