-
Notifications
You must be signed in to change notification settings - Fork 0
/
build.zsh
executable file
·61 lines (45 loc) · 1.96 KB
/
build.zsh
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
#!/bin/zsh
#===================================================
# This script generates the repositories
#===================================================
# To use with another project, change this string and reprepro/conf/distributions
REPO_LATEST_API="https://api.github.com/repos/shiftkey/desktop/releases/latest"
# Get folder that this script is in
SCRIPT_DIR=${0:a:h}
# Use packaged binaries if possible
PATH="$SCRIPT_DIR/usr/bin:$PATH"
# Folder where we store downloads json and version file
STAGING_DIR="${SCRIPT_DIR}/staging"
# Get function for creating deb/rpm repos
. "${SCRIPT_DIR}/functions.zsh"
# exit on first error
set -e
#===================================================
# Get Info About Latest Release
#===================================================
# Retreive json file describing latest release
wget -qO "${STAGING_DIR}/latest.json" "${REPO_LATEST_API}" || {date_time_echo "json download failed"; exit 1}
# Get the new ID
LATEST_ID=$(jq -r '.id' "${STAGING_DIR}/latest.json")
# Only continue if the latest release ID is different from the ID in staging/version
if [[ -f "${STAGING_DIR}/version" ]] {
if [[ "${LATEST_ID}" == $(<"${STAGING_DIR}/version") ]] {
date_time_echo "Already latest version (${LATEST_ID}).\n"
exit 0
} else {
date_time_echo "Adding version ${LATEST_ID}."
}
} else {
date_time_echo "Adding version ${LATEST_ID}. No prior version found."
}
#===================================================
# START Update
#===================================================
cd "${STAGING_DIR}"
make_repos "${STAGING_DIR}/latest.json" "${SCRIPT_DIR}/reprepro/conf" "${SCRIPT_DIR}/dist/rpm" || exit 1
#===================================================
# POST Update
#===================================================
# Write version number so that the loop will not repeat until a new version is released
echo "${LATEST_ID}" > "${STAGING_DIR}/version" &&
date_time_echo "Current version is now ${LATEST_ID}!\n"