diff --git a/_tools/build.sh b/_tools/build.sh index 7b2929a..8a021f9 100755 --- a/_tools/build.sh +++ b/_tools/build.sh @@ -4,7 +4,7 @@ echo "Building Plugin..." # Moves everything including the style sheets over to `dist/` echo "Copying directories..." -rm -r dist/ +rm -rf dist/ mkdir dist cp -r -t dist src/{class,languages,templates}/ # Among the images, only 2 out of 3 are distributed. diff --git a/_tools/release.sh b/_tools/release.sh index 1f90547..a0221f2 100755 --- a/_tools/release.sh +++ b/_tools/release.sh @@ -27,29 +27,30 @@ if [[ $1 == "-c" ]]; then read -p "You have passed the \`commit\` flag (\`-c\`). Did you mean to do this? (Y/N): " CONFIRM && [[ $CONFIRM == [yY] || $CONFIRM == [yY][eE][sS] ]] || exit 1 fi -# NB: To run on a branch other than `main`, uncomment this line: -#if false; then +# Unless forced to, the script will only run on the `main` branch. +if [[ $1 != "-f" ]]; then -# Step 1: Ensure the local copy has checked out the `main` branch + # Step 1: Ensure the local copy has checked out the `main` branch + + if [[ "$(git rev-parse --abbrev-ref HEAD)" != "main" ]]; then + echo "ERR: You are not on the \`main\` branch, please check it out and re-run this command." + exit 1 + else + echo "- \`main\` branch is checked out." + fi + + # Step 2: Ensure local copy of `main` is up-to-date with remote + + if [[ "$(git status | grep -c 'Your branch is up to date')" != 1 ]]; then + echo "ERR: Your local copy is not up-to-date with the remote, please update it and re-run this command." + exit 1 + else + echo "- Local copy of \`main\` is up-to-date with remote." + fi -if [[ "$(git rev-parse --abbrev-ref HEAD)" != "main" ]]; then - echo "ERR: You are not on the \`main\` branch, please check it out and re-run this command." - exit 1 -else - echo "- \`main\` branch is checked out." fi -# Step 2: Ensure local copy of `main` is up-to-date with remote - -if [[ "$(git status | grep -c 'Your branch is up to date')" != 1 ]]; then - echo "ERR: Your local copy is not up-to-date with the remote, please update it and re-run this command." - exit 1 -else - echo "- Local copy of \`main\` is up-to-date with remote." -fi - -# NB: To run on a branch other than `main`, uncomment this line: -#fi +rm -rf ./{dist,tmp,svn-tmp} # Step 3: Check versioning @@ -153,7 +154,7 @@ fi # Step 3(g): Check that the changelog is up-to-date -CHANGELOG_LATEST="$(awk -e '/== Changelog ==/,/= [0-9]+\.[0-9]+(\.[0-9]+)? =/' readme.txt | grep -Po '\d+\.\d+(\.\d+)?')" +CHANGELOG_LATEST="$(awk -e '/== Changelog ==/,/= [0-9]+\.[0-9]+(\.[0-9]+)? =/' src/readme.txt | grep -Po '\d+\.\d+(\.\d+)?')" if [[ $CHANGELOG_LATEST != $DEVELOPMENT_VERSION ]]; then echo "ERR: Changelog is not up-to-date!" echo "Current version is $DEVELOPMENT_VERSION" @@ -176,14 +177,16 @@ echo -e "- Build complete.\n" echo "- Setting pre-release version flags..." PRERELEASE_VERSION=$DEVELOPMENT_VERSION'p' -sed -i "s/$JS_VERSION/version : \"$PRERELEASE_VERSION\"/g" dist/js/wysiwyg-editor.js +sed -i "s/$JS_VERSION/$PRERELEASE_VERSION/g" dist/js/wysiwyg-editor.min.js echo "- Pre-release flags set." # Step 6: Tag the release echo "- Tagging release..." git tag -a $DEVELOPMENT_VERSION -m "Pre-release of version $DEVELOPMENT_VERSION" -git push --tags +if [ $? != 0 ]; then echo "Tag already exists!"; exit 1; fi +git push --tags --no-verify +if [ $? != 0 ]; then echo "Push failed (tag probably exists on remote)!"; exit 1; fi echo "- Release tagged." # Step 7: Push release to SVN repo. @@ -227,8 +230,8 @@ echo "Stable version:" echo -e '\t' $STABLE_VERSION '\n' echo -e "Commit message:\n" echo -e "$CHANGELOG_MESSAGE" '\n' -svn status | grep '^\!' | sed 's/! *//' | xargs -I% svn rm % -echo -e "Changes made to local \`trunk/\`:\n" +svn stat svn-tmp/trunk/ | grep '^\!' | sed 's/! *//' | xargs -I% svn rm % >/dev/null +echo -e "Changes made to local \`trunk/\` (should only be 'M', 'D' and '?'):\n" svn stat svn-tmp/trunk/ echo "" echo -e "\`readme.txt\` header:\n"