mirror of https://github.com/CrimsonTome/tldr.git
feature support: provide translation archives (#10555)
* Feature Support Download Of Individual Languages By Clients Signed-off-by: Adam Henley <adamazing@gmail.com> * Rename language archival step function Co-authored-by: Jack Lin <blueskyson1401@gmail.com> --------- Signed-off-by: Adam Henley <adamazing@gmail.com> Co-authored-by: Jack Lin <blueskyson1401@gmail.com>pull/23/head
parent
03711dd140
commit
8aacd0800b
|
@ -9,6 +9,10 @@ function initialize {
|
||||||
export TLDRHOME=${GITHUB_WORKSPACE:-$(pwd)}
|
export TLDRHOME=${GITHUB_WORKSPACE:-$(pwd)}
|
||||||
fi
|
fi
|
||||||
|
|
||||||
|
if [ -z "$TLDR_LANG_ARCHIVES_DIRECTORY" ]; then
|
||||||
|
export TLDR_LANG_ARCHIVES_DIRECTORY="${GITHUB_WORKSPACE:-$(pwd)}/language_archives"
|
||||||
|
fi
|
||||||
|
|
||||||
export TLDR_ARCHIVE="tldr.zip"
|
export TLDR_ARCHIVE="tldr.zip"
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -24,6 +28,28 @@ function build_archive {
|
||||||
echo "Pages archive successfully built."
|
echo "Pages archive successfully built."
|
||||||
}
|
}
|
||||||
|
|
||||||
|
function build_translation_archives {
|
||||||
|
local source_directory="$TLDRHOME"
|
||||||
|
local target_directory="$TLDR_LANG_ARCHIVES_DIRECTORY"
|
||||||
|
mkdir -p "$target_directory"
|
||||||
|
rm -f "$target_directory/*"
|
||||||
|
|
||||||
|
for lang_dir in "$source_directory"/pages*; do
|
||||||
|
if [ -d "$lang_dir" ]; then
|
||||||
|
local lang=$(basename "$lang_dir")
|
||||||
|
local archive_name="tldr-$lang.zip"
|
||||||
|
|
||||||
|
# Create the zip archive
|
||||||
|
|
||||||
|
cd "$lang_dir"
|
||||||
|
zip -q -r "$target_directory/$archive_name" .
|
||||||
|
zip -q -j "$target_directory/$archive_name" "$source_directory/LICENSE.md"
|
||||||
|
|
||||||
|
echo "Pages archive of $archive_name successfully created."
|
||||||
|
fi
|
||||||
|
done
|
||||||
|
}
|
||||||
|
|
||||||
###################################
|
###################################
|
||||||
# MAIN
|
# MAIN
|
||||||
###################################
|
###################################
|
||||||
|
@ -31,3 +57,4 @@ function build_archive {
|
||||||
initialize
|
initialize
|
||||||
build_index
|
build_index
|
||||||
build_archive
|
build_archive
|
||||||
|
build_translation_archives
|
||||||
|
|
|
@ -9,6 +9,7 @@ function initialize {
|
||||||
export TLDRHOME=${GITHUB_WORKSPACE:-$(pwd)}
|
export TLDRHOME=${GITHUB_WORKSPACE:-$(pwd)}
|
||||||
fi
|
fi
|
||||||
|
|
||||||
|
export TLDR_LANG_ARCHIVES_DIRECTORY="$TLDRHOME/language_archives"
|
||||||
export TLDR_ARCHIVE="tldr.zip"
|
export TLDR_ARCHIVE="tldr.zip"
|
||||||
export SITE_HOME="$HOME/site"
|
export SITE_HOME="$HOME/site"
|
||||||
export SITE_REPO_SLUG="tldr-pages/tldr-pages.github.io"
|
export SITE_REPO_SLUG="tldr-pages/tldr-pages.github.io"
|
||||||
|
@ -29,12 +30,14 @@ function initialize {
|
||||||
function upload_assets {
|
function upload_assets {
|
||||||
git clone --quiet --depth 1 git@github.com:${SITE_REPO_SLUG}.git "$SITE_HOME"
|
git clone --quiet --depth 1 git@github.com:${SITE_REPO_SLUG}.git "$SITE_HOME"
|
||||||
mv -f "$TLDR_ARCHIVE" "$SITE_HOME/assets/"
|
mv -f "$TLDR_ARCHIVE" "$SITE_HOME/assets/"
|
||||||
|
mv -f "${TLDR_LANG_ARCHIVES_DIRECTORY}"/*.zip "$SITE_HOME/assets/"
|
||||||
|
rm -rf "$TLDR_LANG_ARCHIVES_DIRECTORY"
|
||||||
cp -f "$TLDRHOME/index.json" "$SITE_HOME/assets/"
|
cp -f "$TLDRHOME/index.json" "$SITE_HOME/assets/"
|
||||||
cp -f "${TLDRHOME}/scripts/pdf/tldr-pages.pdf" "${SITE_HOME}/assets/tldr-book.pdf"
|
cp -f "${TLDRHOME}/scripts/pdf/tldr-pages.pdf" "${SITE_HOME}/assets/tldr-book.pdf"
|
||||||
|
|
||||||
sha256sum \
|
sha256sum \
|
||||||
"${SITE_HOME}/assets/index.json" \
|
"${SITE_HOME}/assets/index.json" \
|
||||||
"${SITE_HOME}/assets/${TLDR_ARCHIVE}" \
|
"${SITE_HOME}/assets/"*.zip \
|
||||||
"${SITE_HOME}/assets/tldr-book.pdf" \
|
"${SITE_HOME}/assets/tldr-book.pdf" \
|
||||||
> "${SITE_HOME}/assets/tldr.sha256sums"
|
> "${SITE_HOME}/assets/tldr.sha256sums"
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue