Skip to content

Commit

Permalink
Add dry run mode to npm version (#2436)
Browse files Browse the repository at this point in the history
* Add DRY_RUN flag to skip publish/push

* Allow overriding branch names for testing
  • Loading branch information
cincodenada authored Jan 28, 2022
1 parent a57bbf6 commit 51c508a
Showing 1 changed file with 9 additions and 4 deletions.
13 changes: 9 additions & 4 deletions scripts/postversion.sh
Original file line number Diff line number Diff line change
@@ -1,17 +1,22 @@
#!/bin/bash
set -e
PACKAGE_VERSION=$(node -p -e "require('./package.json').version")
ARCHIVE_BRANCH="releases"
ARCHIVE_BRANCH=${ARCHIVE_BRANCH:-releases}
SOURCE_BRANCH=$(git rev-parse --abbrev-ref HEAD)

echo 'postversion tasks'

# npm publish will generate the pkg/sinon.js that we use below
echo 'publish to npm'
git push --follow-tags
npm publish
if [ -n "$DRY_RUN" ]; then
npm publish --dry-run
else
git push --follow-tags
npm publish
fi

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

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

git push
[ -n "$DRY_RUN" ] || git push
git checkout $SOURCE_BRANCH

0 comments on commit 51c508a

Please sign in to comment.