-
Notifications
You must be signed in to change notification settings - Fork 14
Fixes release automations #770
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
Changes from all commits
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 |
|---|---|---|
|
|
@@ -24,7 +24,6 @@ FILES_WITH_SDK_VERSION = { | |
|
|
||
| desc "Bumps version, edits changelog, and creates pull request" | ||
| lane :bump do |options| | ||
| phc_version = get_phc_version | ||
| bump_version_update_changelog_create_pr( | ||
| current_version: current_version_number, | ||
| changelog_latest_path: PATH_CHANGELOG_LATEST, | ||
|
|
@@ -36,16 +35,10 @@ lane :bump do |options| | |
| editor: options[:editor], | ||
| next_version: options[:next_version], | ||
| automatic_release: options[:automatic_release], | ||
| hybrid_common_version: phc_version, | ||
| versions_file_path: PATH_VERSIONS, | ||
| is_prerelease: options[:is_prerelease], | ||
| append_phc_version_if_next_version_is_not_prerelease: true | ||
| ) | ||
| update_hybrids_versions_file( | ||
| versions_file_path: PATH_VERSIONS, | ||
| new_sdk_version: current_version_number, | ||
| hybrid_common_version: phc_version | ||
| is_prerelease: options[:is_prerelease] | ||
| ) | ||
| update_versions_file(current_version_number) | ||
| commit_current_changes(commit_message: 'Updates VERSIONS.md') | ||
| push_to_git_remote(set_upstream: true) | ||
| end | ||
|
|
@@ -68,62 +61,6 @@ lane :automatic_bump do |options| | |
| bump(options) | ||
| end | ||
|
|
||
| desc "Update purchases-hybrid-common dependency" | ||
| lane :update_hybrid_common do |options| | ||
| if options[:dry_run] | ||
| dry_run = true | ||
| end | ||
| if options[:version] | ||
| new_phc_version = options[:version] | ||
| else | ||
| UI.user_error!("Missing `version` argument") | ||
| end | ||
|
|
||
| current_phc_version = get_phc_version | ||
|
|
||
| UI.message("ℹ️ Current Purchases Hybrid Common version: #{current_phc_version}") | ||
| UI.message("ℹ️ Setting Purchases Hybrid Common version: #{new_phc_version}") | ||
| files_to_update = { | ||
| "gradle/libs.versions.toml" => ["revenuecat-common = \"{x}\""], | ||
| "core/core.podspec" => ["spec.dependency 'PurchasesHybridCommon', '{x}'"], | ||
| "mappings/mappings.podspec" => ["spec.dependency 'PurchasesHybridCommon', '{x}'"], | ||
| "models/models.podspec" => ["spec.dependency 'PurchasesHybridCommon', '{x}'"], | ||
| "revenuecatui/revenuecatui.podspec" => ["spec.dependency 'PurchasesHybridCommonUI', '{x}'"], | ||
| "iosApp/Podfile" => [" pod 'PurchasesHybridCommon', '{x}'", " pod 'PurchasesHybridCommonUI', '{x}'"], | ||
| } | ||
|
|
||
| if dry_run | ||
| UI.message("ℹ️ Nothing more to do, dry_run: true") | ||
| next | ||
| end | ||
|
|
||
| bump_phc_version( | ||
| repo_name: REPO_NAME, | ||
| files_to_update: files_to_update, | ||
| current_version: current_phc_version, | ||
| next_version: new_phc_version, | ||
| open_pr: options[:open_pr] || false, | ||
| automatic_release: options[:automatic_release] || false | ||
| ) | ||
| # Making sure Podfile.lock is updated. | ||
| podfile = "iosApp/Podfile" | ||
| cocoapods( | ||
| podfile: podfile, | ||
| repo_update: true | ||
| ) | ||
| if options[:open_pr] | ||
| git_commit( | ||
| path: ["#{podfile}.lock"], | ||
| message: "Updates Podfile.lock", | ||
| skip_git_hooks: true | ||
| ) | ||
| push_to_git_remote( | ||
| tags: false, | ||
| no_verify: true | ||
| ) | ||
| end | ||
| end | ||
|
|
||
| desc "Opens a PR updating the SDK version to the next minor, appending -SNAPSHOT." | ||
| lane :prepare_next_snapshot_version do |options| | ||
| create_next_snapshot_version( | ||
|
|
@@ -179,40 +116,67 @@ lane :github_release do |options| | |
| ) | ||
| end | ||
|
|
||
| def get_phc_version | ||
| android_phc_version = File.read("../gradle/libs.versions.toml") | ||
| .match("revenuecat-common = \"(.*)\"") | ||
| .captures[0] | ||
| UI.user_error!("Android PHC version not found.") if android_phc_version.nil? | ||
|
|
||
| ios_phc_version = File.read("../core/core.podspec") | ||
| .match("spec.dependency 'PurchasesHybridCommon', '(.*)'") | ||
| def current_version_number | ||
| File.read("../gradle/libs.versions.toml") | ||
| .match('revenuecat-kmp = "(.*)"') | ||
| .captures[0] | ||
| UI.user_error!("iOS PHC version not found.") if ios_phc_version.nil? | ||
| end | ||
|
|
||
| ios_phc_ui_version = File.read("../revenuecatui/revenuecatui.podspec") | ||
| .match("spec.dependency 'PurchasesHybridCommonUI', '(.*)'") | ||
| def get_android_version | ||
| version = File.read("../gradle/libs.versions.toml") | ||
| .match('revenuecat-android = "(.*)"') | ||
| .captures[0] | ||
| UI.user_error!("iOS PHC UI version not found.") if ios_phc_ui_version.nil? | ||
|
|
||
| versions_mismatch_error = "Found multiple PHC (UI) versions. Please make sure to use only 1." | ||
| versions_match = android_phc_version == ios_phc_version && ios_phc_version == ios_phc_ui_version | ||
| UI.user_error!(versions_mismatch_error) unless versions_match | ||
|
|
||
| android_phc_version | ||
| end | ||
| UI.user_error!("Android version not found in libs.versions.toml") if version.nil? | ||
| version | ||
| end | ||
|
|
||
| def current_version_number | ||
| File.read("../gradle/libs.versions.toml") | ||
| .match("revenuecat-kmp = \"(.*)\"") | ||
| .captures[0] | ||
| end | ||
| def get_ios_version | ||
| version = File.read("../upstream/purchases-ios/.version").strip | ||
| UI.user_error!("iOS version not found in upstream/purchases-ios/.version") if version.nil? || version.empty? | ||
| version | ||
| end | ||
|
|
||
| def check_no_git_tag_exists(version_number) | ||
| if git_tag_exists(tag: version_number, remote: true, remote_name: 'origin') | ||
| raise "git tag with version #{version_number} already exists!" | ||
| end | ||
| def get_billing_client_version(android_version) | ||
|
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. Wonder if we should extract this to the fastlane plugin so it can be shared with PHC... Not a blocker though :)
Member
Author
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. Hmm yea, wouldn't that require us to make it a lane instead of a function?
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. Indeed.... so yeah, I guess it's not that complex and not that reused just now that we need to do this I think |
||
| require 'base64' | ||
| response = github_api( | ||
| server_url: 'https://api.github.com', | ||
| api_token: ENV["GITHUB_TOKEN"], | ||
| http_method: 'GET', | ||
| path: "/repos/RevenueCat/purchases-android/contents/gradle/libs.versions.toml?ref=#{android_version}" | ||
| ) | ||
| contents = Base64.decode64(response[:json]['content']) | ||
| matches = contents.match('bc8 = "(.*)"') | ||
| UI.user_error!("Could not find Play Billing Library version for purchases-android #{android_version}") unless matches | ||
| matches.captures[0] | ||
| end | ||
|
|
||
| def update_versions_file(sdk_version) | ||
| android_version = get_android_version | ||
| ios_version = get_ios_version | ||
| billing_version = get_billing_client_version(android_version) | ||
|
|
||
| UI.message("Android version: #{android_version}") | ||
| UI.message("iOS version: #{ios_version}") | ||
| UI.message("Play Billing Library version: #{billing_version}") | ||
|
|
||
| versions_path = File.join('..', PATH_VERSIONS) | ||
| lines = File.readlines(versions_path) | ||
| new_line = [ | ||
| sdk_version, | ||
| "[#{ios_version}](https://github.com/RevenueCat/purchases-ios/releases/tag/#{ios_version})", | ||
| "[#{android_version}](https://github.com/RevenueCat/purchases-android/releases/tag/#{android_version})", | ||
| "N/A", | ||
|
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. Hmm good to leave this like this for now I think. Once we've merge this and some time passes, it might be worth removing the column entirely. |
||
| "[#{billing_version}](https://developer.android.com/google/play/billing/release-notes)" | ||
| ].join(' | ') | ||
| lines.insert(2, "| #{new_line} |\n") | ||
| File.write(versions_path, lines.join) | ||
| end | ||
|
|
||
| def check_no_git_tag_exists(version_number) | ||
| if git_tag_exists(tag: version_number, remote: true, remote_name: 'origin') | ||
| raise "git tag with version #{version_number} already exists!" | ||
| end | ||
| end | ||
|
|
||
| # Publishes the SDK. If the current version is a SNAPSHOT version, it will be published | ||
| # to Sonatype's snapshots repository, otherwise it will be published to Maven Central. | ||
|
|
||
Uh oh!
There was an error while loading. Please reload this page.
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 will need to change PHC to avoid calling this non-existing workflow after merging this to main
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.
Great point! I think this should be enough RevenueCat/purchases-hybrid-common#1583