Closed mokagio closed 1 year ago
@mokagio I bumped into an issue when installing Pods in the XCFramework folder and generating the RN bundle (e.g. running npm command npm run bundle:android
).
Error:
error While trying to resolve module `react-native` from file `<WORKSPACE>/gutenberg-mobile/block-experiments/blocks/layout-grid/src/grid/edit.native.js`, the package `<WORKSPACE>/gutenberg-mobile/ios-xcframework/Pods/React/package.json` was successfully found. However, this package itself specifies a `main` module field that could not be resolved (`<WORKSPACE>/gutenberg-mobile/ios-xcframework/Pods/React/index`. Indeed, none of these files exist:
* <WORKSPACE>/gutenberg-mobile/ios-xcframework/Pods/React/index(.native|.android.js|.native.js|.js|.android.cjs|.native.cjs|.cjs|.android.jsx|.native.jsx|.jsx|.android.json|.native.json|.json|.android.scss|.native.scss|.scss|.android.sass|.native.sass|.sass|.android.ts|.native.ts|.ts|.android.tsx|.native.tsx|.tsx)
* <WORKSPACE>/gutenberg-mobile/ios-xcframework/Pods/React/index/index(.native|.android.js|.native.js|.js|.android.cjs|.native.cjs|.cjs|.android.jsx|.native.jsx|.jsx|.android.json|.native.json|.json|.android.scss|.native.scss|.scss|.android.sass|.native.sass|.sass|.android.ts|.native.ts|.ts|.android.tsx|.native.tsx|.tsx).
Error: While trying to resolve module `react-native` from file `<WORKSPACE>/gutenberg-mobile/block-experiments/blocks/layout-grid/src/grid/edit.native.js`, the package `<WORKSPACE>/gutenberg-mobile/ios-xcframework/Pods/React/package.json` was successfully found. However, this package itself specifies a `main` module field that could not be resolved (`<WORKSPACE>/gutenberg-mobile/ios-xcframework/Pods/React/index`. Indeed, none of these files exist:
* <WORKSPACE>/gutenberg-mobile/ios-xcframework/Pods/React/index(.native|.android.js|.native.js|.js|.android.cjs|.native.cjs|.cjs|.android.jsx|.native.jsx|.jsx|.android.json|.native.json|.json|.android.scss|.native.scss|.scss|.android.sass|.native.sass|.sass|.android.ts|.native.ts|.ts|.android.tsx|.native.tsx|.tsx)
* <WORKSPACE>/gutenberg-mobile/ios-xcframework/Pods/React/index/index(.native|.android.js|.native.js|.js|.android.cjs|.native.cjs|.cjs|.android.jsx|.native.jsx|.jsx|.android.json|.native.json|.json|.android.scss|.native.scss|.scss|.android.sass|.native.sass|.sass|.android.ts|.native.ts|.ts|.android.tsx|.native.tsx|.tsx)
at DependencyGraph.resolveDependency (<WORKSPACE>/gutenberg-mobile/node_modules/metro/src/node-haste/DependencyGraph.js:243:17)
at Object.resolve (<WORKSPACE>/gutenberg-mobile/node_modules/metro/src/lib/transformHelpers.js:129:24)
at resolve (<WORKSPACE>/gutenberg-mobile/node_modules/metro/src/DeltaBundler/traverseDependencies.js:396:33)
at <WORKSPACE>/gutenberg-mobile/node_modules/metro/src/DeltaBundler/traverseDependencies.js:412:26
at Array.reduce (<anonymous>)
at resolveDependencies (<WORKSPACE>/gutenberg-mobile/node_modules/metro/src/DeltaBundler/traverseDependencies.js:411:33)
at processModule (<WORKSPACE>/gutenberg-mobile/node_modules/metro/src/DeltaBundler/traverseDependencies.js:140:31)
at runMicrotasks (<anonymous>)
at processTicksAndRejections (internal/process/task_queues.js:95:5)
at async addDependency (<WORKSPACE>/gutenberg-mobile/node_modules/metro/src/DeltaBundler/traverseDependencies.js:230:18)
Seems Metro is trying to resolve React Native using the React package from one of the Pods. Maybe we could tweak the Metro configuration somehow to ignore it. I can try to take a look at this in the next few days.
Thanks @fluiddot
Ah, I run into that too and tried to make the automation ignore the ios-xcframework
folder tinkering the config files but didn't get to the bottom of it. My issue was when trying to run tests, though. The ones I tried were Jest's and Watchman's.
Ultimately, I brushed that away assuming that "no one would need to use the XCFramework project locally," π That's obviously an unsatisfactory conclusion.
Fingers crossed you can sort it out π€
Ultimately, I brushed that away assuming that "no one would need to use the XCFramework project locally," π That's obviously an unsatisfactory conclusion.
I think I forgot to mention that I ran into the issue after running the release script for testing this PR. So, I think that with this change we might start experiencing it after cutting a new release. Note that the script by default will install the Pods in the same Gutenberg Mobile project we use for development.
I'll try to spare some time today on this and find out how to tweak Metro's configuration to ignore files/folders.
I'll try to spare some time today on this and find out how to tweak Metro's configuration to ignore files/folders.
I found a Metro configuration parameter to solve this, I created https://github.com/wordpress-mobile/gutenberg-mobile/pull/5819 with the fix. @mokagio let me know if you could take a quick look, thanks π !
This is necessary after the introduction of the XCFramework builder project in https://github.com/wordpress-mobile/gutenberg-mobile/pull/5739 and https://github.com/wordpress-mobile/gutenberg-mobile/pull/5740.
Worth noting that the XCFramework distribution pipeline and integration in Jetpack and WordPress iOS is currently incomplete. The step is required to avoid a CI failure but has not effect on the quality of the final release. This will hopefully change within the next couple of releases.
Update: I run a manual test after following @fluiddot's suggestion:
The script starts and eventually reaches the new step...
...which succeeds
This is the commit:
For reference, here's the diff for the modified version of the script that I used
```diff --- a/release_automation.sh +++ b/release_automation.sh @@ -50,35 +50,35 @@ if ! [[ $REPLY =~ ^[Yy]$ ]]; then fi # Check if script is up-to-date -LOCAL_COMMIT=$(git rev-parse HEAD) -execute "git" "remote" "update" -DEFAULT_BRANCH_HEAD=$(git rev-parse 'trunk@{upstream}') -if ! [[ "$LOCAL_COMMIT" = "$DEFAULT_BRANCH_HEAD" ]]; then - echo "" - echo "You're not running this script from the HEAD commit on the default branch, 'trunk'." - echo "If you are generating a release you should generally use the latest version of the script." - read -r -p "Are you sure you want the script to proceed? (y/n) " - echo "" - if ! [[ $REPLY =~ ^[Yy]$ ]]; then - abort "Exiting script..." - fi -fi - -# Check if script has uncommitted changes -if [ -n "$(git status --porcelain)" ]; then - echo "You are running this script with uncommitted changes." - echo "If you are generating a release you should generally use the current version of the script on the develop branch." - read -r -p "Are you sure you want the script to proceed? (y/n) " - echo "" - if ! [[ $REPLY =~ ^[Yy]$ ]]; then - abort "Exiting script..." - fi -fi - -# Read GB-Mobile PR template -PR_TEMPLATE_PATH='./release_pull_request.md' -test -f "$PR_TEMPLATE_PATH" || abort "Error: Could not find PR template at $PR_TEMPLATE_PATH" -PR_TEMPLATE=$(cat "$PR_TEMPLATE_PATH") +# LOCAL_COMMIT=$(git rev-parse HEAD) +# execute "git" "remote" "update" +# DEFAULT_BRANCH_HEAD=$(git rev-parse 'trunk@{upstream}') +# if ! [[ "$LOCAL_COMMIT" = "$DEFAULT_BRANCH_HEAD" ]]; then +# echo "" +# echo "You're not running this script from the HEAD commit on the default branch, 'trunk'." +# echo "If you are generating a release you should generally use the latest version of the script." +# read -r -p "Are you sure you want the script to proceed? (y/n) " +# echo "" +# if ! [[ $REPLY =~ ^[Yy]$ ]]; then +# abort "Exiting script..." +# fi +# fi + +# # Check if script has uncommitted changes +# if [ -n "$(git status --porcelain)" ]; then +# echo "You are running this script with uncommitted changes." +# echo "If you are generating a release you should generally use the current version of the script on the develop branch." +# read -r -p "Are you sure you want the script to proceed? (y/n) " +# echo "" +# if ! [[ $REPLY =~ ^[Yy]$ ]]; then +# abort "Exiting script..." +# fi +# fi + +# # Read GB-Mobile PR template +# PR_TEMPLATE_PATH='./release_pull_request.md' +# test -f "$PR_TEMPLATE_PATH" || abort "Error: Could not find PR template at $PR_TEMPLATE_PATH" +# PR_TEMPLATE=$(cat "$PR_TEMPLATE_PATH") # Ask for path to gutenberg-mobile directory # (default is sibling directory of gutenberg-mobile-release-toolkit) @@ -96,136 +96,136 @@ source ./release_prechecks.sh "$GB_MOBILE_PATH" # Execute script commands from gutenberg-mobile directory cd "$GB_MOBILE_PATH" -# Check that Github CLI is installed -command -v gh >/dev/null || abort "Error: The Github CLI must be installed." - -# Check that Github CLI is logged -gh auth status >/dev/null 2>&1 || abort "Error: You are not logged into any GitHub hosts. Run 'gh auth login' to authenticate." - -# Check that jq is installed -command -v jq >/dev/null || abort "Error: jq must be installed." - -# Check that Aztec versions are set to release versions -aztec_version_problems="$(check_android_and_ios_aztec_versions)" -if [[ -n "$aztec_version_problems" ]]; then - warn "There appear to be problems with the Aztec versions:\n$aztec_version_problems" - confirm_to_proceed "Do you want to proceed with the release despite the ^above^ problem(s) with the Aztec version?" -else - ohai "Confirmed that Aztec Libraries are set to release versions. Proceeding..." -fi - -# Check if current HEAD is on trunk -CURRENT_BRANCH=$(git rev-parse --abbrev-ref HEAD) -if [[ ! "$CURRENT_BRANCH" =~ ^trunk$ ]]; then - - # Check if current HEAD is a release tag - CURRENT_TAG=$(git tag --points-at HEAD) - if [[ ! "$CURRENT_TAG" =~ v[0-9]+\.[0-9]+\.[0-9]+ ]]; then - warn "Releases should generally only be based on 'trunk', or a release tag." - warn "Gutenberg-Mobile is currently on the '$CURRENT_BRANCH' branch and '$CURRENT_TAG' tag." - confirm_to_proceed "Are you sure you want to create a release branch from here?" - fi -fi - -# Confirm branch is clean -[[ -z "$(git status --porcelain)" ]] || { git status; abort "Uncommitted changes found. Aborting release script..."; } - -# Ask for new version number -CURRENT_VERSION_NUMBER=$(jq '.version' package.json --raw-output) -echo "Current Version Number:$CURRENT_VERSION_NUMBER" -read -r -p "Enter the new version number: " VERSION_NUMBER -if [[ -z "$VERSION_NUMBER" ]]; then - abort "Version number cannot be empty." -fi - -# Ensure javascript dependencies are up-to-date -read -r -p "Run 'npm ci' to ensure javascript dependencies are up-to-date? (y/n) " -n 1 -echo "" -if [[ $REPLY =~ ^[Yy]$ ]]; then - execute "npm" "ci" -fi - -# 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 [[ -n "$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 +# # Check that Github CLI is installed +# command -v gh >/dev/null || abort "Error: The Github CLI must be installed." + +# # Check that Github CLI is logged +# gh auth status >/dev/null 2>&1 || abort "Error: You are not logged into any GitHub hosts. Run 'gh auth login' to authenticate." + +# # Check that jq is installed +# command -v jq >/dev/null || abort "Error: jq must be installed." + +# # Check that Aztec versions are set to release versions +# aztec_version_problems="$(check_android_and_ios_aztec_versions)" +# if [[ -n "$aztec_version_problems" ]]; then +# warn "There appear to be problems with the Aztec versions:\n$aztec_version_problems" +# confirm_to_proceed "Do you want to proceed with the release despite the ^above^ problem(s) with the Aztec version?" +# else +# ohai "Confirmed that Aztec Libraries are set to release versions. Proceeding..." +# fi + +# # Check if current HEAD is on trunk +# CURRENT_BRANCH=$(git rev-parse --abbrev-ref HEAD) +# if [[ ! "$CURRENT_BRANCH" =~ ^trunk$ ]]; then + +# # Check if current HEAD is a release tag +# CURRENT_TAG=$(git tag --points-at HEAD) +# if [[ ! "$CURRENT_TAG" =~ v[0-9]+\.[0-9]+\.[0-9]+ ]]; then +# warn "Releases should generally only be based on 'trunk', or a release tag." +# warn "Gutenberg-Mobile is currently on the '$CURRENT_BRANCH' branch and '$CURRENT_TAG' tag." +# confirm_to_proceed "Are you sure you want to create a release branch from here?" +# fi +# fi + +# # Confirm branch is clean +# [[ -z "$(git status --porcelain)" ]] || { git status; abort "Uncommitted changes found. Aborting release script..."; } + +# # Ask for new version number +# CURRENT_VERSION_NUMBER=$(jq '.version' package.json --raw-output) +# echo "Current Version Number:$CURRENT_VERSION_NUMBER" +# read -r -p "Enter the new version number: " VERSION_NUMBER +# if [[ -z "$VERSION_NUMBER" ]]; then +# abort "Version number cannot be empty." +# fi + +# # Ensure javascript dependencies are up-to-date +# read -r -p "Run 'npm ci' to ensure javascript dependencies are up-to-date? (y/n) " -n 1 +# echo "" +# if [[ $REPLY =~ ^[Yy]$ ]]; then +# execute "npm" "ci" +# fi + +# # 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 [[ -n "$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" +RELEASE_BRANCH="release/test" ohai "Create Git branch '$RELEASE_BRANCH' in gutenberg-mobile." execute "git" "switch" "-c" "$RELEASE_BRANCH" -# Create Git branch in Gutenberg -GB_RELEASE_BRANCH="rnmobile/release_$VERSION_NUMBER" -ohai "Create Git branch '$GB_RELEASE_BRANCH' in gutenberg." -cd gutenberg -execute "git" "switch" "-c" "$GB_RELEASE_BRANCH" -cd .. - -# Set version numbers -ohai "Set version numbers in package.json files" -for file in 'package.json' 'package-lock.json' 'gutenberg/packages/react-native-aztec/package.json' 'gutenberg/packages/react-native-bridge/package.json' 'gutenberg/packages/react-native-editor/package.json'; do - TEMP_FILE=$(mktemp) - execute "jq" ".version = \"$VERSION_NUMBER\"" "$file" > "$TEMP_FILE" "--tab" - execute "mv" "$TEMP_FILE" "$file" -done - -# Commit react-native-aztec, react-native-bridge, react-native-editor version update -ohai "Commit react-native-aztec, react-native-bridge, react-native-editor version update version update" -cd gutenberg -git add 'packages/react-native-aztec/package.json' 'packages/react-native-bridge/package.json' 'packages/react-native-editor/package.json' -execute "git" "commit" "-m" "Release script: Update react-native-editor version to $VERSION_NUMBER" -cd .. - -# Commit gutenberg-mobile version updates -ohai "Commit gutenberg-mobile version updates" -git add 'package.json' 'package-lock.json' -execute "git" "commit" "-m" "Release script: Update gb mobile version to $VERSION_NUMBER" - -# Make sure podfile is updated -ohai "Make sure podfile is updated" -PRE_IOS_COMMAND="npm run core preios" -eval "$PRE_IOS_COMMAND" - -# If preios results in changes, commit them -cd gutenberg -if [[ -n "$(git status --porcelain)" ]]; then - ohai "Commit changes from '$PRE_IOS_COMMAND'" - execute "git" "commit" "-a" "-m" "Release script: Update with changes from '$PRE_IOS_COMMAND'" -else - ohai "There were no changes from '$PRE_IOS_COMMAND' to be committed." -fi -cd .. - -# Ask if a cherry-pick is needed before bundling (for example if this is a hotfix release) -cd gutenberg -CHERRY_PICK_PROMPT="Do you want to cherry-pick a commit from gutenberg? (y/n) " -while - read -r -p "$CHERRY_PICK_PROMPT" -n 1 - echo "" - [[ $REPLY =~ ^[Yy]$ ]] -do - read -r -p "Enter the commit hash to cherry-pick: " GUTENBERG_COMMIT_HASH_TO_CHERRY_PICK - execute "git" "cherry-pick" "$GUTENBERG_COMMIT_HASH_TO_CHERRY_PICK" - CHERRY_PICK_PROMPT="Do you want to cherry-pick another commit from gutenberg? (y/n) " -done -cd .. - -# Commit updates to gutenberg submodule -ohai "Commit updates to gutenberg submodule" -execute "git" "add" "gutenberg" -execute "git" "commit" "-m" "Release script: Update gutenberg ref" - -# Update the bundles -ohai "Update the bundles" -npm run bundle || abort "Error: '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 ci'." - -# Commit bundle changes -ohai "Commit bundle changes" -execute "git" "add" "bundle/" -execute "git" "commit" "-m" "Release script: Update bundle for: $VERSION_NUMBER" +# # Create Git branch in Gutenberg +# GB_RELEASE_BRANCH="rnmobile/release_$VERSION_NUMBER" +# ohai "Create Git branch '$GB_RELEASE_BRANCH' in gutenberg." +# cd gutenberg +# execute "git" "switch" "-c" "$GB_RELEASE_BRANCH" +# cd .. + +# # Set version numbers +# ohai "Set version numbers in package.json files" +# for file in 'package.json' 'package-lock.json' 'gutenberg/packages/react-native-aztec/package.json' 'gutenberg/packages/react-native-bridge/package.json' 'gutenberg/packages/react-native-editor/package.json'; do +# TEMP_FILE=$(mktemp) +# execute "jq" ".version = \"$VERSION_NUMBER\"" "$file" > "$TEMP_FILE" "--tab" +# execute "mv" "$TEMP_FILE" "$file" +# done + +# # Commit react-native-aztec, react-native-bridge, react-native-editor version update +# ohai "Commit react-native-aztec, react-native-bridge, react-native-editor version update version update" +# cd gutenberg +# git add 'packages/react-native-aztec/package.json' 'packages/react-native-bridge/package.json' 'packages/react-native-editor/package.json' +# execute "git" "commit" "-m" "Release script: Update react-native-editor version to $VERSION_NUMBER" +# cd .. + +# # Commit gutenberg-mobile version updates +# ohai "Commit gutenberg-mobile version updates" +# git add 'package.json' 'package-lock.json' +# execute "git" "commit" "-m" "Release script: Update gb mobile version to $VERSION_NUMBER" + +# # Make sure podfile is updated +# ohai "Make sure podfile is updated" +# PRE_IOS_COMMAND="npm run core preios" +# eval "$PRE_IOS_COMMAND" + +# # If preios results in changes, commit them +# cd gutenberg +# if [[ -n "$(git status --porcelain)" ]]; then +# ohai "Commit changes from '$PRE_IOS_COMMAND'" +# execute "git" "commit" "-a" "-m" "Release script: Update with changes from '$PRE_IOS_COMMAND'" +# else +# ohai "There were no changes from '$PRE_IOS_COMMAND' to be committed." +# fi +# cd .. + +# # Ask if a cherry-pick is needed before bundling (for example if this is a hotfix release) +# cd gutenberg +# CHERRY_PICK_PROMPT="Do you want to cherry-pick a commit from gutenberg? (y/n) " +# while +# read -r -p "$CHERRY_PICK_PROMPT" -n 1 +# echo "" +# [[ $REPLY =~ ^[Yy]$ ]] +# do +# read -r -p "Enter the commit hash to cherry-pick: " GUTENBERG_COMMIT_HASH_TO_CHERRY_PICK +# execute "git" "cherry-pick" "$GUTENBERG_COMMIT_HASH_TO_CHERRY_PICK" +# CHERRY_PICK_PROMPT="Do you want to cherry-pick another commit from gutenberg? (y/n) " +# done +# cd .. + +# # Commit updates to gutenberg submodule +# ohai "Commit updates to gutenberg submodule" +# execute "git" "add" "gutenberg" +# execute "git" "commit" "-m" "Release script: Update gutenberg ref" + +# # Update the bundles +# ohai "Update the bundles" +# npm run bundle || abort "Error: '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 ci'." + +# # Commit bundle changes +# ohai "Commit bundle changes" +# execute "git" "add" "bundle/" +# execute "git" "commit" "-m" "Release script: Update bundle for: $VERSION_NUMBER" # Update the Podfile for the XCFramework builder project # @@ -245,191 +245,191 @@ cd .. # Create PRs ##### -# Verify before creating PRs -confirm_to_proceed "Do you want to proceed with creating a Gutenberg-Mobile PR for the $RELEASE_BRANCH branch and a Gutenberg PR for the $GB_RELEASE_BRANCH branch." -ohai "Proceeding to create PRs..." +## Verify before creating PRs +#confirm_to_proceed "Do you want to proceed with creating a Gutenberg-Mobile PR for the $RELEASE_BRANCH branch and a Gutenberg PR for the $GB_RELEASE_BRANCH branch." +#ohai "Proceeding to create PRs..." -##### -# Gutenberg-Mobile PR -##### +###### +## Gutenberg-Mobile PR +###### -# Replace version number in GB-Mobile PR template -PR_BODY=${PR_TEMPLATE//v1.XX.Y/$VERSION_NUMBER} +## Replace version number in GB-Mobile PR template +#PR_BODY=${PR_TEMPLATE//v1.XX.Y/$VERSION_NUMBER} -execute "git" "push" "-u" "origin" "HEAD" +#execute "git" "push" "-u" "origin" "HEAD" -# Create Draft GB-Mobile Release PR in GitHub -GB_MOBILE_PR_URL=$(execute "gh" "pr" "create" \ -"--title" "Release $VERSION_NUMBER" \ -"--body" "$PR_BODY" \ -"--repo" "$MOBILE_REPO/gutenberg-mobile" \ -"--head" "$MOBILE_REPO:$RELEASE_BRANCH" \ -"--base" "$GUTENBERG_MOBILE_TARGET_BRANCH" \ -"--label" "$GUTENBERG_MOBILE_PR_LABEL" \ -"--draft") +## Create Draft GB-Mobile Release PR in GitHub +#GB_MOBILE_PR_URL=$(execute "gh" "pr" "create" \ +#"--title" "Release $VERSION_NUMBER" \ +#"--body" "$PR_BODY" \ +#"--repo" "$MOBILE_REPO/gutenberg-mobile" \ +#"--head" "$MOBILE_REPO:$RELEASE_BRANCH" \ +#"--base" "$GUTENBERG_MOBILE_TARGET_BRANCH" \ +#"--label" "$GUTENBERG_MOBILE_PR_LABEL" \ +#"--draft") -##### -# Gutenberg PR -##### +###### +## 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" || abort "Error: Could not find PR template at $GUTENBERG_PR_TEMPLATE_PATH" -# Get the checklist from the gutenberg PR template by removing everything before the '## Checklist:' line -CHECKLIST_FROM_GUTENBERG_PR_TEMPLATE=$(sed -e/'## Checklist:'/\{ -e:1 -en\;b1 -e\} -ed < "$GUTENBERG_PR_TEMPLATE_PATH") - -# 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" - -execute "git" "push" "-u" "origin" "HEAD" - -# Create Draft Gutenberg Release PR in GitHub -GUTENBERG_PR_URL=$(execute "gh" "pr" "create" \ -"--title" "Mobile Release v$VERSION_NUMBER" \ -"--body" "$GUTENBERG_PR_BODY" \ -"--repo" "$GUTENBERG_REPO/gutenberg" \ -"--head" "$GUTENBERG_REPO:$GB_RELEASE_BRANCH" \ -"--base" "$GUTENBERG_TARGET_BRANCH" \ -"--label" "$GUTENBERG_PR_LABEL" \ -"--draft") -cd .. +## Get Checklist from Gutenberg PR template +#cd gutenberg +#GUTENBERG_PR_TEMPLATE_PATH=".github/PULL_REQUEST_TEMPLATE.md" +#test -f "$GUTENBERG_PR_TEMPLATE_PATH" || abort "Error: Could not find PR template at $GUTENBERG_PR_TEMPLATE_PATH" +## Get the checklist from the gutenberg PR template by removing everything before the '## Checklist:' line +#CHECKLIST_FROM_GUTENBERG_PR_TEMPLATE=$(sed -e/'## Checklist:'/\{ -e:1 -en\;b1 -e\} -ed < "$GUTENBERG_PR_TEMPLATE_PATH") -echo "PRs Created" -echo "===========" -printf "Gutenberg-Mobile PR %s \n Gutenberg %s \n" "$GB_MOBILE_PR_URL" "$GUTENBERG_PR_URL" | column -t +## Construct body for Gutenberg release PR +#GUTENBERG_PR_BEGINNING="## Description +#Release $VERSION_NUMBER of the react-native-editor and Gutenberg-Mobile. -confirm_to_proceed "Do you want to proceed with creating main apps (WPiOS and WPAndroid) PRs?" -ohai "Proceeding to create main apps PRs..." +#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 -GB_MOBILE_PR_REF=$(git rev-parse HEAD) +#$CHECKLIST_FROM_GUTENBERG_PR_TEMPLATE" + +#execute "git" "push" "-u" "origin" "HEAD" -WP_APPS_PR_TITLE="Integrate gutenberg-mobile release $VERSION_NUMBER" +## Create Draft Gutenberg Release PR in GitHub +#GUTENBERG_PR_URL=$(execute "gh" "pr" "create" \ +#"--title" "Mobile Release v$VERSION_NUMBER" \ +#"--body" "$GUTENBERG_PR_BODY" \ +#"--repo" "$GUTENBERG_REPO/gutenberg" \ +#"--head" "$GUTENBERG_REPO:$GB_RELEASE_BRANCH" \ +#"--base" "$GUTENBERG_TARGET_BRANCH" \ +#"--label" "$GUTENBERG_PR_LABEL" \ +#"--draft") +#cd .. -WP_APPS_PR_BODY="## Description -This PR incorporates the $VERSION_NUMBER release of gutenberg-mobile. -For more information about this release and testing instructions, please see the related Gutenberg-Mobile PR: $GB_MOBILE_PR_URL +#echo "PRs Created" +#echo "===========" +#printf "Gutenberg-Mobile PR %s \n Gutenberg %s \n" "$GB_MOBILE_PR_URL" "$GUTENBERG_PR_URL" | column -t -Release Submission Checklist +#confirm_to_proceed "Do you want to proceed with creating main apps (WPiOS and WPAndroid) PRs?" +#ohai "Proceeding to create main apps PRs..." -- [ ] I have considered if this change warrants user-facing release notes and have added them to \`RELEASE-NOTES.txt\` if necessary." +#GB_MOBILE_PR_REF=$(git rev-parse HEAD) -WP_APPS_INTEGRATION_BRANCH="gutenberg/integrate_release_$VERSION_NUMBER" +#WP_APPS_PR_TITLE="Integrate gutenberg-mobile release $VERSION_NUMBER" -##### -# WPiOS PR -##### +#WP_APPS_PR_BODY="## Description +#This PR incorporates the $VERSION_NUMBER release of gutenberg-mobile. +#For more information about this release and testing instructions, please see the related Gutenberg-Mobile PR: $GB_MOBILE_PR_URL -read -r -p "Do you want to target $WPIOS_TARGET_BRANCH branch for WPiOS PR? (y/n) " -n 1 -echo "" -if [[ $REPLY =~ ^[Nn]$ ]]; then - read -r -p "Enter the branch name you want to target. Make sure a branch with this name already exists in WPiOS repository: " WPIOS_TARGET_BRANCH -fi +#Release Submission Checklist -TEMP_WP_IOS_DIRECTORY=$(mktemp -d) -ohai "Clone WordPress-iOS into '$TEMP_WP_IOS_DIRECTORY'" -execute "git" "clone" "-b" "$WPIOS_TARGET_BRANCH" "--depth=1" "git@github.com:$MOBILE_REPO/WordPress-iOS.git" "$TEMP_WP_IOS_DIRECTORY" +#- [ ] I have considered if this change warrants user-facing release notes and have added them to \`RELEASE-NOTES.txt\` if necessary." -cd "$TEMP_WP_IOS_DIRECTORY" +#WP_APPS_INTEGRATION_BRANCH="gutenberg/integrate_release_$VERSION_NUMBER" -ohai "Create after_x.xx.x branch in WordPress-iOS" -execute "git" "switch" "-c" "gutenberg/after_$VERSION_NUMBER" +###### +## WPiOS PR +###### -execute "git" "push" "-u" "origin" "HEAD" +#read -r -p "Do you want to target $WPIOS_TARGET_BRANCH branch for WPiOS PR? (y/n) " -n 1 +#echo "" +#if [[ $REPLY =~ ^[Nn]$ ]]; then +# read -r -p "Enter the branch name you want to target. Make sure a branch with this name already exists in WPiOS repository: " WPIOS_TARGET_BRANCH +#fi -ohai "Create release branch in WordPress-iOS" -execute "git" "switch" "-c" "gutenberg/integrate_release_$VERSION_NUMBER" +#TEMP_WP_IOS_DIRECTORY=$(mktemp -d) +#ohai "Clone WordPress-iOS into '$TEMP_WP_IOS_DIRECTORY'" +#execute "git" "clone" "-b" "$WPIOS_TARGET_BRANCH" "--depth=1" "git@github.com:$MOBILE_REPO/WordPress-iOS.git" "$TEMP_WP_IOS_DIRECTORY" -ohai "Update GitHub organization and gutenberg-mobile ref" -version_file="Gutenberg/version.rb" -test -f "$version_file" || abort "Error: Could not find $version_file" -sed -i'.orig' -E "s/GITHUB_ORG = 'wordpress-mobile'/GITHUB_ORG = '$MOBILE_REPO'/" $version_file || abort "Error: Failed updating GitHub organization in $version_file" -sed -i'.orig' -E "s/# commit: '(.*)',/commit: '$GB_MOBILE_PR_REF'/" $version_file || abort "Error: Failed updating gutenberg ref in $version_file (part 1 of 2, setting the commit)" -sed -i'.orig' -E "s/tag: '(.*)'/# &/" $version_file || abort "Error: Failed updating gutenberg ref in $version_file (part 2 of 2, commenting the tag)" -execute "bundle" "install" -execute_until_succeeds "rake" "dependencies" +#cd "$TEMP_WP_IOS_DIRECTORY" +#ohai "Create after_x.xx.x branch in WordPress-iOS" +#execute "git" "switch" "-c" "gutenberg/after_$VERSION_NUMBER" -execute "git" "add" "Podfile" "Podfile.lock" "$version_file" -execute "git" "commit" "-m" "Release script: Update gutenberg-mobile ref" +#execute "git" "push" "-u" "origin" "HEAD" -ohai "Push integration branch" -execute "git" "push" "-u" "origin" "HEAD" +#ohai "Create release branch in WordPress-iOS" +#execute "git" "switch" "-c" "gutenberg/integrate_release_$VERSION_NUMBER" -# Create Draft WPiOS Release PR in GitHub -ohai "Create Draft WPiOS Release PR in GitHub" -WP_IOS_PR_URL=$(execute "gh" "pr" "create" \ -"--title" "$WP_APPS_PR_TITLE" \ -"--body" "$WP_APPS_PR_BODY" \ -"--repo" "$MOBILE_REPO/WordPress-iOS" \ -"--head" "$MOBILE_REPO:$WP_APPS_INTEGRATION_BRANCH" \ -"--base" "$WPIOS_TARGET_BRANCH" \ -"--label" "$WPIOS_PR_LABEL" \ -"--draft") +#ohai "Update GitHub organization and gutenberg-mobile ref" +#version_file="Gutenberg/version.rb" +#test -f "$version_file" || abort "Error: Could not find $version_file" +#sed -i'.orig' -E "s/GITHUB_ORG = 'wordpress-mobile'/GITHUB_ORG = '$MOBILE_REPO'/" $version_file || abort "Error: Failed updating GitHub organization in $version_file" +#sed -i'.orig' -E "s/# commit: '(.*)',/commit: '$GB_MOBILE_PR_REF'/" $version_file || abort "Error: Failed updating gutenberg ref in $version_file (part 1 of 2, setting the commit)" +#sed -i'.orig' -E "s/tag: '(.*)'/# &/" $version_file || abort "Error: Failed updating gutenberg ref in $version_file (part 2 of 2, commenting the tag)" +#execute "bundle" "install" +#execute_until_succeeds "rake" "dependencies" -ohai "WPiOS PR Created: $WP_IOS_PR_URL" -echo "" -##### -# WPAndroid PR -##### -read -r -p "Do you want to target $WPANDROID_TARGET_BRANCH branch for WPAndroid PR? (y/n) " -n 1 -echo "" -if [[ $REPLY =~ ^[Nn]$ ]]; then - read -r -p "Enter the branch name you want to target. Make sure a branch with this name already exists in WPAndroid repository: " WPANDROID_TARGET_BRANCH -fi +#execute "git" "add" "Podfile" "Podfile.lock" "$version_file" +#execute "git" "commit" "-m" "Release script: Update gutenberg-mobile ref" -TEMP_WP_ANDROID_DIRECTORY=$(mktemp -d) -ohai "Clone WordPress-Android into '$TEMP_WP_ANDROID_DIRECTORY'" -execute "git" "clone" "-b" "$WPANDROID_TARGET_BRANCH" "--depth=1" "git@github.com:$MOBILE_REPO/WordPress-Android.git" "$TEMP_WP_ANDROID_DIRECTORY" +#ohai "Push integration branch" +#execute "git" "push" "-u" "origin" "HEAD" -cd "$TEMP_WP_ANDROID_DIRECTORY" +## Create Draft WPiOS Release PR in GitHub +#ohai "Create Draft WPiOS Release PR in GitHub" +#WP_IOS_PR_URL=$(execute "gh" "pr" "create" \ +#"--title" "$WP_APPS_PR_TITLE" \ +#"--body" "$WP_APPS_PR_BODY" \ +#"--repo" "$MOBILE_REPO/WordPress-iOS" \ +#"--head" "$MOBILE_REPO:$WP_APPS_INTEGRATION_BRANCH" \ +#"--base" "$WPIOS_TARGET_BRANCH" \ +#"--label" "$WPIOS_PR_LABEL" \ +#"--draft") -# This is still needed because of Android Stories. -execute "git" "submodule" "update" "--init" "--recursive" "--depth=1" "--recommend-shallow" +#ohai "WPiOS PR Created: $WP_IOS_PR_URL" +#echo "" -ohai "Create after_x.xx.x branch in WordPress-Android" -execute "git" "switch" "-c" "gutenberg/after_$VERSION_NUMBER" +###### +## WPAndroid PR +###### +#read -r -p "Do you want to target $WPANDROID_TARGET_BRANCH branch for WPAndroid PR? (y/n) " -n 1 +#echo "" +#if [[ $REPLY =~ ^[Nn]$ ]]; then +# read -r -p "Enter the branch name you want to target. Make sure a branch with this name already exists in WPAndroid repository: " WPANDROID_TARGET_BRANCH +#fi -execute "git" "push" "-u" "origin" "HEAD" +#TEMP_WP_ANDROID_DIRECTORY=$(mktemp -d) +#ohai "Clone WordPress-Android into '$TEMP_WP_ANDROID_DIRECTORY'" +#execute "git" "clone" "-b" "$WPANDROID_TARGET_BRANCH" "--depth=1" "git@github.com:$MOBILE_REPO/WordPress-Android.git" "$TEMP_WP_ANDROID_DIRECTORY" -ohai "Create release branch in WordPress-Android" -execute "git" "switch" "-c" "$WP_APPS_INTEGRATION_BRANCH" +#cd "$TEMP_WP_ANDROID_DIRECTORY" -# Get the last part of the path from GB_MOBILE_PR_URL -PULL_ID=${GB_MOBILE_PR_URL##*/} +## This is still needed because of Android Stories. +#execute "git" "submodule" "update" "--init" "--recursive" "--depth=1" "--recommend-shallow" -ohai "Update build.gradle file with the latest version" -test -f "build.gradle" || abort "Error: Could not find build.gradle" -sed -i '' -E "s/gutenbergMobileVersion = '(.*)'/gutenbergMobileVersion = '${PULL_ID}-$GB_MOBILE_PR_REF'/" build.gradle || abort "Error: Failed updating gutenbergMobileVersion in build.gradle" +#ohai "Create after_x.xx.x branch in WordPress-Android" +#execute "git" "switch" "-c" "gutenberg/after_$VERSION_NUMBER" -execute "git" "add" "build.gradle" -execute "git" "commit" "-m" "Release script: Update build.gradle gutenbergMobileVersion to ref" +#execute "git" "push" "-u" "origin" "HEAD" -ohai "Push integration branch" -execute "git" "push" "-u" "origin" "HEAD" +#ohai "Create release branch in WordPress-Android" +#execute "git" "switch" "-c" "$WP_APPS_INTEGRATION_BRANCH" -# Create Draft WPAndroid Release PR in GitHub -ohai "Create Draft WPAndroid Release PR in GitHub" -WP_ANDROID_PR_URL=$(execute "gh" "pr" "create" \ -"--title" "$WP_APPS_PR_TITLE" \ -"--body" "$WP_APPS_PR_BODY" --repo "$MOBILE_REPO/WordPress-Android" \ -"--head" "$MOBILE_REPO:$WP_APPS_INTEGRATION_BRANCH" \ -"--base" "$WPANDROID_TARGET_BRANCH" \ -"--label" "$WPANDROID_PR_LABEL" \ -"--draft") +## Get the last part of the path from GB_MOBILE_PR_URL +#PULL_ID=${GB_MOBILE_PR_URL##*/} -ohai "WPAndroid PR Created: $WP_ANDROID_PR_URL" -echo "" +#ohai "Update build.gradle file with the latest version" +#test -f "build.gradle" || abort "Error: Could not find build.gradle" +#sed -i '' -E "s/gutenbergMobileVersion = '(.*)'/gutenbergMobileVersion = '${PULL_ID}-$GB_MOBILE_PR_REF'/" build.gradle || abort "Error: Failed updating gutenbergMobileVersion in build.gradle" + +#execute "git" "add" "build.gradle" +#execute "git" "commit" "-m" "Release script: Update build.gradle gutenbergMobileVersion to ref" + +#ohai "Push integration branch" +#execute "git" "push" "-u" "origin" "HEAD" + +## Create Draft WPAndroid Release PR in GitHub +#ohai "Create Draft WPAndroid Release PR in GitHub" +#WP_ANDROID_PR_URL=$(execute "gh" "pr" "create" \ +#"--title" "$WP_APPS_PR_TITLE" \ +#"--body" "$WP_APPS_PR_BODY" --repo "$MOBILE_REPO/WordPress-Android" \ +#"--head" "$MOBILE_REPO:$WP_APPS_INTEGRATION_BRANCH" \ +#"--base" "$WPANDROID_TARGET_BRANCH" \ +#"--label" "$WPANDROID_PR_LABEL" \ +#"--draft") + +#ohai "WPAndroid PR Created: $WP_ANDROID_PR_URL" +#echo "" -echo "Main apps PRs created" -echo "===========" -printf "WPAndroid %s \n WPiOS %s \n" "$WP_ANDROID_PR_URL" "$WP_IOS_PR_URL" | column -t +#echo "Main apps PRs created" +#echo "===========" +#printf "WPAndroid %s \n WPiOS %s \n" "$WP_ANDROID_PR_URL" "$WP_IOS_PR_URL" | column -t ```