Created
April 28, 2014 07:47
-
-
Save sagotch/11364627 to your computer and use it in GitHub Desktop.
makorel - Release new OPAM package version easily - shell script version
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/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} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
NB: Only works with archive / checksum format. See https://github.com/sagotch/makorel for a more complete solution.