Skip to content

Commit 51c508a

Browse files
authored
Add dry run mode to npm version (#2436)
* Add DRY_RUN flag to skip publish/push * Allow overriding branch names for testing
1 parent a57bbf6 commit 51c508a

File tree

1 file changed

+9
-4
lines changed

1 file changed

+9
-4
lines changed

scripts/postversion.sh

Lines changed: 9 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,17 +1,22 @@
11
#!/bin/bash
22
set -e
33
PACKAGE_VERSION=$(node -p -e "require('./package.json').version")
4-
ARCHIVE_BRANCH="releases"
4+
ARCHIVE_BRANCH=${ARCHIVE_BRANCH:-releases}
55
SOURCE_BRANCH=$(git rev-parse --abbrev-ref HEAD)
66

77
echo 'postversion tasks'
88

99
# npm publish will generate the pkg/sinon.js that we use below
1010
echo 'publish to npm'
11-
git push --follow-tags
12-
npm publish
11+
if [ -n "$DRY_RUN" ]; then
12+
npm publish --dry-run
13+
else
14+
git push --follow-tags
15+
npm publish
16+
fi
1317

1418
# Now update the releases branch and archive the new release
19+
echo "archiving release from $SOURCE_BRANCH to $ARCHIVE_BRANCH"
1520
git checkout $ARCHIVE_BRANCH
1621
git merge --no-edit -m "Merge version $PACKAGE_VERSION" $SOURCE_BRANCH
1722

@@ -27,5 +32,5 @@ cp "pkg/sinon.js" "./docs/releases/sinon-$PACKAGE_VERSION.js"
2732
git add "docs/releases/sinon-$PACKAGE_VERSION.js"
2833
git commit -n -m "Add version $PACKAGE_VERSION to releases"
2934

30-
git push
35+
[ -n "$DRY_RUN" ] || git push
3136
git checkout $SOURCE_BRANCH

0 commit comments

Comments
 (0)