Rename nightly packages to show date instead of revsion ID (#893)

Fixes https://github.com/kiwix/k8s/issues/50 for Kiwix JS.
This commit is contained in:
Jaifroid 2022-10-08 16:27:24 +01:00 committed by GitHub
parent 9a6e6f7add
commit 13afb90d95
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 23 additions and 5 deletions

View File

@ -13,6 +13,11 @@ on:
- cron: '37 1 * * *'
# Allows us to run this workflow manually from the Actions tab
workflow_dispatch:
inputs:
target:
description: Do you wish to build release or nightly?
required: false
default: 'nightly'
# A workflow run is made up of one or more jobs that can run sequentially or in parallel
jobs:
@ -51,14 +56,20 @@ jobs:
MOZILLA_API_SECRET: ${{ secrets.MOZILLA_API_SECRET }}
MOZILLA_API_KEY: ${{ secrets.MOZILLA_API_KEY }}
TAG_NAME: ${{ github.event.release.tag_name }}
CRON_LAUNCHED: ${{ github.event.schedule }}
INPUT_TARGET: ${{ github.event.inputs.target }}
shell: bash
# Switch -t indicates a tag release (public release); add -d for dry run (for testing)
# BEFORE the -v switch (because $TAG_NAME is empty for non-public builds)
run: |
# If user dispateched with "nightly", simulate a CRON run
if [ "$INPUT_TARGET" = "nightly" ]; then
CRON_LAUNCHED="nightly"
fi
# Run xvfb to make Chrome/Chromium believe it has a display. Else it fails signing the package
Xvfb -ac :99 -screen 0 1280x1024x16 &
export DISPLAY=:99
if [ "x$TAG_NAME" = "x" ]; then
if [ -z "$TAG_NAME" ]; then
./scripts/create_all_packages.sh
else
./scripts/create_all_packages.sh -t -v "$TAG_NAME"

View File

@ -24,10 +24,10 @@ if [ -r "$BASEDIR/scripts/set_secret_environment_variables.sh" ]; then
fi
# Use the passed version number, else use the commit id
if [ ! "${VERSION}zz" == "zz" ]; then
if [ -n "${VERSION}" ]; then
echo "Packaging version $VERSION because it has been passed as an argument"
VERSION_FOR_MOZILLA_MANIFEST="$VERSION"
if [ ! "${TAG}zz" == "zz" ]; then
if [ -n "${TAG}" ]; then
echo "This version is a tag : we're releasing a public version"
fi
else
@ -37,7 +37,7 @@ else
# and we have to comply with their version string : https://developer.mozilla.org/en-US/docs/Mozilla/Toolkit_version_format
# So we need to replace every number of the commit id by another string (with 32 cars max)
# We are allowed only a few special caracters : +*.-_ so we prefered to use capital letters
# (hopping this string is case-sensitive)
# (hoping this string is case-sensitive)
COMMIT_ID_FOR_MOZILLA_MANIFEST=$(echo $COMMIT_ID | tr '[0123456789]' '[ABCDEFGHIJ]')
VERSION_FOR_MOZILLA_MANIFEST="${MAJOR_NUMERIC_VERSION}commit${COMMIT_ID_FOR_MOZILLA_MANIFEST}"
echo "Packaging version $VERSION"
@ -76,10 +76,17 @@ cp -f ubuntu_touch/* tmp/
sed -i -e "s/$VERSION_TO_REPLACE/$VERSION/" tmp/manifest.json
scripts/package_ubuntu_touch_app.sh $DRYRUN $TAG -v $VERSION
if [ "${DRYRUN}zz" == "zz" ]; then
if [ -z "${DRYRUN}" ]; then
# Change permissions on source files to match those expected by the server
chmod 644 build/*
CURRENT_DATE=$(date +'%Y-%m-%d')
if [ -n "${CRON_LAUNCHED}" ]; then
# It's a nightly build, so rename files to include the date and remove extraneous info so that permalinks can be generated
for file in build/*; do
target=$(sed -E "s/-[0-9.]+commit[^.]+/_$CURRENT_DATE/" <<<"$file")
mv "$file" "$target"
done
fi
# Upload the files on master.download.kiwix.org
echo "Uploading the files on https://download.kiwix.org/nightly/$CURRENT_DATE/"
echo "mkdir /data/download/nightly/$CURRENT_DATE" | sftp -P 30022 -o StrictHostKeyChecking=no -i ./scripts/ssh_key ci@master.download.kiwix.org