Skip to content

Commit

Permalink
Feature Support Download Of Individual Languages By Clients
Browse files Browse the repository at this point in the history
Signed-off-by: Adam Henley <[email protected]>
  • Loading branch information
adamazing committed Jul 28, 2023
1 parent 3000e6c commit ab1fb2f
Show file tree
Hide file tree
Showing 2 changed files with 30 additions and 1 deletion.
27 changes: 27 additions & 0 deletions scripts/build.sh
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,10 @@ function initialize {
export TLDRHOME=${GITHUB_WORKSPACE:-$(pwd)}
fi

if [ -z "$TLDR_LANG_ARCHIVES_DIRECTORY" ]; then
export TLDR_LANG_ARCHIVES_DIRECTORY="${GITHUB_WORKSPACE:-$(pwd)}/language_archives"
fi

export TLDR_ARCHIVE="tldr.zip"
}

Expand All @@ -24,10 +28,33 @@ function build_archive {
echo "Pages archive successfully built."
}

function build_individual_language_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
###################################

initialize
build_index
build_archive
build_individual_language_archives
4 changes: 3 additions & 1 deletion scripts/deploy.sh
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@ function initialize {
export TLDRHOME=${GITHUB_WORKSPACE:-$(pwd)}
fi

export TLDR_LANG_ARCHIVES_DIRECTORY="$TLDRHOME/language_archives"
export TLDR_ARCHIVE="tldr.zip"
export SITE_HOME="$HOME/site"
export SITE_REPO_SLUG="tldr-pages/tldr-pages.github.io"
Expand All @@ -29,12 +30,13 @@ function initialize {
function upload_assets {
git clone --quiet --depth 1 [email protected]:${SITE_REPO_SLUG}.git "$SITE_HOME"
mv -f "$TLDR_ARCHIVE" "$SITE_HOME/assets/"
mv -f "$TLDR_LANG_ARCHIVES_DIRECTORY/*" "$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"

sha256sum \
"${SITE_HOME}/assets/index.json" \
"${SITE_HOME}/assets/${TLDR_ARCHIVE}" \
"${SITE_HOME}/assets/*.zip" \
"${SITE_HOME}/assets/tldr-book.pdf" \
> "${SITE_HOME}/assets/tldr.sha256sums"

Expand Down

0 comments on commit ab1fb2f

Please sign in to comment.