Fix deploy scripts for handling composer.json version and version string validation (https://github.com/woocommerce/woocommerce-blocks/pull/3027)
* improve patch version detection and automatically fix incorrect format for version * don’t include composer.json version update in commit * update build-plugin zip to account for autoloader generation * for zip-only do composer dump-autoload command * regenerate classmap after composer version change reverted in composer.json and/or deployed * fix condition * improve/fix version string splitting * remove lingering debugging * Add some more info around the question on whether this is deployed to WordPress.org or not * update release doc about main branch version bumping * tweak wording in release docs * fix grammar in user instructions
This commit is contained in:
parent
0a1a14f5db
commit
0244bd5327
|
@ -3,7 +3,7 @@
|
|||
# Exit if any command fails.
|
||||
set -e
|
||||
|
||||
TYPE='PRODUCTION';
|
||||
TYPE='PRODUCTION'
|
||||
|
||||
print_usage() {
|
||||
echo "build-plugin-zip - attempt to build a plugin"
|
||||
|
@ -33,6 +33,17 @@ while getopts 'hdz' flag; do
|
|||
esac
|
||||
done
|
||||
|
||||
# Tool for grabbing version from package.json
|
||||
get_version() {
|
||||
grep '\"version\"' package.json \
|
||||
| cut -d ':' -f 2 \
|
||||
| sed 's/"//g' \
|
||||
| sed 's/,//g' \
|
||||
| sed 's/ //g'
|
||||
}
|
||||
|
||||
# Set version
|
||||
VERSION=$(get_version)
|
||||
|
||||
# Store paths
|
||||
SOURCE_PATH=$(pwd)
|
||||
|
@ -80,6 +91,9 @@ if [ -z "$NO_CHECKS" ]; then
|
|||
fi
|
||||
fi
|
||||
|
||||
# Add version to composer.json
|
||||
perl -i -pe "s/\"type\":*.+/\"type\":\"wordpress-plugin\",\n\t\"version\": \"${VERSION}\",/" composer.json
|
||||
|
||||
# Run the build.
|
||||
npm list webpack
|
||||
if [ $TYPE = 'DEV' ]; then
|
||||
|
@ -94,6 +108,7 @@ if [ $TYPE = 'DEV' ]; then
|
|||
npm run dev
|
||||
status "==========================="
|
||||
elif [ $TYPE = 'ZIP_ONLY' ]; then
|
||||
composer dump-autoload
|
||||
status "Skipping build commands - using current built assets on disk for built archive...👷♀️"
|
||||
status "==========================="
|
||||
else
|
||||
|
@ -118,4 +133,10 @@ zip -r ../woocommerce-gutenberg-products-block.zip ./
|
|||
cd ..
|
||||
rm -r zip-file
|
||||
|
||||
# cleanup composer.json
|
||||
git checkout -- composer.json
|
||||
|
||||
# regenerate classmap for development use
|
||||
composer dump-autoload
|
||||
|
||||
success "Done. You've built WooCommerce Blocks! 🎉"
|
||||
|
|
|
@ -77,7 +77,7 @@ fi
|
|||
|
||||
|
||||
echo
|
||||
output 3 "Will this release get published to WordPress.org (if no, then only a tag will be created)? [y/N]:"
|
||||
output 3 "Will this release get published to WordPress.org? Note: If the version on WordPress.org is greater than ${VERSION}, then you should answer 'N' here. [y/N]:"
|
||||
read -r DO_WP_DEPLOY
|
||||
echo
|
||||
|
||||
|
@ -88,14 +88,34 @@ fi
|
|||
|
||||
# Safety check, if a patch release is detected ask for verification.
|
||||
VERSION_PIECES=${VERSION//[^.]}
|
||||
if [[ "${#VERSION_PIECES}" -ge "2" && "$(echo "${DO_WP_DEPLOY:-n}" | tr "[:upper:]" "[:lower:]")" = "y" ]]; then
|
||||
|
||||
# explode version parts
|
||||
split_version() {
|
||||
echo ${VERSION} \
|
||||
| sed 's/\./ /g'
|
||||
}
|
||||
|
||||
SPLIT_VERSION=($(split_version))
|
||||
|
||||
# IF VERSION_PIECES is less than 2 then its invalid so let's update it and notify
|
||||
if [[ "${#VERSION_PIECES}" -lt "2" ]]; then
|
||||
if [[ ${#VERSION_PIECES} -eq "0" ]]; then
|
||||
VERSION=${VERSION}.0.0
|
||||
else
|
||||
VERSION=${VERSION}.0
|
||||
fi
|
||||
fi
|
||||
|
||||
if [[ "${#VERSION_PIECES}" -ge "2" && "${SPLIT_VERSION[2]}" -ne "0" && "$(echo "${DO_WP_DEPLOY:-n}" | tr "[:upper:]" "[:lower:]")" = "y" ]]; then
|
||||
output 1 "The version you entered (${VERSION}) looks like a patch version. Since this version will be deployed to WordPress.org, it will become the latest available version. Are you sure you want that (no will abort)?: [y/N]"
|
||||
read -r ABORT
|
||||
echo
|
||||
if [ "$(echo "${ABORT:-n}" | tr "[:upper:]" "[:lower:]")" != "y" ]; then
|
||||
output 1 "Release cancelled!"
|
||||
exit 1
|
||||
fi
|
||||
else
|
||||
echo "$(output 4 "The version is set as ") $(output 3 "${VERSION}") $(output 4 " and the next step will be to bump all the version strings in relevant files.")"
|
||||
printf "Ready to proceed? [y/N]: "
|
||||
read -r PROCEED
|
||||
echo
|
||||
|
@ -112,6 +132,9 @@ source $RELEASER_PATH/bin/version-changes.sh
|
|||
|
||||
composer dump-autoload
|
||||
|
||||
# remove composer.json version bump after autoload regen (we don't commit it)
|
||||
git checkout -- composer.json
|
||||
|
||||
output 2 "Committing version change..."
|
||||
echo
|
||||
|
||||
|
@ -158,4 +181,7 @@ git checkout $CURRENTBRANCH
|
|||
git branch -D $BRANCH
|
||||
git push origin --delete $BRANCH
|
||||
|
||||
# regenerate classmap for development
|
||||
composer dump-autoload
|
||||
|
||||
output 2 "GitHub release complete."
|
||||
|
|
|
@ -158,7 +158,7 @@ _Outcome_: **Customers can install/update via WPORG; WPORG plugin page is up to
|
|||
|
||||
- Merge the release branch back into `main` (without the branch being up to date with `main`). This may have merge conflicts needing resolved if there are cherry-picked commits in the release branch.
|
||||
- Restore the branch if it is deleted. Release branches are kept open for potential patch releases for that version.
|
||||
- For _major_ & _minor_ releases, update version on `main` with dev suffix, e.g. [`2.6-dev`](https://github.com/woocommerce/woocommerce-gutenberg-products-block/commit/e27f053e7be0bf7c1d376f5bdb9d9999190ce158).
|
||||
- For _major_ & _minor_ releases, confirm version on `main` is correct and has dev suffix [`2.6-dev`](https://github.com/woocommerce/woocommerce-gutenberg-products-block/commit/e27f053e7be0bf7c1d376f5bdb9d9999190ce158). **Note:** this should have already been taken care for you by the release deploy script, just verify that the versions have been updated correctly.
|
||||
- Update the schedules p2 with the shipped date for the release (Pca54o-1N-p2).
|
||||
|
||||
_Outcome:_ __Main branch contains all changes and metadata tweaks for the release.__
|
||||
|
@ -207,7 +207,7 @@ In particular, please review and update as needed:
|
|||
|
||||
- Are there any new blocks in this release? Ensure they have adequate user documentation.
|
||||
- Ensure any major improvements or changes are documented.
|
||||
- Update minimum supported versions (WordPress, WooCommerce Core) and other requirements where necessary, including:
|
||||
- Update minimum supported versions (WordPress, WooCommerce Core) and other requirements where necessary, including:
|
||||
- [WCCOM product page](https://woocommerce.com/products/woocommerce-gutenberg-products-block/)
|
||||
- [WooCommerce blocks main documentation page](https://docs.woocommerce.com/document/woocommerce-blocks/)
|
||||
|
||||
|
|
Loading…
Reference in New Issue