Add version string replacement script for deploy (https://github.com/woocommerce/woocommerce-blocks/pull/948)
* add version replacement script and load via github-deploy.sh script * update contributing doc accounting for version replacement script * ensure new version changes are committed. * set default variables and don’t change out $VID:$ when doing a pre-release * show pre-release detection before bumping versions * set the correct path for the version-changes script * conditionally use correct sed for environment. * switch to perl expression
This commit is contained in:
parent
d4cfd644b8
commit
cd44475081
|
@ -50,10 +50,9 @@ These instructions cover new releases of the blocks plugin for those with commit
|
|||
|
||||
**Before any release** ensure you update:
|
||||
|
||||
- The `readme.txt` file supported versions, version number, changelog and list of blocks if the release includes new blocks.
|
||||
- The version number in `woocommerce-gutenberg-products-block.php`
|
||||
- The version number in `package.json`
|
||||
- The version number in `src/Package.php`
|
||||
- The `readme.txt` file supported versions, changelog and list of blocks if the release includes new blocks.
|
||||
|
||||
> Note: version numbers will automatically be updated in files via the deploy script (see `bin/version-changes.sh`).
|
||||
|
||||
### Tagging new releases on GitHub
|
||||
|
||||
|
|
|
@ -52,7 +52,8 @@ echo
|
|||
echo "Before proceeding:"
|
||||
echo " • Ensure you have checked out the branch you wish to release"
|
||||
echo " • Ensure you have committed/pushed all local changes"
|
||||
echo " • Did you remember to update versions, changelogs, and stable tags in the readme and plugin files?"
|
||||
echo " • Did you remember to update changelogs, the readme and plugin files?"
|
||||
echo " • Are there any changes needed to the readme file?"
|
||||
echo " • If you are running this script directly instead of via '$ npm run deploy', ensure you have built assets and installed composer in --no-dev mode."
|
||||
echo
|
||||
output 3 "Do you want to continue? [y/N]: "
|
||||
|
@ -68,12 +69,24 @@ output 3 "Please enter the version number to tag, for example, 1.0.0:"
|
|||
read -r VERSION
|
||||
echo
|
||||
|
||||
CURRENTBRANCH="$(git rev-parse --abbrev-ref HEAD)"
|
||||
|
||||
# Check if is a pre-release.
|
||||
if is_substring "-" "${VERSION}"; then
|
||||
IS_PRE_RELEASE=true
|
||||
output 2 "Detected pre-release version!"
|
||||
fi
|
||||
|
||||
# Version changes
|
||||
output 2 "Updating version numbers in files..."
|
||||
source $RELEASER_PATH/bin/version-changes.sh
|
||||
|
||||
output 2 "Committing version change..."
|
||||
echo
|
||||
|
||||
git commit -am "Bumping version strings to new version." --no-verify
|
||||
git push origin $CURRENTBRANCH
|
||||
|
||||
if [ ! -d "build" ]; then
|
||||
output 3 "Build directory not found. Aborting."
|
||||
exit 1
|
||||
|
@ -91,8 +104,6 @@ fi
|
|||
output 2 "Starting release to GitHub..."
|
||||
echo
|
||||
|
||||
CURRENTBRANCH="$(git rev-parse --abbrev-ref HEAD)"
|
||||
|
||||
# Create a release branch.
|
||||
BRANCH="build/${VERSION}"
|
||||
git checkout -b $BRANCH
|
||||
|
|
|
@ -0,0 +1,20 @@
|
|||
#!/bin/sh
|
||||
VERSION=${VERSION:=\$VID\:\$}
|
||||
IS_PRE_RELEASE=${IS_PRE_RELEASE:=false}
|
||||
|
||||
# replace all instances of $VID:$ with the release version but only when not pre-release.
|
||||
if [ $IS_PRE_RELEASE = false ]; then
|
||||
find ./src -name "*.php" -print0 | xargs -0 perl -i -pe 's/\$VID:\$/'${VERSION}'/g'
|
||||
fi
|
||||
|
||||
# Update version number in readme.txt
|
||||
perl -i -pe 's/Stable tag:*.+/Stable tag: '${VERSION}'/' readme.txt
|
||||
|
||||
# Update version in main plugin file
|
||||
perl -i -pe 's/Version:*.+/Version: '${VERSION}'/' woocommerce-gutenberg-products-block.php
|
||||
|
||||
# Update version in package.json
|
||||
perl -i -pe 's/"version":*.+/"version": "'${VERSION}'",/' package.json
|
||||
|
||||
# Update version in main file
|
||||
perl -i -pe "s/VERSION =*.+/VERSION = '${VERSION}';/" src/Package.php
|
Loading…
Reference in New Issue