-
Notifications
You must be signed in to change notification settings - Fork 1.2k
Cache Gutenberg XCFramework downloads on disk #25352
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: trunk
Are you sure you want to change the base?
Changes from all commits
828b582
aa5f84b
27c0c08
15a96ba
8b12843
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,4 @@ | ||
| .PHONY: dependencies | ||
|
|
||
| dependencies: | ||
| ./Scripts/download-gutenberg-xcframeworks.sh |
| Original file line number | Diff line number | Diff line change | ||||||||||
|---|---|---|---|---|---|---|---|---|---|---|---|---|
| @@ -0,0 +1,53 @@ | ||||||||||||
| #!/bin/bash | ||||||||||||
| set -euo pipefail | ||||||||||||
|
Comment on lines
+1
to
+2
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Nitpick: Apps Infra recently started moving toward a more portable shebang
Suggested change
|
||||||||||||
|
|
||||||||||||
| # Downloads and installs Gutenberg XCFrameworks with progress and on-disk caching. | ||||||||||||
| # | ||||||||||||
| # Usage: download-gutenberg-xcframeworks.sh [frameworks_dir] | ||||||||||||
| # frameworks_dir defaults to WordPress/Frameworks | ||||||||||||
|
|
||||||||||||
| VERSION="v1.121.0" | ||||||||||||
|
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. What do you think of making the version an input with fallback, too?
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Actually... maybe we would be better served by extracting the version in a dedicated file? It's currently duplicated. |
||||||||||||
| FRAMEWORKS_DIR="${1:-WordPress/Frameworks}" | ||||||||||||
|
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Nitpick. I love that this is can be changed at call time. Nice UX. But neither Did you consider exposing it? If not, is there value in having it configurable here? FWIW, I think this is not an issue and we shouldn't get distracted with exposing the config. But maybe there's a good use case for it that I'm not aware of, so I thought I'd call it out. |
||||||||||||
|
|
||||||||||||
| CACHE_DIR="${HOME}/Library/Caches/WordPress-iOS/Gutenberg/${VERSION}" | ||||||||||||
| DOWNLOAD_URL="https://cdn.a8c-ci.services/gutenberg-mobile/Gutenberg-${VERSION}.tar.gz" | ||||||||||||
|
|
||||||||||||
| # Download and extract into the cache if this version isn't cached yet. | ||||||||||||
| if [[ -d "${CACHE_DIR}" ]]; then | ||||||||||||
| echo "Using cached Gutenberg ${VERSION}" | ||||||||||||
| else | ||||||||||||
| echo "Downloading Gutenberg ${VERSION}..." | ||||||||||||
|
|
||||||||||||
| # Extract into a temp directory first so a partial download doesn't | ||||||||||||
| # leave a corrupt cache that persists across runs. | ||||||||||||
| mkdir -p "$(dirname "${CACHE_DIR}")" | ||||||||||||
| TEMP_DIR="$(mktemp -d "${CACHE_DIR}.XXXXXX")" | ||||||||||||
| trap 'rm -rf "${TEMP_DIR}"' EXIT | ||||||||||||
|
Member
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. TIL about |
||||||||||||
|
|
||||||||||||
| curl --fail --location --progress-bar "${DOWNLOAD_URL}" \ | ||||||||||||
| | tar xzf - -C "${TEMP_DIR}" | ||||||||||||
|
|
||||||||||||
| # Move contents up from the nested Frameworks/ directory. | ||||||||||||
| if [[ -d "${TEMP_DIR}/Frameworks" ]]; then | ||||||||||||
| mv "${TEMP_DIR}"/Frameworks/* "${TEMP_DIR}/" | ||||||||||||
| rm -rf "${TEMP_DIR}/Frameworks" | ||||||||||||
| fi | ||||||||||||
|
|
||||||||||||
| # Create dSYMs directories that Xcode expects for hermes. | ||||||||||||
| mkdir -p \ | ||||||||||||
| "${TEMP_DIR}/hermes.xcframework/ios-arm64/dSYMs" \ | ||||||||||||
| "${TEMP_DIR}/hermes.xcframework/ios-arm64_x86_64-simulator/dSYMs" | ||||||||||||
|
|
||||||||||||
| # Clean up leftover files from the archive. | ||||||||||||
| rm -f "${TEMP_DIR}/dummy.txt" | ||||||||||||
|
|
||||||||||||
| # Atomically promote the temp directory to the final cache path. | ||||||||||||
| mv "${TEMP_DIR}" "${CACHE_DIR}" | ||||||||||||
| trap - EXIT | ||||||||||||
| fi | ||||||||||||
|
|
||||||||||||
| # Copy cached contents into the project. | ||||||||||||
| rm -rf "${FRAMEWORKS_DIR}" | ||||||||||||
|
Member
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. The likelihood of someone mistakenly passing
Suggested change
|
||||||||||||
| cp -a "${CACHE_DIR}" "${FRAMEWORKS_DIR}" | ||||||||||||
|
|
||||||||||||
| echo "Gutenberg ${VERSION} setup complete." | ||||||||||||
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
We might add a default help target to improve discoverability.