From 9f9705b83e3427d4f962513c30f2af114a0ac254 Mon Sep 17 00:00:00 2001 From: Gio Lodi Date: Fri, 2 Jun 2023 17:31:16 +1000 Subject: [PATCH] =?UTF-8?q?WIP=20=E2=80=93=20Ditch=20the=20whole=20local?= =?UTF-8?q?=20spec=20idea=20and=20refer=20to=20a=20remote=20one=20?= =?UTF-8?q?=F0=9F=A4=A6=E2=80=8D=E2=99=82=EF=B8=8F?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- Gutenberg/Gutenberg.podspec | 78 ---------------------------------- Gutenberg/cocoapods_helpers.rb | 11 +---- Gutenberg/version.rb | 10 ----- Podfile.lock | 6 +-- 4 files changed, 5 insertions(+), 100 deletions(-) delete mode 100644 Gutenberg/Gutenberg.podspec diff --git a/Gutenberg/Gutenberg.podspec b/Gutenberg/Gutenberg.podspec deleted file mode 100644 index 29d591d939a1..000000000000 --- a/Gutenberg/Gutenberg.podspec +++ /dev/null @@ -1,78 +0,0 @@ -# frozen_string_literal: true - -require 'pathname' -require_relative './version' - -# A spec for a pod whose only job is delegating the XCFrameworks integration to CocoaPods. -# -# This is used to fetch Gutenberg builds that come from commits instead of tags. -# Builds from tags are "official" and stable, so we distribute them via GitHub we'll eventually publish them on CocoaPods. -# The artifacts for builds from commits are instead only stored on an Automattic's server. -Pod::Spec.new do |s| - raise 'Could not find Gutenberg version configuration' if GUTENBERG_CONFIG.nil? - - gutenberg_version = GUTENBERG_CONFIG[:commit] - - raise "Trying to fetch Gutenberg XCFramework from Automattic's distribution server with invalid version '#{GUTENBERG_CONFIG}'" if gutenberg_version.nil? - - xcframework_storage_url = 'https://d2twmm2nzpx3bg.cloudfront.net' - - xcframework_archive_url = "#{xcframework_storage_url}/Gutenberg-#{gutenberg_version}.tar.gz" - - require 'net/http' - - raise "Could not find file at URL #{xcframework_archive_url}" unless Net::HTTP.get_response(URI(xcframework_archive_url)).code == '200' - - s.name = 'Gutenberg' - s.version = '1.0.0' # The value here is irrelevant, but required - s.summary = 'A spec to help integrating the Gutenberg XCFramework' - s.homepage = 'https://apps.wordpress.com' - s.license = { type: 'GPL', file: '../LICENSE' } - s.authors = 'Automattic' - - s.ios.deployment_target = '13.0' # TODO: Read from common source - s.swift_version = '5.0' # TODO: read from common source - - s.requires_arc = true # TODO: Can this be omitted? - - # Tell CocoaPods where to download the XCFramework(s) archive with `source` and what to use from its decompressed contents with `vendored_frameworks`. - # - # Unfortunately, CocoaPods currently (1.12.1) does not work when it comes to local specs with http sources. - # - # See https://github.com/CocoaPods/CocoaPods/issues/10288#issuecomment-1517711223 - # s.source = { http: xcframework_archive_url } - archive_name = "Gutenberg-#{gutenberg_version}.tar.gz" - # Always use relative paths, otherwise the checksums in the lockfile will change from machine to machine - relative_extracted_archive_directory = Pathname.new("#{GUTENBERG_ARCHIVE_DIRECTORY}").relative_path_from(__dir__).to_s - relative_download_directory = Pathname.new(GUTENBERG_DOWNLOADS_DIRECTORY).relative_path_from(__dir__).to_s - relative_download_path = File.join(relative_download_directory, archive_name) - - s.source = { http: "file://#{relative_download_path}" } - - s.vendored_frameworks = [ - 'Aztec.xcframework', - 'Gutenberg.xcframework', - 'React.xcframework', - 'RNTAztecView.xcframework', - 'yoga.xcframework' - ].map do |f| - # This needs to be a relative path to the local extraction location and account for the archive folder structure. - File.join(relative_extracted_archive_directory, 'Frameworks', f) - end - - # Print the message here because the prepare_command output is not forwarded by CocoaPods - if File.exist? relative_download_path - puts "📦 Will skip downloading Gutenberg archive because it already exists at #{relative_download_path}" - else - puts "⬇️ Will download Gutenberg archive to #{relative_download_path}" - end - - s.prepare_command = <<-CMD - mkdir -p #{relative_download_directory} - if [[ ! -f "#{relative_download_path}" ]]; then - curl --progress-bar #{xcframework_archive_url} -o #{relative_download_path} - fi - mkdir -p #{relative_extracted_archive_directory} - tar -xzf #{relative_download_path} --directory=#{relative_extracted_archive_directory} - CMD -end diff --git a/Gutenberg/cocoapods_helpers.rb b/Gutenberg/cocoapods_helpers.rb index 7709e2e90024..3dc29fe1df27 100644 --- a/Gutenberg/cocoapods_helpers.rb +++ b/Gutenberg/cocoapods_helpers.rb @@ -89,9 +89,7 @@ def gutenberg_pod(config: GUTENBERG_CONFIG) gutenberg_dependencies(options: options) elsif options[:commit] - # Notice the use of relative path, otherwise we'd get the full path of the user that run the `pod install` command tracked in Podfile.lock. - # Also notice the path is relative from Dir.pwd, that is, the location where the script running this code is invoked to avoid absolute paths making the checksum non determinstic. - pod 'Gutenberg', path: Pathname.new(File.join(__dir__, 'Gutenberg.podspec')).relative_path_from(Dir.pwd).to_s + pod 'Gutenberg', podspec: "https://d2twmm2nzpx3bg.cloudfront.net/Gutenberg-#{options[:commit]}.podspec" end end # rubocop:enable Metrics/AbcSize @@ -103,7 +101,7 @@ def gutenberg_dependencies(options:) tag = options[:tag] podspec_prefix = "https://raw.githubusercontent.com/#{GITHUB_ORG}/#{REPO_NAME}/#{tag}" elsif options[:commit] - return # when referencing via a commit, we donwload pre-built frameworks + return # when referencing via a commit, we download pre-built frameworks else raise "Unexpected Gutenberg dependencies configuration '#{options}'" end @@ -118,8 +116,3 @@ def gutenberg_dependencies(options:) pod pod_name, podspec: "#{podspec_prefix}/#{pod_name}.#{podspec_extension}" end end - -def archive_url(commit:) - xcframework_storage_url = 'https://d2twmm2nzpx3bg.cloudfront.net' - "#{xcframework_storage_url}/Gutenberg-#{commit}.tar.gz" -end diff --git a/Gutenberg/version.rb b/Gutenberg/version.rb index d10d29c0a402..2941c0bf1ae9 100644 --- a/Gutenberg/version.rb +++ b/Gutenberg/version.rb @@ -17,13 +17,3 @@ GITHUB_ORG = 'wordpress-mobile' REPO_NAME = 'gutenberg-mobile' - -# The root working directory for downloading and extracting archives. -# In this location because multiple sources access it. -# -# This path should be ignored by Git. -GUTENBERG_WORKING_DIRECTORY = File.join(__dir__, '.build') -# Where to download the XCFramework archives -GUTENBERG_DOWNLOADS_DIRECTORY = File.join(GUTENBERG_WORKING_DIRECTORY, 'downloads') -# Where to extract the XCFramework archive version to use for the build. -GUTENBERG_ARCHIVE_DIRECTORY = File.join(GUTENBERG_WORKING_DIRECTORY, 'archive') diff --git a/Podfile.lock b/Podfile.lock index c2b3995e426f..9ba8464b1cd6 100644 --- a/Podfile.lock +++ b/Podfile.lock @@ -150,7 +150,7 @@ DEPENDENCIES: - FSInteractiveMap (from `https://github.com/wordpress-mobile/FSInteractiveMap.git`, tag `0.2.0`) - Gifu (= 3.2.0) - Gridicons (~> 1.1.0) - - Gutenberg (from `Gutenberg/Gutenberg.podspec`) + - Gutenberg (from `https://d2twmm2nzpx3bg.cloudfront.net/Gutenberg-b24b84849081f4d3846f2c1a5868764283be5aad.podspec`) - JTAppleCalendar (~> 8.0.2) - Kanvas (~> 1.4.4) - MediaEditor (~> 1.2.1) @@ -226,7 +226,7 @@ EXTERNAL SOURCES: :git: https://github.com/wordpress-mobile/FSInteractiveMap.git :tag: 0.2.0 Gutenberg: - :path: Gutenberg/Gutenberg.podspec + :podspec: https://d2twmm2nzpx3bg.cloudfront.net/Gutenberg-b24b84849081f4d3846f2c1a5868764283be5aad.podspec WordPressShared: :branch: trunk :git: https://github.com/wordpress-mobile/WordPress-iOS-Shared.git @@ -255,7 +255,7 @@ SPEC CHECKSUMS: Gridicons: 17d660b97ce4231d582101b02f8280628b141c9a GTMAppAuth: 0ff230db599948a9ad7470ca667337803b3fc4dd GTMSessionFetcher: 5595ec75acf5be50814f81e9189490412bad82ba - Gutenberg: 288b6bead2d6bdc78b95f1a00f6bdc901578927e + Gutenberg: 7db906bba665170651d95db110d21599105ef820 JTAppleCalendar: 932cadea40b1051beab10f67843451d48ba16c99 Kanvas: f932eaed3d3f47aae8aafb6c2d27c968bdd49030 MediaEditor: 20cdeb46bdecd040b8bc94467ac85a52b53b193a