-
Notifications
You must be signed in to change notification settings - Fork 0
add dry-run, npm tags to publish #35
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: main
Are you sure you want to change the base?
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,9 +1,49 @@ | ||
#!/usr/bin/env bash | ||
set -euo pipefail | ||
|
||
echo "Running npm publish..." | ||
npm publish | ||
# Default values | ||
dry_run=false | ||
|
||
echo "Creating git tag..." | ||
git tag "v${version}" | ||
git push --tags | ||
usage() { | ||
echo "Usage: $0 [-d] [-h]" | ||
echo " -d Perform a dry run without actually publishing or creating git tags" | ||
echo " -h Show this help message" | ||
exit 1 | ||
} | ||
|
||
while getopts ":dh" opt; do | ||
case $opt in | ||
d) | ||
dry_run=true | ||
;; | ||
h) | ||
usage | ||
;; | ||
\?) | ||
echo "Invalid option: -$OPTARG" | ||
usage | ||
;; | ||
esac | ||
done | ||
|
||
version=$(node -p "require('./package.json').version") | ||
if [[ $version == *-* ]]; then | ||
# Extract suffix after the last dash (e.g., "1.0.0-ea" -> "ea") | ||
tag="${version##*-}" | ||
else | ||
# No suffix, use latest tag | ||
tag="latest" | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I think we'll only want to use |
||
fi | ||
|
||
if [[ "$dry_run" == true ]]; then | ||
npm publish --tag "$tag" --dry-run | ||
|
||
echo "DRY RUN: Skipping git tag and push operations" | ||
else | ||
echo "Publishing version $version with tag '$tag'..." | ||
npm publish --tag "$tag" | ||
|
||
echo "Creating git tag..." | ||
git tag "v${version}" | ||
git push --tags | ||
fi |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Need to modify this to allow prerelease versions:
1.0.0-ea.0
. Currently would extractea.0
as the tag when we wantea
.npm version prerelease --preid=ea
1.0.0 -> 1.0.0-ea.0