Merge branch 'normalise-markup-by-default' into develop
[akkoma] / installation / download-mastofe-build.sh
1 #!/bin/sh
2 # Pleroma: A lightweight social networking server
3 # Copyright © 2017-2021 Pleroma Authors <https://pleroma.social/>
4 # SPDX-License-Identifier: AGPL-3.0-only
5 project_id="74"
6 project_branch="rebase/glitch-soc"
7 static_dir="instance/static"
8 # For bundling:
9 # project_branch="pleroma"
10 # static_dir="priv/static"
11
12 if [ ! -d "${static_dir}" ]
13 then
14 echo "Error: ${static_dir} directory is missing, are you sure you are running this script at the root of pleroma’s repository?"
15 exit 1
16 fi
17
18 last_modified="$(curl --fail -s -I 'https://git.pleroma.social/api/v4/projects/'${project_id}'/jobs/artifacts/'${project_branch}'/download?job=build' | grep '^Last-Modified:' | cut -d: -f2-)"
19
20 echo "branch:${project_branch}"
21 echo "Last-Modified:${last_modified}"
22
23 artifact="mastofe.zip"
24
25 if [ "${last_modified}x" = "x" ]
26 then
27 echo "ERROR: Couldn't get the modification date of the latest build archive, maybe it expired, exiting..."
28 exit 1
29 fi
30
31 if [ -e mastofe.timestamp ] && [ "$(cat mastofe.timestamp)" = "${last_modified}" ]
32 then
33 echo "MastoFE is up-to-date, exiting..."
34 exit 0
35 fi
36
37 curl --fail -c - "https://git.pleroma.social/api/v4/projects/${project_id}/jobs/artifacts/${project_branch}/download?job=build" -o "${artifact}" || exit
38
39 # TODO: Update the emoji as well
40 rm -fr "${static_dir}/sw.js" "${static_dir}/packs" || exit
41 unzip -q "${artifact}" || exit
42
43 cp public/assets/sw.js "${static_dir}/sw.js" || exit
44 cp -r public/packs "${static_dir}/packs" || exit
45
46 echo "${last_modified}" > mastofe.timestamp
47 rm -fr public
48 rm -i "${artifact}"