Skip to content

Commit 42754fb

Browse files
mbwhiteheatherlp
authored andcommitted
[FAB-15990] release scripts
PLEASE NOTE these changes are NOT releasing rather providing scripts so that they can be used to help the process You shouldn't need to manually update version numbers. Change-Id: I6a4e60ba79c5dd67081070f59fa27a2c94190031 Signed-off-by: Matthew B. White <whitemat@uk.ibm.com>
1 parent 6946d91 commit 42754fb

5 files changed

Lines changed: 194 additions & 64 deletions

File tree

scripts/gittag.sh

Lines changed: 37 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,37 @@
1+
#!/bin/bash
2+
3+
# Exit on first error, print all commands.
4+
set -e
5+
set -o pipefail
6+
DIR="$( cd "$( dirname "${BASH_SOURCE[0]}" )/.." && pwd )"
7+
8+
# set to echo to do processing but not the git commands
9+
#DRYRUN=echo
10+
11+
# release name
12+
RELEASE=release-1.4
13+
14+
function abort {
15+
echo "!! Exiting shell script"
16+
echo "!!" "$1"
17+
exit -1
18+
}
19+
20+
VERSION=$(jq '.version' ${DIR}/package.json | sed -r "s/\"([0-9]?[0-9]\.[0-9]?[0-9]\.[0-9]?[0-9]).*/\1/")
21+
22+
echo New version string will be v${VERSION}
23+
24+
# do the release notes for this new version exist?
25+
if [[ -f "${DIR}/release_notes/v${VERSION}.txt" ]]; then
26+
echo "Release notes exist, hope they make sense!"
27+
else
28+
abort "No releases notes under the file ${DIR}/release_notes/v${NEW_VERSION}.txt exist";
29+
fi
30+
31+
32+
33+
34+
${DRYRUN} git checkout "${RELEASE}"
35+
${DRYRUN} git pull
36+
${DRYRUN} git tag -a "v${VERSION}" `git log -n 1 --pretty=oneline | head -c7` -F release_notes/"v${VERSION}".txt
37+
${DRYRUN} git push origin v${VERSION} HEAD:refs/heads/${RELEASE}

scripts/release.sh

Lines changed: 93 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,93 @@
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

test/fv/annotations/package.json

Lines changed: 26 additions & 26 deletions
Original file line numberDiff line numberDiff line change
@@ -1,28 +1,28 @@
11
{
2-
"name": "ts_chaincode",
3-
"description": "Chaincode testing typescript functionality and annotations",
4-
"engines": {
5-
"node": ">=8.4.0",
6-
"npm": ">=5.3.0"
7-
},
8-
"scripts": {
9-
"build": "tsc",
10-
"start": "fabric-chaincode-node start",
11-
"prestart": "tsc"
12-
},
13-
"main": "dist/index.js",
14-
"typings": "dist/index.d.ts",
15-
"engine-strict": true,
16-
"engineStrict": true,
17-
"version": "1.0.0",
18-
"author": "",
19-
"license": "APACHE-2.0",
20-
"dependencies": {
21-
"fabric-shim": "unstable",
22-
"fabric-contract-api": "unstable",
23-
"@types/node": "^10.3.6",
24-
"ts-node": "^3.3.0",
25-
"tslint": "^5.6.0",
26-
"typescript": "^2.5.3"
27-
}
2+
"name": "ts_chaincode",
3+
"description": "Chaincode testing typescript functionality and annotations",
4+
"engines": {
5+
"node": ">=8.4.0",
6+
"npm": ">=5.3.0"
7+
},
8+
"scripts": {
9+
"build": "tsc",
10+
"start": "fabric-chaincode-node start",
11+
"prestart": "tsc"
12+
},
13+
"main": "dist/index.js",
14+
"typings": "dist/index.d.ts",
15+
"engine-strict": true,
16+
"engineStrict": true,
17+
"version": "1.0.0",
18+
"author": "",
19+
"license": "APACHE-2.0",
20+
"dependencies": {
21+
"fabric-shim": "unstable",
22+
"fabric-contract-api": "unstable",
23+
"@types/node": "^10.3.6",
24+
"ts-node": "^3.3.0",
25+
"tslint": "^5.6.0",
26+
"typescript": "^2.5.3"
2827
}
28+
}

test/fv/crud/package.json

Lines changed: 19 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -1,21 +1,21 @@
11
{
2-
"name": "chaincode",
3-
"description": "Chaincode testing crud functionality",
4-
"engines": {
5-
"node": ">=8.4.0",
6-
"npm": ">=5.3.0"
7-
},
8-
"scripts": {
9-
"start": "fabric-chaincode-node start"
10-
},
11-
"main": "index.js",
12-
"engine-strict": true,
13-
"engineStrict": true,
14-
"version": "1.0.0",
15-
"author": "",
16-
"license": "Apache-2.0",
17-
"dependencies": {
18-
"fabric-shim": "unstable",
19-
"fabric-contract-api": "unstable"
20-
}
2+
"name": "chaincode",
3+
"description": "Chaincode testing crud functionality",
4+
"engines": {
5+
"node": ">=8.4.0",
6+
"npm": ">=5.3.0"
7+
},
8+
"scripts": {
9+
"start": "fabric-chaincode-node start"
10+
},
11+
"main": "index.js",
12+
"engine-strict": true,
13+
"engineStrict": true,
14+
"version": "1.0.0",
15+
"author": "",
16+
"license": "Apache-2.0",
17+
"dependencies": {
18+
"fabric-shim": "unstable",
19+
"fabric-contract-api": "unstable"
2120
}
21+
}

test/fv/query/package.json

Lines changed: 19 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -1,21 +1,21 @@
11
{
2-
"name": "chaincode",
3-
"description": "Chaincode testing query functionality",
4-
"engines": {
5-
"node": ">=8.4.0",
6-
"npm": ">=5.3.0"
7-
},
8-
"scripts": {
9-
"start": "fabric-chaincode-node start"
10-
},
11-
"main": "index.js",
12-
"engine-strict": true,
13-
"engineStrict": true,
14-
"version": "1.0.0",
15-
"author": "",
16-
"license": "Apache-2.0",
17-
"dependencies": {
18-
"fabric-shim": "unstable",
19-
"fabric-contract-api": "unstable"
20-
}
2+
"name": "chaincode",
3+
"description": "Chaincode testing query functionality",
4+
"engines": {
5+
"node": ">=8.4.0",
6+
"npm": ">=5.3.0"
7+
},
8+
"scripts": {
9+
"start": "fabric-chaincode-node start"
10+
},
11+
"main": "index.js",
12+
"engine-strict": true,
13+
"engineStrict": true,
14+
"version": "1.0.0",
15+
"author": "",
16+
"license": "Apache-2.0",
17+
"dependencies": {
18+
"fabric-shim": "unstable",
19+
"fabric-contract-api": "unstable"
2120
}
21+
}

0 commit comments

Comments
 (0)