Skip to content

Instantly share code, notes, and snippets.

@sagotch
Created April 28, 2014 07:47
Show Gist options
  • Save sagotch/11364627 to your computer and use it in GitHub Desktop.
Save sagotch/11364627 to your computer and use it in GitHub Desktop.
makorel - Release new OPAM package version easily - shell script version
#!/usr/bin/env bash
USAGE="usage: makorel version [package]"
# with:
# - version: new version to release
# - package: /path/to/package/root/directory (optionnal)
if [ $# -lt 1 ] || [ $# -gt 2 ]; then
echo "${USAGE}. Exiting with 1.";
exit 1;
fi
if [ $# -eq 2 ]; then
cd $2;
fi
PKG=${PWD##*/}
NEWVERSION=$1
LASTVERSION=$(ls -t | tail -1 | sed -e "s/${PKG}\.\(.*\)/\1/")
if [ -d "${PKG}.${NEWVERSION}" ]; then
echo "${PKG}.${NEWVERSION} already exists. Exiting with 1."; exit 1
else
cp -R ${PKG}.${LASTVERSION} ${PKG}.${NEWVERSION}
fi
URLFILE=${PKG}.${NEWVERSION}/url
URL=$(grep "archive" ${URLFILE} \
| sed -e "s/\([ \t]*archive[ \t]*:[ \t]*\"\)\(.*\)${LASTVERSION}\([^\"]*.*\)\"/\2${NEWVERSION}\3/")
CHECKSUM=$(curl -s -L ${URL} | md5sum | cut -d\ -f 1)
echo -e "archive:\"${URL}\"\nchecksum:\"${CHECKSUM}\"" > ${URLFILE}
@sagotch
Copy link
Author

sagotch commented Apr 28, 2014

NB: Only works with archive / checksum format. See https://github.com/sagotch/makorel for a more complete solution.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment