Skip to content

Commit 6be874e

Browse files
committed
Add a opam-release script for the release process
1 parent 2ba53a0 commit 6be874e

File tree

1 file changed

+53
-0
lines changed

1 file changed

+53
-0
lines changed

opam/opam-release.sh

Lines changed: 53 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,53 @@
1+
#!/bin/sh
2+
3+
if [ ! -d "./opam" ]; then
4+
echo "ERROR: missing ./opam. Run this from the root of a Solo5 repository."
5+
exit 1
6+
fi
7+
8+
GIT_VERSION=$(git -C . describe --dirty --tags --always)
9+
DEV=
10+
11+
if ! echo "$GIT_VERSION" | egrep -q '^v[0-9]+.[0-9]+.[0-9]+$'; then
12+
echo "WARNING: Not a clean Git release: $GIT_VERSION"
13+
echo "WARNING: This is almost certainly not what you want."
14+
DEV=~dev
15+
fi
16+
17+
TARBALL="esperanto-${GIT_VERSION}.tar.gz"
18+
if [ ! -f ${TARBALL} ]; then
19+
echo "ERROR: Release tarball ${TARBALL} not found."
20+
echo "ERROR: Did you run 'make distrib'?"
21+
exit 1
22+
fi
23+
24+
echo "Using tarball: ${TARBALL}"
25+
CHECKSUM="$(sha512sum ${TARBALL} | cut -d' ' -f1)"
26+
OPAM_VERSION=$(echo -n "${GIT_VERSION}" | cut -d- -f1 | tr -d v)
27+
[ -n "${DEV}" ] && OPAM_VERSION="${OPAM_VERSION}${DEV}"
28+
echo "OPAM version: ${OPAM_VERSION}"
29+
OUTPUT_DIR=./opam/release
30+
if [ -d ${OUTPUT_DIR} ]; then
31+
echo "Deleting existing output directory: ${OUTPUT_DIR}"
32+
rm -rf ${OUTPUT_DIR}
33+
fi
34+
mkdir -p ${OUTPUT_DIR}/tmp
35+
cat <<EOM >${OUTPUT_DIR}/tmp/url
36+
url {
37+
src: "https://github.com/dinosaure/esperanto/releases/download/${GIT_VERSION}/${TARBALL}"
38+
checksum: "sha512=${CHECKSUM}"
39+
}
40+
EOM
41+
for PKG in '' '-cosmopolitan'; do
42+
PKG_DIR=${OUTPUT_DIR}/packages/esperanto${PKG}/esperanto${PKG}.${OPAM_VERSION}
43+
mkdir -p ${PKG_DIR} || exit 1
44+
cat opam/esperanto${PKG}.opam ${OUTPUT_DIR}/tmp/url \
45+
> ${PKG_DIR}/opam || exit 1
46+
opam lint ${PKG_DIR}/opam || exit 1
47+
done
48+
49+
echo "Done. Submit ${OUTPUT_DIR}/packages as a PR to opam-repository."
50+
echo "Example: cp -r opam/release/packages path/to/opam-repository"
51+
echo " cd path/to/opam/repository"
52+
echo " git checkout -b esperanto.${OPAM_VERSION}"
53+
echo " git add ."

0 commit comments

Comments
 (0)