-
Notifications
You must be signed in to change notification settings - Fork 19
/
publish.bash
53 lines (38 loc) · 1.54 KB
/
publish.bash
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
#!/usr/bin/env bash
set -e -u -x
# binary-name should not contains spaces.
# paths should be absolute.
# local-temp-clone-path contents will be deleted.
if [ "$#" -ne 4 ]; then
echo "required arguments: binary-name local-binary-path local-buildinfo-path local-temp-clone-path"
exit 1
fi
binary_name=$1
local_binary_path=$2
local_buildinfo_path=$3
local_temp_clone_path=$4
repo=https://github.com/Psiphon-Labs/psiphon-tunnel-core-binaries.git
# Always start from a clean psiphon-tunnel-core-binaries clone. Limit history depth
# to limit download size and required disk space.
rm -rf $local_temp_clone_path
git clone --depth 1 $repo $local_temp_clone_path
# By convention, psiphon-tunnel-core buildinfo files record the rev on the 3rd line.
buildrev=$(cat "${local_buildinfo_path}" | head -n 3 | tail -n 1)
commit_message="${binary_name} $buildrev"
cd "${local_temp_clone_path}"
# With cloned history depth of 1, this only checks if the most recent build was the same rev.
if [ $(git log | grep "$commit_message" | wc -l) == 1 ]; then
echo "existing binary commit found, skipping publication"
exit 0
fi
mkdir -p "./${binary_name}"
cp "${local_binary_path}" "./${binary_name}"
git add "./${binary_name}"
# Use --allow-empty: if the binary happens to be identical to the previous commit, still
# push the new rev.
git commit --allow-empty --message="$commit_message"
# Set a large HTTP POST buffer to accommodate pushing large files.
git config http.postBuffer 209715200
git push origin master
rm -rf "${local_temp_clone_path}"
echo "publish finished"