kiwix-js-pwa/scripts/publish_linux_packages_to_kiwix.sh
renaud gaudin 3de5c2d3a2 Fixed build uploads
Changes the destination of uploads to master.download.kiwix.org on port 30022
As this service doesn't offer a shell anymore, converted the folder creation
and file renamings to more verbose, SFTP-based scripts.
---


Former-commit-id: 4173c0fa0b793931d5e15a7d39e3a2d14063f3c2 [formerly b0cf21f9ed35aa38c1cd0270f9a6ca3ed7f61caf] [formerly ff9a715eca41430f60697e57f284e3b64523e9f3] [formerly 58f9e5893e5d47ffbf0ee2a99253320945a3537b [formerly 6e468b5130bbb35f098121b6095987c59d77f634 [formerly 9f6018b27ee96d7f86e583aab170ea7babdf09cc]]]
Former-commit-id: c23f42c726cfdc8430661f093e63f4ecadfc74a8 [formerly 98f54ef911581b8927e29b59780dc79f11da0155 [formerly 84b32b2148c8db3e936c243c1dd795e04a4f68ae]]
Former-commit-id: 4732e5bfd600646015d9ddc5598ef76487103c97 [formerly c906eb55103256bfaaa8e7b83bd63d1f7df84025]
Former-commit-id: ab83883aa1edddc293cf823ceefb150517fc44b2
2022-04-06 10:56:23 +00:00

50 lines
2.3 KiB
Bash

#!/bin/bash
# Script to upload Linux packages to download.kiwix.org
target="/data/download/release/kiwix-js-electron"
if [[ ${INPUT_TARGET} = "nightly" ]]; then
CRON_LAUNCHED="1"
fi
if [[ "qq${CRON_LAUNCHED}" != "qq" ]]; then
echo "This script was launched by the GitHub Cron proces"
CURRENT_DATE=$(date +'%Y-%m-%d')
target="/data/download/nightly/$CURRENT_DATE"
fi
echo "Uploading packages to https://download.kiwix.org$target/"
echo "mkdir ${target}" | sftp -P 30022 -o StrictHostKeyChecking=no -i ./scripts/ssh_key ci@master.download.kiwix.org
for file in ./bld/Electron/* ; do
if [[ "$file" =~ \.(AppImage|deb|rpm)$ ]]; then
directory=$(sed -E 's/[^\/]+$//' <<<"$file")
filename=$(sed -E 's/[^/]+\///g' <<<"$file")
# Convert spaces and hyphens to underscores
filename=$(sed 's/\s/_/g' <<<"$filename")
filename=$(sed 's/-/_/g' <<<"$filename")
# Remove unneeded elements
filename=$(sed -E 's/_E([_.])/\1/' <<<"$filename")
# Convert to all lowercase
filename="${filename,,}"
# Restore hyphens in app name and architecture
filename=$(sed 's/kiwix_js_electron/kiwix-js-electron/' <<<"$filename")
filename=$(sed 's/x86_64/x86-64/' <<<"$filename")
# Normalize 64bit naming convention
filename=$(sed 's/amd64/x86-64/' <<<"$filename")
# Remove spurious dot
filename=$(sed -E 's/\.(i686|x86)/_\1/' <<<"$filename")
# Swap order of architecture and release number
filename=$(sed -E 's/(electron)(.+)(_(i[36]86|x86)[^.]*)/\1\3\2/' <<<"$filename")
if [[ $filename =~ \.appimage && (! $filename =~ i386) ]]; then
filename=$(sed -E 's/(electron)(.)/\1_x86-64\2/' <<<"$filename")
fi
if [[ "qq${CRON_LAUNCHED}" != "qq" ]]; then
# Delete release number other than SHA if there is a SHA
filename=$(sed -E 's/_[0-9.]+([-_.])/\1/' <<<"$filename")
fi
# Put it all together
renamed_file="$directory$filename"
if [[ "$file" != "$renamed_file" ]]; then
mv "$file" "$renamed_file"
fi
echo "Copying $renamed_file to $target"
scp -P 30022 -o StrictHostKeyChecking=no -i ./scripts/ssh_key "$renamed_file" ci@master.download.kiwix.org:$target
fi
done