Skip to content

Commit c5f658e

Browse files
committed
build/pre-release: fail if builds are identical
1 parent 54a5204 commit c5f658e

File tree

1 file changed

+23
-17
lines changed

1 file changed

+23
-17
lines changed

build/pre-release.sh

Lines changed: 23 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -2,12 +2,12 @@
22
git clean -fx dist/*
33
git diff-index HEAD --stat --exit-code || exit $?
44

5-
INITIAL_REV=$(git rev-parse --abbrev-ref HEAD)
5+
INITIAL_BRANCH=$(git rev-parse --abbrev-ref HEAD)
66

77
echo 'checking out the "unstable" branch'
88
git checkout unstable || exit $?
99

10-
git merge --no-ff --no-edit $INITIAL_REV || exit $?
10+
git merge --no-ff --no-edit $INITIAL_BRANCH || exit $?
1111

1212
# preversion tests must pass
1313
npm run preversion || exit $?
@@ -16,22 +16,28 @@ npm run preversion || exit $?
1616
NEW_VERSION=$(node build/bump prerelease)
1717
NEW_TAG=$(echo "v$NEW_VERSION" | sed 's/[+].*//')
1818

19-
npm run build &&
20-
git commit -m "v$NEW_VERSION" -- package.json dist || exit $?
19+
#if the version tag already exists, reset head to previous commit and exit
20+
if [ git cat-file -e $NEW_TAG ]; then
21+
exit 1
22+
fi
2123

22-
# add new version tag
23-
if git tag $NEW_TAG; then
24-
# push branch and tags to git origin and publish to npm
25-
git tag --force next &&
26-
git push &&
27-
git push origin $NEW_TAG next &&
28-
npm publish --tag next
29-
else
30-
#if the version tag already exists, reset head to previous commit and exit
31-
err=$?
32-
git reset HEAD@{1}
33-
exit $err
24+
npm run build || exit $?
25+
26+
if [ ! git diff --quiet next ]; then
27+
echo files of this build and the existing "next" tag are identical
28+
exit 1
3429
fi
3530

31+
32+
git commit -m "v$NEW_VERSION" -- package.json dist || exit $?
33+
34+
# add new version tag
35+
git tag $NEW_TAG
36+
# push branch and tags to git origin and publish to npm
37+
git tag --force next &&
38+
git push &&
39+
git push origin $NEW_TAG next &&
40+
npm publish --tag next
41+
3642
# leave the "unstable" branch
37-
git checkout $INITIAI_REV
43+
git checkout $INITIAL_BRANCH

0 commit comments

Comments
 (0)