1#!/bin/bash 2set -e 3 4if [ $(git diff | wc -l) != 0 ] 5then 6 echo "Commit your change before publish!" 7 exit 1 8fi 9 10if [ -z "$1" ] 11then 12 PART_ID=0 13else 14 PART_ID=$1 15fi 16ROOT=$(dirname $(readlink -f $0)) 17OLD_VERSION=$(cat ${ROOT}/doc-template/latest_version) 18NEW_VERSION=$(awk -F. 'BEGIN{idx=3-'${PART_ID}'}{$idx+=1; for(i=idx+1; i <= 3; i++) $i=0; print $1"."$2"."$3}' ${ROOT}/doc-template/latest_version) 19echo "Publishing new version ${OLD_VERSION} -> ${NEW_VERSION}" 20echo ${NEW_VERSION} > doc-template/latest_version 21doc-template/update_readme.sh 22echo ${OLD_VERSION} > doc-template/latest_version 23cargo fmt 24 25PATTERN=$(echo ^version = \"${OLD_VERSION}\"\$ | sed 's/\./\\./g') 26DATE=$(date "+%Y-%m-%d") 27sed -i "s/${PATTERN}/version = \"${NEW_VERSION}\"/g" Cargo.toml 28PATTERN=$(echo ${NEW_VERSION} | sed 's/\./\\./g') 29sed -i "s/^## Plotters .* (?) *\$/## Plotters ${NEW_VERSION} ($DATE)/g" CHANGELOG.md 30 31echo ${NEW_VERSION} > doc-template/latest_version 32 33git add -u . 34git commit -m "Bump version number from ${OLD_VERSION} to ${NEW_VERSION}" 35git tag -a "v${NEW_VERSION}" -m "Plotters ${NEW_VERSION} release" 36 37# Verify MSRV 38MSRV=$(cat ${ROOT}/doc-template/msrv.txt) 39rustup install ${MSRV} 40cargo +${MSRV} build 41 42cargo publish 43git push origin 44git push origin "v${NEW_VERSION}" 45