1+ #! /bin/bash
2+ # Release process for the Java chaincode is this
3+ #
4+ # > Work from the latest release-1.4 branch
5+ # > Write a new release notes file along the lines of the the existing files
6+ # > Run the script
7+ #
8+ # ./scripts/release.sh
9+ #
10+ # This will change the version to the correct release version and set the tag to mark the package
11+ # as npm publishable by the merge builds
12+ # > Submit this to gerrit with this push command
13+ #
14+ # git push origin HEAD:refs/for/release-1.4
15+ #
16+ # > When the build has complete, git pull to update your branch
17+ # > To tag in gerrit run
18+ #
19+ # ./scripts/gittag.sh
20+ #
21+ # > To update the version to a new snapshot leve run the
22+ #
23+ # NEW_SUFFIX=snapshot ./scripts/release.sh
24+ #
25+ # > Push these changes as per normal
26+
27+
28+ # Exit on first error, print all commands.
29+ set -e
30+ set -o pipefail
31+ DIR=" $( cd " $( dirname " ${BASH_SOURCE[0]} " ) /.." && pwd ) "
32+
33+ function abort {
34+ echo " !! Exiting shell script"
35+ echo " !!" " $1 "
36+ exit -1
37+ }
38+
39+ # need determine the release version
40+ # Suffix can be added after the version eg rc or beta etc.
41+ if [ -z ${NEW_SUFFIX+x} ]; then
42+ echo Suffix is not specified using pure version number
43+ NEW_VERSION=$( jq ' .version' ${DIR} /package.json | sed -r " s/\" ([0-9]?[0-9]\.[0-9]?[0-9]\.[0-9]?[0-9])-.*/\1/" )
44+ NEW_TAG=" latest"
45+ elif [[ ${NEW_SUFFIX} == ' snapshot' ]]; then
46+ echo new suffix is ${NEW_SUFFIX}
47+ CURRENT_VERSION=$( jq ' .version' ${DIR} /package.json | sed -r " s/\" ([0-9]?[0-9]\.[0-9]?[0-9]\.[0-9]?[0-9])(.)*/\1/" )
48+ NEW_VERSION=$( ${DIR} /node_modules/.bin/semver -i ${CURRENT_VERSION} ) -snapshot
49+ NEW_TAG=" unstable-1.4"
50+ else # for beta, rc etc releases where the version doesn't change
51+ echo new suffix is ${NEW_SUFFIX}
52+ NEW_VERSION=$( jq ' .version' ${DIR} /package.json | sed -r " s/\" ([0-9]?[0-9]\.[0-9]?[0-9]\.[0-9]?[0-9])(.)*/\1-${NEW_SUFFIX} /" )
53+ NEW_TAG=" ${NEW_SUFFIX} -1.4"
54+ fi
55+
56+ echo New version string will be " ${NEW_VERSION} "
57+
58+ # do the release notes and changelog for this new version exist if needed
59+ if [[ ${NEW_TAG} == ' latest' ]]; then
60+ if [[ -f " ${DIR} /release_notes/v${NEW_VERSION} .txt" ]]; then
61+ echo " Release notes exist, hope they make sense!"
62+ else
63+ abort " No releases notes under the file ${DIR} /release_notes/v${NEW_VERSION} .txt exist" ;
64+ fi
65+
66+ OLD_VERSION=$( cat ./CHANGELOG.md | sed -n 1p | sed -n -e " s/.*v\(.*\)/\1/p" )
67+ echo Previous version is v${OLD_VERSION}
68+
69+ echo " Writing change log..."
70+ " ${DIR} /scripts/changelog.sh" " v${OLD_VERSION} " " v${NEW_VERSION} "
71+ echo " ...done"
72+ fi
73+
74+ # need to modify the package.json versions now to represent the updates
75+ for PACKAGE in fabric-shim-crypto fabric-shim fabric-contract-api
76+ do
77+ jq --arg VERSION " ${NEW_VERSION} " --arg TAG " ${NEW_TAG} " ' .version = $VERSION | .tag = $TAG ' ${DIR} /${PACKAGE} /package.json > " .tmp" && mv " .tmp" ${DIR} /${PACKAGE} /package.json
78+ done
79+
80+ jq --arg VERSION " ${NEW_VERSION} " ' .version = $VERSION' ${DIR} /package.json > " .tmp" && mv " .tmp" ${DIR} /package.json
81+ # This is a optional operation that can be done at any point to update the
82+ # test to use a specific version of Fabric docker images etc
83+ #
84+
85+ if [[ ${NEW_TAG} == ' latest' ]]; then
86+ echo " Please verify that all is well with the changes, add, comit and push to gerrit with"
87+ echo " "
88+ echo " git push origin HEAD:refs/for/release-1.4"
89+ echo " "
90+ echo " Wait for build to happen, which will push NPM modules, then run ./scripts/gittag.sh"
91+ else
92+ echo " Please verify that all is well with the changes, and, commit and push to gerrit as normal"
93+ fi
0 commit comments