Skip to content

Commit

Permalink
chore update deploy script
Browse files Browse the repository at this point in the history
  • Loading branch information
rrd108 committed Aug 5, 2024
1 parent 77b4610 commit e760f4b
Showing 1 changed file with 26 additions and 34 deletions.
60 changes: 26 additions & 34 deletions deploy.sh
Original file line number Diff line number Diff line change
Expand Up @@ -4,9 +4,9 @@ RED='\e[1;41m'
GREEN='\e[1;42m'
NC='\033[0m' # No Color

# Check if a version type (minor or patch) and dry-run flag are provided as command-line arguments
if [ -z "$1" ] || [ -z "$2" ]; then
echo "Usage: $0 patch|minor dry-run|publish"
# Check if a version type (minor or patch) is provided as a command-line argument
if [ -z "$1" ]; then
echo "Usage: $0 patch|minor"
exit 1
fi

Expand All @@ -17,13 +17,6 @@ if [ "$1" != "patch" ] && [ "$1" != "minor" ]; then
exit 1
fi

# Check if the provided dry-run flag is valid
if [ "$2" != "dry-run" ] && [ "$2" != "publish" ]; then
echo "Invalid dry-run flag: $2"
echo "dry-run flag should be 'dry-run' or 'publish'"
exit 1
fi

echo $'\n' "Running Frontend Tests" $'\n'
yarn test
if [ $? -eq 0 ]; then
Expand All @@ -34,6 +27,11 @@ else
PREV_STEP=0
fi

if [ $PREV_STEP -eq 1 ];then
echo $'\n' "Check docs for missing rules" $'\n'
yarn docs:missing
fi

if [ $PREV_STEP -eq 1 ];then
echo $'\n' "Run build to generate dist files" $'\n'
yarn build
Expand All @@ -49,37 +47,31 @@ if [ $PREV_STEP -eq 1 ];then
last_release=$(git describe --tags --abbrev=0)
release_notes=$(git log "${last_release}..HEAD" --pretty="%s" | awk -v prefix="* " '/^(feat|fix|docs|test|chore|refactor|style)/{print prefix $0}')

# Perform publishing, pushing, and release creation only if the dry-run flag is not set
if [ "$2" == "publish" ]; then
echo "👉 Publishing the new version to npmjs.com"
yarn publish --new-version "$1"

# Capture the new version number
new_version=$(node -p "require('./package.json').version")

echo "👉 Pushing new version to git: $new_version"
git push vue-mess-detector "v$new_version"
echo "👉 Publishing the new version to npmjs.com"
yarn publish --new-version "$1"

echo "👉 Creating a new release on GitHub"
gh release create "v$new_version" --notes "$release_notes"
# Capture the new version number
new_version=$(node -p "require('./package.json').version")

echo "👉 Pushing new version to git: $new_version"
git push vue-mess-detector "v$new_version"

# Update the version field in jsr.json
jq ".version = \"$new_version\"" jsr.json > tmp.json && mv tmp.json jsr.json
echo "👉 Creating a new release on GitHub"
gh release create "v$new_version" --notes "$release_notes"

echo "👉 jsr.json updated with the new version: $new_version"
# Update the version field in jsr.json
jq ".version = \"$new_version\"" jsr.json > tmp.json && mv tmp.json jsr.json

# Commit the changes to Git
git add jsr.json
git commit -m "Bump version to $new_version"
echo "👉 jsr.json updated with the new version: $new_version"

echo "👉 Changes committed to Git"
# Commit the changes to Git
git add jsr.json
git commit -m "Bump version to $new_version"

npx jsr publish
echo "👉 Published the new version to JSR"
else
echo "Dry run mode. No publishing or pushing will be performed."
fi
echo "👉 Changes committed to Git"

npx jsr publish
echo "👉 Published the new version to JSR"
else
echo -e $'\n' "${RED} \u2a2f Repository is not clean. ${NC} Please commit or stash your changes before running this script." $'\n'
exit 1
Expand Down

0 comments on commit e760f4b

Please sign in to comment.