Add dry run option for the release script (https://github.com/woocommerce/woocommerce-admin/pull/6946)
* Added dry run option and clean between core and plugin builds * Add safety so I will not accidently start a release * Change return to exit and update plugin release name on dry run * Updated some of the logging * Made use of git --dry-run and hub --noop * Add dry run to add as well * Removed dry-run command, updated log
This commit is contained in:
parent
64eb902257
commit
a7db89ff4f
|
@ -21,6 +21,7 @@ Now you can build the files using one of these commands:
|
||||||
- `npm run dev` : Build a development version
|
- `npm run dev` : Build a development version
|
||||||
- `npm start` : Build a development version, watch files for changes
|
- `npm start` : Build a development version, watch files for changes
|
||||||
- `npm run build:release` : Build a WordPress plugin ZIP file (`woocommerce-admin.zip` will be created in the repository root)
|
- `npm run build:release` : Build a WordPress plugin ZIP file (`woocommerce-admin.zip` will be created in the repository root)
|
||||||
|
- `DRY_RUN=1 npm run build:release` : Builds a Wordpress plugin ZIP **without** pushing it to Github and creating a release.
|
||||||
|
|
||||||
For more helper scripts [see here](./CONTRIBUTING.md#helper-scripts)
|
For more helper scripts [see here](./CONTRIBUTING.md#helper-scripts)
|
||||||
|
|
||||||
|
|
|
@ -40,6 +40,9 @@ warning () {
|
||||||
}
|
}
|
||||||
|
|
||||||
status "💃 Time to release WooCommerce Admin 🕺"
|
status "💃 Time to release WooCommerce Admin 🕺"
|
||||||
|
if [ $DRY_RUN ]; then
|
||||||
|
warning "This is a dry run, nothing will be pushed up to Github, it will only generate zip files."
|
||||||
|
fi
|
||||||
|
|
||||||
warning "Please enter the version number to tag, for example, 1.0.0: "
|
warning "Please enter the version number to tag, for example, 1.0.0: "
|
||||||
read -r VERSION
|
read -r VERSION
|
||||||
|
@ -108,13 +111,18 @@ status "Generating the plugin build... 👷♀️"
|
||||||
|
|
||||||
# Make a Github release.
|
# Make a Github release.
|
||||||
status "Starting a Github release... 👷♀️"
|
status "Starting a Github release... 👷♀️"
|
||||||
./bin/github-deploy.sh ${PLUGIN_TAG} ${ZIP_FILE}
|
if [ $DRY_RUN ]; then
|
||||||
|
PLUGIN_ZIP_FILE="woocommerce-admin-plugin.zip"
|
||||||
|
else
|
||||||
|
PLUGIN_ZIP_FILE=$ZIP_FILE
|
||||||
|
fi
|
||||||
|
./bin/github-deploy.sh ${PLUGIN_TAG} ${PLUGIN_ZIP_FILE}
|
||||||
|
|
||||||
if [ $IS_CUSTOM_BUILD = false ]; then
|
if [ $IS_CUSTOM_BUILD = false ]; then
|
||||||
# Remove ignored files to reset repository to pristine condition. Previous
|
# Remove ignored files to reset repository to pristine condition. Previous
|
||||||
# test ensures that changed files abort the plugin build.
|
# test ensures that changed files abort the plugin build.
|
||||||
status "Cleaning working directory... 🛀"
|
status "Cleaning working directory... 🛀"
|
||||||
git clean -xdf
|
git clean -xdf -e woocommerce-admin-plugin.zip
|
||||||
|
|
||||||
# Install PHP dependencies
|
# Install PHP dependencies
|
||||||
status "Gathering PHP dependencies... 🐿️"
|
status "Gathering PHP dependencies... 🐿️"
|
||||||
|
@ -129,4 +137,11 @@ if [ $IS_CUSTOM_BUILD = false ]; then
|
||||||
./bin/github-deploy.sh ${CORE_TAG} ${ZIP_FILE}
|
./bin/github-deploy.sh ${CORE_TAG} ${ZIP_FILE}
|
||||||
fi
|
fi
|
||||||
|
|
||||||
|
if [ $DRY_RUN ]; then
|
||||||
|
output 2 "Dry run successfully finished."
|
||||||
|
echo
|
||||||
|
echo "Generated $PLUGIN_ZIP_FILE for the woocommerce-admin plugin build"
|
||||||
|
echo "Generated $ZIP_FILE for the woocommerce-admin core build"
|
||||||
|
exit;
|
||||||
|
fi
|
||||||
success "Done. You've built WooCommerce Admin! 🎉 "
|
success "Done. You've built WooCommerce Admin! 🎉 "
|
||||||
|
|
|
@ -51,6 +51,7 @@ if [[ $1 == '' || $2 == '' ]]
|
||||||
exit 1
|
exit 1
|
||||||
fi
|
fi
|
||||||
|
|
||||||
|
|
||||||
printf "This script will build files and create a tag on GitHub based on your local branch."
|
printf "This script will build files and create a tag on GitHub based on your local branch."
|
||||||
echo
|
echo
|
||||||
echo
|
echo
|
||||||
|
@ -59,6 +60,9 @@ echo
|
||||||
echo
|
echo
|
||||||
printf "The /dist/ directory will also be pushed to the tagged release."
|
printf "The /dist/ directory will also be pushed to the tagged release."
|
||||||
echo
|
echo
|
||||||
|
if [ $DRY_RUN ]; then
|
||||||
|
output 2 "This is a dry run, only the zip will be generated."
|
||||||
|
fi
|
||||||
echo
|
echo
|
||||||
echo "Before proceeding:"
|
echo "Before proceeding:"
|
||||||
echo " • Ensure you have checked out the branch you wish to release"
|
echo " • Ensure you have checked out the branch you wish to release"
|
||||||
|
@ -89,45 +93,53 @@ fi
|
||||||
output 2 "Starting release to GitHub..."
|
output 2 "Starting release to GitHub..."
|
||||||
echo
|
echo
|
||||||
|
|
||||||
# Create a release branch.
|
|
||||||
BRANCH="build/${VERSION}"
|
BRANCH="build/${VERSION}"
|
||||||
|
|
||||||
|
NOOP_ARG=""
|
||||||
|
DRY_RUN_ARG=""
|
||||||
|
if [ $DRY_RUN ]; then
|
||||||
|
NOOP_ARG="--noop"
|
||||||
|
DRY_RUN_ARG="--dry-run"
|
||||||
|
fi
|
||||||
|
|
||||||
|
# Create a release branch.
|
||||||
git checkout -b $BRANCH
|
git checkout -b $BRANCH
|
||||||
|
|
||||||
# Force add feature-config.php
|
# Force add feature-config.php
|
||||||
git add includes/feature-config.php --force
|
git add includes/feature-config.php --force $DRY_RUN_ARG
|
||||||
git add .
|
git add . $DRY_RUN_ARG
|
||||||
git commit -m "Adding feature-config.php directory to release" --no-verify
|
git commit -m "Adding feature-config.php directory to release" --no-verify $DRY_RUN_ARG
|
||||||
|
|
||||||
# Force add language files
|
# Force add language files
|
||||||
git add languages/woocommerce-admin.pot --force
|
git add languages/woocommerce-admin.pot --force $DRY_RUN_ARG
|
||||||
git add .
|
git add . $DRY_RUN_ARG
|
||||||
git commit -m "Adding translations to release" --no-verify
|
git commit -m "Adding translations to release" --no-verify $DRY_RUN_ARG
|
||||||
|
|
||||||
# Force add build directory and commit.
|
# Force add build directory and commit.
|
||||||
git add dist/. --force
|
git add dist/. --force $DRY_RUN_ARG
|
||||||
git add .
|
git add . $DRY_RUN_ARG
|
||||||
git commit -m "Adding /dist directory to release" --no-verify
|
git commit -m "Adding /dist directory to release" --no-verify $DRY_RUN_ARG
|
||||||
|
|
||||||
# Force add vendor directory and commit.
|
# Force add vendor directory and commit.
|
||||||
git add vendor/. --force
|
git add vendor/. --force $DRY_RUN_ARG
|
||||||
git add .
|
git add . $DRY_RUN_ARG
|
||||||
git commit -m "Adding /vendor directory to release" --no-verify
|
git commit -m "Adding /vendor directory to release" --no-verify $DRY_RUN_ARG
|
||||||
|
|
||||||
# Push branch upstream
|
# Push branch upstream
|
||||||
git push origin $BRANCH
|
git push origin $BRANCH $DRY_RUN_ARG
|
||||||
|
|
||||||
# Create the zip archive
|
# Create the zip archive
|
||||||
./bin/make-zip.sh $ZIP_FILE
|
./bin/make-zip.sh $ZIP_FILE
|
||||||
|
|
||||||
# Create the new release.
|
# Create the new release.
|
||||||
if [ $IS_PRE_RELEASE = true ]; then
|
if [ $IS_PRE_RELEASE = true ]; then
|
||||||
hub release create -m $VERSION -m "Release of version $VERSION. See readme.txt for details." -t $BRANCH --prerelease "v${VERSION}" --attach "${ZIP_FILE}"
|
hub $NOOP_ARG release create -m $VERSION -m "Release of version $VERSION. See readme.txt for details." -t $BRANCH --prerelease "v${VERSION}" --attach "${ZIP_FILE}"
|
||||||
else
|
else
|
||||||
hub release create -m $VERSION -m "Release of version $VERSION. See readme.txt for details." -t $BRANCH "v${VERSION}" --attach "${ZIP_FILE}"
|
hub $NOOP_ARG release create -m $VERSION -m "Release of version $VERSION. See readme.txt for details." -t $BRANCH "v${VERSION}" --attach "${ZIP_FILE}"
|
||||||
fi
|
fi
|
||||||
|
|
||||||
git checkout $CURRENTBRANCH
|
git checkout $CURRENTBRANCH
|
||||||
git branch -D $BRANCH
|
git branch -D $BRANCH
|
||||||
git push origin --delete $BRANCH
|
git push origin --delete $BRANCH $DRY_RUN_ARG
|
||||||
|
|
||||||
output 2 "GitHub release complete."
|
output 2 "GitHub release complete."
|
||||||
|
|
Loading…
Reference in New Issue