Skip to content

Commit

Permalink
Merge pull request #2529 from wordpress-mobile/release/1.34.0
Browse files Browse the repository at this point in the history
Release 1.34.0
  • Loading branch information
cameronvoell authored Aug 8, 2020
2 parents 33bfe15 + f2ac24f commit 7a532e7
Show file tree
Hide file tree
Showing 115 changed files with 2,392 additions and 2,253 deletions.
2 changes: 1 addition & 1 deletion .github/PULL_REQUEST_TEMPLATE.md
Original file line number Diff line number Diff line change
Expand Up @@ -5,4 +5,4 @@ To test:
PR submission checklist:

- [ ] I have considered adding unit tests where possible.
- [ ] I have considered if this change warrants user-facing release notes [more info](docs/Release-notes.md) and have added them to `[RELEASE-NOTES.txt](RELEASE-NOTES.txt)` if necessary.
- [ ] I have considered if this change warrants user-facing release notes [more info](https://github.com/wordpress-mobile/gutenberg-mobile/blob/develop/docs/Release-notes.md) and have added them to [RELEASE-NOTES.txt](https://github.com/wordpress-mobile/gutenberg-mobile/blob/develop/RELEASE-NOTES.txt) if necessary.
11 changes: 5 additions & 6 deletions .github/PULL_REQUEST_TEMPLATE/release_pull_request.md
Original file line number Diff line number Diff line change
Expand Up @@ -11,14 +11,13 @@ Release for Gutenberg Mobile v1.XX.Y

## Extra PRs that Landed After the Release Was Cut

- [ ] PR 1
- [ ] PR 2
No extra PRs yet. 🎉

## Changes
<!-- To determine the changes you can check the RELEASE-NOTES.txt file and cross check with the list of commits that are part of the PR -->
<!-- To determine the changes you can check the RELEASE-NOTES.txt and gutenberg/packages/react-native-editor/CHANGELOG.md files and cross check with the list of commits that are part of the PR -->

- Change 1
- Change 2
- Change 1: link-to-pr-describing-change-1
- Change 2: link-to-pr-describing-change-2

## Test plan

Expand All @@ -34,6 +33,6 @@ Release for Gutenberg Mobile v1.XX.Y
- iOS: Aztec dependencies match in `RNTAztecView.podspec` and `gutenberg/packages/react-native-aztec/RNTAztecView.podspec`.
- Android: 'grep aztecVersion react-native-aztec/android/build.gradle'.
- [ ] Gutenberg 'Podfile' and 'Podfile.lock' inside 'gutenberg/package/react-native-editor/ios/' are updated to the release number.
- [ ] Check if `RELEASE-NOTES.txt` and `gutenberg/packages/react-native-editor/CHANGELOG.md` are updated with all the changes that made it to the release.
- [ ] Bundle package of the release is updated.
- [ ] Check if `RELEASE-NOTES.txt` and `gutenberg/packages/react-native-editor/RELEASE-NOTES.txt` are updated with all the changes that made it to the release.

1 change: 1 addition & 0 deletions RELEASE-NOTES.txt
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@
* [***] Media editing support in Media & Text block.
* [***] New block: Social Icons
* [*] Cover block placeholder is updated to allow users start the block with a background color
* [*] Accessibility, update the title VoiceOver label to be more clear when you are editing the post or page title.

1.32.0
------
Expand Down
116 changes: 100 additions & 16 deletions bin/release_automation.sh
Original file line number Diff line number Diff line change
@@ -1,23 +1,36 @@
#!/bin/bash

# Check that Github CLI is installed
command -v gh >/dev/null || { echo "Error: The Github CLI must be installed."; exit 1; }
# Before creating the release, this script performs the following checks:
# - AztecAndroid and WordPress-Aztec-iOS are set to release versions
# - Release is being created off of either develop, main, or release/*
# - Release is being created off of a clean branch
# - Whether there are any open PRs targeting the milestone for the release

# Execute script commands from project's root directory
SCRIPT_PATH="$( cd "$( dirname "${BASH_SOURCE[0]}" )" >/dev/null 2>&1 && pwd )"
cd "$SCRIPT_PATH/.."

# Check current branch is develop, master, or release/* branch
source bin/release_prechecks.sh
source bin/release_utils.sh

# Check that Github CLI is installed
command -v gh >/dev/null || { echo "Error: The Github CLI must be installed."; exit 1; }

# Check that Aztec versions are set to release versions
aztec_version_problems="$(check_android_and_ios_aztec_versions)"
if [[ ! -z "$aztec_version_problems" ]]; then
printf "\nThere appear to be problems with the Aztec versions:\n$aztec_version_problems\n"
confirm_to_proceed "Do you want to proceed with the release despite the ^above^ problem(s) with the Aztec version?"
else
echo "Confirmed that Aztec Libraries are set to release versions. Proceeding..."
fi

## Check current branch is develop, main, or release/* branch
CURRENT_BRANCH=$(git rev-parse --abbrev-ref HEAD)
if [[ ! "$CURRENT_BRANCH" =~ "^develop$|^main$|^release/.*" ]]; then
echo "Releases should generally only be based on 'develop', 'main', or an earlier release branch."
echo "You are currently on the '$CURRENT_BRANCH' branch."
read -p "Are you sure you want to create a release branch from the '$CURRENT_BRANCH' branch? (y/n) " -n 1
echo ""
if [[ ! $REPLY =~ ^[Yy]$ ]]; then
printf "Aborting release...\n"
exit 1
fi
confirm_to_proceed "Are you sure you want to create a release branch from the '$CURRENT_BRANCH' branch?"
fi

# Confirm branch is clean
Expand All @@ -27,10 +40,22 @@ fi
CURRENT_VERSION_NUMBER=$(./node_modules/.bin/json -f package.json version)
echo "Current Version Number:$CURRENT_VERSION_NUMBER"
read -p "Enter the new version number: " VERSION_NUMBER
if [[ -z "$VERSION_NUMBER" ]]; then
echo "Version number cannot be empty."
exit 1
fi

# Insure javascript dependencies are up-to-date
npm ci || { echo "Error: 'npm ci' failed"; echo 1; }


# If there are any open PRs with a milestone matching the release version number, notify the user and ask them if they want to proceed
number_milestone_prs=$(check_if_version_has_pending_prs_for_milestone "$VERSION_NUMBER")
if [[ ! -z "$number_milestone_prs" ]] && [[ "0" != "$number_milestone_prs" ]]; then
echo "There are currently $number_milestone_prs PRs with a milestone matching $VERSION_NUMBER."
confirm_to_proceed "Do you want to proceed with cutting the release?"
fi

# Create Git branch
RELEASE_BRANCH="release/$VERSION_NUMBER"
git switch -c "$RELEASE_BRANCH" || { echo "Error: could not create '$RELEASE_BRANCH' branch."; exit 1; }
Expand Down Expand Up @@ -74,25 +99,84 @@ cd ..
# Update the bundles
npm run bundle || { printf "\nError: 'npm bundle' failed.\nIf there is an error stating something like \"Command 'bundle' unrecognized.\" above, perhaps try running 'rm -rf node_modules gutenberg/node_modules && npm install'.\n"; exit 1; }

# Commit bundle changes
# Commit bundle changes along with any update to the gutenberg submodule (if necessary)
git commit -a -m "Release script: Update bundle for: $VERSION_NUMBER" || { echo "Error: failed to commit changes"; exit 1; }

# Verify before publishing a PR
read -p "This script will now create a PR on Github. Would you like to proceed? (y/n) " -n 1

#####
# Create PRs
#####

# Verify before creating PRs
echo "This script will now create a Gutenberg-Mobile PR for the $RELEASE_BRANCH branch and a Gutenberg PR for the $GB_RELEASE_BRANCH branch."
read -p "Would you like to proceed? (y/n) " -n 1
if [[ $REPLY =~ ^[Yy]$ ]]; then
printf "\n\nProceeding to create a PR...\n"
else
printf "\n\nFinishing release script without creating a PR\n"
exit 1
fi

# Read PR template

#####
# Gutenberg-Mobile PR
#####

# Read GB-Mobile PR template
PR_TEMPLATE_PATH='.github/PULL_REQUEST_TEMPLATE/release_pull_request.md'
test -f "$PR_TEMPLATE_PATH" || { echo "Error: Could not find PR template at $PR_TEMPLATE_PATH"; exit 1; }
PR_TEMPLATE=$(cat "$PR_TEMPLATE_PATH")

# Replace version number in PR template
# Replace version number in GB-Mobile PR template
PR_BODY=${PR_TEMPLATE//v1.XX.Y/$VERSION_NUMBER}

# Create PR in GitHub
gh pr create -t "Release $VERSION_NUMBER" -b "$PR_BODY" -B main -l "release-process" -d || { echo "Error: Failed to create PR"; exit 1; }
# Insure PR is created on proper remote
# see https://github.com/cli/cli/issues/800
BASE_REMOTE=$(get_remote_name 'wordpress-mobile/gutenberg-mobile')
git push -u "$BASE_REMOTE" HEAD || { echo "Unable to push to remote $BASE_REMOTE"; exit 1; }

# Create Draft GB-Mobile Release PR in GitHub
GB_MOBILE_PR_URL=$(gh pr create --title "Release $VERSION_NUMBER" --body "$PR_BODY" --base main --label "release-process" --draft)
if [[ $? != 0 ]]; then
echo "Error: Failed to create Gutenberg-Mobile PR"
exit 1
fi


#####
# Gutenberg PR
#####

# Get Checklist from Gutenberg PR template
cd gutenberg
GUTENBERG_PR_TEMPLATE_PATH=".github/PULL_REQUEST_TEMPLATE.md"
test -f "$GUTENBERG_PR_TEMPLATE_PATH" || { echo "Error: Could not find PR template at $GUTENBERG_PR_TEMPLATE_PATH"; exit 1; }
# Get the checklist from the gutenberg PR template by removing everything before the '## Checklist:' line
CHECKLIST_FROM_GUTENBERG_PR_TEMPLATE=$(cat "$GUTENBERG_PR_TEMPLATE_PATH" | sed -e/'## Checklist:'/\{ -e:1 -en\;b1 -e\} -ed)

# Construct body for Gutenberg release PR
GUTENBERG_PR_BEGINNING="## Description
Release $VERSION_NUMBER of the react-native-editor and Gutenberg-Mobile.
For more information about this release and testing instructions, please see the related Gutenberg-Mobile PR: $GB_MOBILE_PR_URL"
GUTENBERG_PR_BODY="$GUTENBERG_PR_BEGINNING
$CHECKLIST_FROM_GUTENBERG_PR_TEMPLATE"

# Insure PR is created on proper remote
# see https://github.com/cli/cli/issues/800
GB_BASE_REMOTE=$(get_remote_name 'WordPress/gutenberg')
git push -u "$GB_BASE_REMOTE" HEAD || { echo "Unable to push to remote: $GB_BASE_REMOTE"; exit 1; }

# Create Draft Gutenberg Release PR in GitHub
GUTENBERG_PR_URL=$(gh pr create --title "Mobile Release v$VERSION_NUMBER" --body "$GUTENBERG_PR_BODY" --base master --label 'Mobile App Android/iOS' --draft)
if [[ $? != 0 ]]; then
echo "Error: Failed to create Gutenberg PR"
exit 1
fi
cd ..

echo "PRs Created"
echo "==========="
printf "Gutenberg-Mobile $GB_MOBILE_PR_URL
Gutenberg $GUTENBERG_PR_URL\n" | column -t
94 changes: 94 additions & 0 deletions bin/release_prechecks.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,94 @@
#!/bin/bash

# Execute script commands from project's root directory
SCRIPT_PATH="$( cd "$( dirname "${BASH_SOURCE[0]}" )" >/dev/null 2>&1 && pwd )"
cd "$SCRIPT_PATH/.."

#####
# Confirm to Proceed Prompt
#####

# Accepts a single argument: a yes/no question (ending with a ? most likely) to ask the user
function confirm_to_proceed() {
read -p "$1 (y/n) " -n 1
echo ""
if [[ ! $REPLY =~ ^[Yy]$ ]]; then
printf "Aborting release...\n"
exit 1
fi
}

#####
# PR Milestone check
#####

function check_num_milestone_prs() {
MILESTONE_NAME="$1"
curl -s -H "Accept: application/vnd.github.v3+json" \
"https://api.github.com/repos/wordpress-mobile/gutenberg-mobile/milestones" \
| npx json -c "this.title === '$MILESTONE_NAME'" -a open_issues
}

function check_if_version_has_pending_prs_for_milestone() {
number_milestone_prs=$(check_num_milestone_prs "$VERSION_NUMBER")
# If we got no results and the version ends with ".0"
if [[ -z "$number_milestone_prs" ]] && [[ "$VERSION_NUMBER" =~ [0-9]+\.[0-9]+\.0$ ]]; then
# Remove the ending ".0" and check again because we usually drop ".0" from our
# milestones. For example, the milestone for 1.34.0 was 1.34
version_without_dot_zero=$(echo "$VERSION_NUMBER" | rev | cut -c 3- | rev)
number_milestone_prs=$(check_num_milestone_prs "$version_without_dot_zero")
fi
echo "$number_milestone_prs"
}


#####
# Check for Aztec Release Versions
#####

SEMANTIC_VERSION_REGEX='\d+\.\d+\.\d+'

function check_android_aztec_is_release_version() {
react_native_aztec_gradle='gutenberg/packages/react-native-aztec/android/build.gradle'
release_version=$(grep aztecVersion "$react_native_aztec_gradle" | grep -oE "$SEMANTIC_VERSION_REGEX")
if [[ -z "$release_version" ]]; then
echo "A release version for AztecAndroid was not found in $react_native_aztec_gradle"
fi
}

function check_ios_aztec_is_release_version() {
result=''

podspec_file='RNTAztecView.podspec'
aztec_version=$(grep WordPress-Aztec-iOS "$podspec_file" | grep -oE "$SEMANTIC_VERSION_REGEX")
if [[ -z "$aztec_version" ]]; then
result="A release version for WordPress-Aztec-iOS was not found in $podspec_file"
fi

podfile='gutenberg/packages/react-native-editor/ios/Podfile'
commented_out_reference_in_podfile=$(grep -E "# *pod 'WordPress-Aztec-iOS'" "$podfile")
if [[ -z "$commented_out_reference_in_podfile" ]]; then
message="The developer version of WordPress-Aztec-iOS was not commented out in $podfile"
if [[ -z "$result" ]]; then
result="$message"
else
result="${result}\n${message}"
fi

fi

echo "$result"
}

# If any problems, the problems are each printed on their own line
function check_android_and_ios_aztec_versions() {
android_result=$(check_android_aztec_is_release_version)
ios_result=$(check_ios_aztec_is_release_version)
if [[ ! -z "$android_result" ]]; then
echo "${android_result}\n${ios_result}"
else
echo "$ios_result"
fi
}

printf "$(check_android_and_ios_aztec_versions)\n"
8 changes: 8 additions & 0 deletions bin/release_utils.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
#!/bin/bash

# Accepts the repository owner/name (wordpress-mobile/gutenberg-mobile) and returns
# the locally matching remote
function get_remote_name() {
REPO="$1"
git remote -v | grep "git@github.com:$REPO.git (push)" | grep -oE '^\S*'
}
Loading

0 comments on commit 7a532e7

Please sign in to comment.