Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feature support: provide translation archives #10555

Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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_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
###################################

initialize
build_index
build_archive
build_translation_archives
5 changes: 4 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,14 @@ 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}"/*.zip "$SITE_HOME/assets/"
rm -rf "$TLDR_LANG_ARCHIVES_DIRECTORY"
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
Loading