forked from Solo5/solo5
-
Notifications
You must be signed in to change notification settings - Fork 2
/
Copy pathopam-release.sh
executable file
·68 lines (60 loc) · 2.26 KB
/
opam-release.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
#!/bin/sh
#
# This script is used to generate OPAM metadata for publishing a Solo5 release
# to ocaml/opam-repository. It should be run from the root of a clean, tagged
# Solo5 git repository.
# From Makefile.commmon, the '-Werror' should be removed for the tag of the
# release, to avoid failures with future C compilers (which may add new
# warnings).
if [ ! -d "./opam" ]; then
echo "ERROR: missing ./opam. Run this from the root of a Solo5 repository."
exit 1
fi
GIT_VERSION=$(git -C . describe --dirty --tags --always)
DEV=
if ! echo "$GIT_VERSION" | egrep -q '^v[0-9]+.[0-9]+.[0-9]+$'; then
echo "WARNING: Not a clean Git release: $GIT_VERSION"
echo "WARNING: This is almost certainly not what you want."
DEV=~dev
fi
WERROR=$(git grep -c ' -Werror' Makefile.common | cut -d ':' -f 2)
if [ "$WERROR" -gt 0 ]; then
echo "ERROR: There are occurences of '-Werror' in 'Makefile.common'."
echo "ERROR: This is almost certainly not what you want."
exit 1
fi
TARBALL="solo5-${GIT_VERSION}.tar.gz"
if [ ! -f ${TARBALL} ]; then
echo "ERROR: Release tarball ${TARBALL} not found."
echo "ERROR: Did you run 'make distrib'?"
exit 1
fi
echo "Using tarball: ${TARBALL}"
CHECKSUM="$(sha512sum ${TARBALL} | cut -d' ' -f1)"
OPAM_VERSION=$(echo -n "${GIT_VERSION}" | cut -d- -f1 | tr -d v)
[ -n "${DEV}" ] && OPAM_VERSION="${OPAM_VERSION}${DEV}"
echo "OPAM version: ${OPAM_VERSION}"
OUTPUT_DIR=./opam/release
if [ -d ${OUTPUT_DIR} ]; then
echo "Deleting existing output directory: ${OUTPUT_DIR}"
rm -rf ${OUTPUT_DIR}
fi
mkdir -p ${OUTPUT_DIR}/tmp
cat <<EOM >${OUTPUT_DIR}/tmp/url
url {
src: "https://github.com/Solo5/solo5/releases/download/${GIT_VERSION}/${TARBALL}"
checksum: "sha512=${CHECKSUM}"
}
EOM
for VARIANT in '' '-cross-aarch64'; do
PKG_DIR=${OUTPUT_DIR}/packages/solo5${VARIANT}/solo5${VARIANT}.${OPAM_VERSION}
mkdir -p ${PKG_DIR} || exit 1
cat opam/solo5${VARIANT}.opam ${OUTPUT_DIR}/tmp/url \
> ${PKG_DIR}/opam || exit 1
opam lint ${PKG_DIR}/opam || exit 1
done
echo "Done. Submit ${OUTPUT_DIR}/packages as a PR to opam-repository."
echo "Example: cp -r opam/release/packages path/to/opam-repository"
echo " cd path/to/opam/repository"
echo " git checkout -b solo5.${OPAM_VERSION}"
echo " git add ."