Skip to content

Commit e163349

Browse files
jeffbcrossvsavkin
authored andcommitted
chore(release): change release script to append commits instead of replace
1 parent 286d364 commit e163349

File tree

1 file changed

+58
-20
lines changed

1 file changed

+58
-20
lines changed

scripts/release.sh

Lines changed: 58 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -2,23 +2,61 @@
22

33
./scripts/package.sh
44

5-
cd build/packages/bazel
6-
git init
7-
git add .
8-
git commit -am 'init commit'
9-
git remote add origin git@github.com:nrwl/bazel-build.git
10-
git push -f origin master
11-
12-
cd ../nx
13-
git init
14-
git add .
15-
git commit -am 'init commit'
16-
git remote add origin git@github.com:nrwl/nx-build.git
17-
git push -f origin master
18-
19-
cd ../schematics
20-
git init
21-
git add .
22-
git commit -am 'init commit'
23-
git remote add origin git@github.com:nrwl/schematics-build.git
24-
git push -f origin master
5+
function restore() {
6+
echo "FINISHED"
7+
cd $STARTING_DIRECTORY
8+
}
9+
10+
function getPackageVersion() {
11+
echo `node -e "console.log(require('./package.json').version)"`
12+
}
13+
14+
#Rewrite the version in the package.json to be root package version+short sha (0.0.1+abcdef0)
15+
function updatePackageVersion() {
16+
PACKAGE_NAME=$1
17+
VERSION=$2
18+
node -e "const pkgPath='./${PACKAGE_NAME}/package.json';const pkg=require(pkgPath);pkg.version='${VERSION}'; fs.writeFileSync(pkgPath, JSON.stringify(pkg, null, 2)+'\n')"
19+
}
20+
21+
STARTING_DIRECTORY=${PWD}
22+
SHORT_SHA=`git rev-parse --short HEAD`
23+
BRANCH_NAME=pub-${SHORT_SHA}
24+
PACKAGE_VERSION=`getPackageVersion`
25+
BUILT=../packages
26+
BUILD_VER="${PACKAGE_VERSION}+${SHORT_SHA}"
27+
trap restore SIGINT SIGTERM EXIT
28+
29+
mkdir -p build/git-clones
30+
cd build/git-clones
31+
32+
for dir in $BUILT/*/
33+
do
34+
PACKAGE_DIR="$(basename ${dir})"
35+
BUILD_ARTIFACTS="${dir}"
36+
REPO_DIR="${PACKAGE_DIR}-build"
37+
38+
rm -rf $REPO_DIR
39+
mkdir -p $REPO_DIR
40+
# Create directory and populate with shallow git content from origin
41+
(cd $REPO_DIR &&
42+
git init && \
43+
git remote add origin git@github.com:nrwl/$REPO_DIR.git && \
44+
git fetch origin master --depth=1 && \
45+
git checkout origin/master && \
46+
git checkout -b $BRANCH_NAME
47+
)
48+
49+
# Clean up the contents of the git directory so creating the commit will
50+
# be simpler (not having to selectively delete files)
51+
rm -rf $REPO_DIR/*
52+
cp -R ${BUILD_ARTIFACTS}/* $REPO_DIR/
53+
updatePackageVersion $REPO_DIR $BUILD_VER
54+
55+
(
56+
cd $REPO_DIR && \
57+
git add --all && \
58+
git commit -m "publishing ${BUILD_VER}" --quiet && \
59+
git tag "${BUILD_VER}" && \
60+
git push origin $BRANCH_NAME:master --tags --force
61+
)
62+
done

0 commit comments

Comments
 (0)