-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathprepare-release-artifacts.sh
executable file
·78 lines (61 loc) · 1.8 KB
/
prepare-release-artifacts.sh
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
#!/usr/bin/bash
# This Source Code Form is subject to the terms of the Mozilla Public
# License, v. 2.0. If a copy of the MPL was not distributed with this
# file, You can obtain one at https://mozilla.org/MPL/2.0/. *)
set -e
function usage() {
echo "Usage: ${0} [-s EMAIL]" 1>&2
exit 1
}
local_user=""
while getopts "s:" o; do
case "${o}" in
s)
local_user=${OPTARG}
;;
*)
usage
;;
esac
done
function spatial_version() {
grep '^version:' spatial-shell.opam | sed 's/version: "\(.*\)"/\1/'
}
echo "Building artifacts for spatial-shell-$(spatial_version)"
if [ ! -z "$(git status -s)" ]; then
echo "You have uncommitted changes. Press enter to continue."
read
if [ ! "$?" = "0" ]; then
exit 1
fi
fi
release_name="spatial-shell-$(spatial_version)"
archive_suffix="-linux-$(uname -m).tar.gz"
worktree=$(git rev-parse --show-toplevel)
tmp_workspace="$(mktemp -d)"
if [ -f "_artifacts/${release_name}${archive_suffix}" ]; then
echo "_artifacts/${release_name}${archive_suffix} already exists. You need to delete it to run this script."
exit 2
fi
# Building a static distribution
pushd "${tmp_workspace}"
git clone -q "${worktree}" .
OCAML_COMPILER=ocaml-option-static,ocaml-option-no-compression,ocaml.5.1.1 make build-deps
eval $(opam env)
BUILD_PROFILE=static make
DESTDIR=artifacts make install
opam switch remove . -y
popd
mkdir -p _artifacts
mv "${tmp_workspace}/artifacts" "_artifacts/${release_name}"
# Creating the archive
rm -rf "${tmp_workspace}"
pushd _artifacts
tar czvf "${release_name}${archive_suffix}" "${release_name}"
rm -rf ${release_name}
if [ -n "${local_user}" ]; then
gpg --local-user "${local_user}" \
--out "${release_name}${archive_suffix}.sig" \
--detach-sig "${release_name}${archive_suffix}"
fi
popd