-
Notifications
You must be signed in to change notification settings - Fork 3
Expand file tree
/
Copy pathdeploy
More file actions
executable file
·120 lines (103 loc) · 2.77 KB
/
deploy
File metadata and controls
executable file
·120 lines (103 loc) · 2.77 KB
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
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
#!/bin/bash
#
# Stage and deploy a previously built Zotero version
#
# Updates local manifest files to include the new version, then runs DEPLOY_CMD
# (from config.inc.php) to push the changes live.
#
# Can be run locally on the server or remotely via SSH:
# ssh deploy.zotero /path/to/deploy release 9.0.1 mwl
#
set -euo pipefail
SCRIPT_DIR="$( cd "$( dirname "${BASH_SOURCE[0]}" )" && pwd )"
MANIFESTS_DIR="$SCRIPT_DIR/manifests"
DEPLOY_CMD=$(php -r "require('$SCRIPT_DIR/config.inc.php'); echo \$DEPLOY_CMD;")
function usage {
cat >&2 <<DONE
Usage: $0 CHANNEL VERSION PLATFORMS
CHANNEL Release channel ('release', 'beta', 'dev')
VERSION Version number (e.g., '9.0.1', '9.0.1-beta.3+abc123')
PLATFORMS Platforms to deploy (m=Mac, w=Windows, l=Linux)
DONE
exit 1
}
CHANNEL="${1:-}"
VERSION="${2:-}"
PLATFORMS="${3:-}"
if [[ -z "$CHANNEL" ]] || [[ -z "$VERSION" ]] || [[ -z "$PLATFORMS" ]]; then
usage
fi
CHANNEL_DIR="$MANIFESTS_DIR/$CHANNEL"
VERSION_DIR="$CHANNEL_DIR/$VERSION"
if [ ! -d "$VERSION_DIR" ]; then
echo "Error: $VERSION_DIR not found -- has the build been uploaded?" >&2
exit 1
fi
SHORT_VERSION="${VERSION:0:3}"
# Stage: update local manifest files
for i in `seq 0 1 $((${#PLATFORMS}-1))`
do
case ${PLATFORMS:i:1} in
m)
os_name="mac"
architectures="mac"
;;
w)
os_name="win"
architectures="win32 win-x64 win-arm64"
;;
l)
os_name="linux"
architectures="linux-i686 linux-x86_64 linux-arm64"
;;
*)
echo "Invalid platform option: ${PLATFORMS:i:1}" >&2
usage
;;
esac
# Read build ID from build-{os}.json
build_json="$VERSION_DIR/build-${os_name}.json"
if [ ! -f "$build_json" ]; then
echo "Error: $build_json not found" >&2
exit 1
fi
BUILD_ID=$(python3 -c "import json; print(json.load(open('$build_json'))['buildID'])")
for arch in $architectures; do
jsonfile="$CHANNEL_DIR/updates-$arch.json"
if [ ! -f "$jsonfile" ]; then
echo "Error: $jsonfile not found" >&2
exit 1
fi
echo "Updating $jsonfile"
# Back up the file
cp "$jsonfile" "$jsonfile.bak"
# Add new version entry, keep last 5
python3 -c "
import json, sys
with open('$jsonfile') as f:
updates = json.load(f)
updates.append({
'version': '$VERSION',
'buildID': '$BUILD_ID',
'detailsURL': 'https://www.zotero.org/support/${SHORT_VERSION}_changelog',
'major': None
})
updates = updates[-5:]
with open('$jsonfile', 'w') as f:
json.dump(updates, f, indent=2)
f.write('\n')
"
done
# Add version to incrementals list
incr_file="$CHANNEL_DIR/incrementals-$os_name"
echo "Adding $VERSION to $incr_file"
echo "$VERSION" >> "$incr_file"
done
# Deploy: push changes live
if [ -n "${DEPLOY_CMD:-}" ]; then
echo
echo "Deploying..."
$DEPLOY_CMD
fi
echo
echo "Deployed $VERSION on channel $CHANNEL for platforms $PLATFORMS"