Skip to content

Commit

Permalink
Add lane to trigger bumps (#3766)
Browse files Browse the repository at this point in the history
This avoids having to go through CircleCI's UI when we want to trigger a
bump
  • Loading branch information
vegaro authored Mar 14, 2024
1 parent 58e5984 commit e65c323
Show file tree
Hide file tree
Showing 4 changed files with 37 additions and 20 deletions.
3 changes: 2 additions & 1 deletion Gemfile.lock
Original file line number Diff line number Diff line change
@@ -1,8 +1,9 @@
GIT
remote: https://github.com/RevenueCat/fastlane-plugin-revenuecat_internal
revision: 9c82c7ab8dab77383245907fd6e5184a61398cae
revision: d23de33ecf1c7b59d3bde5766c78a579999352bd
specs:
fastlane-plugin-revenuecat_internal (0.1.0)
rest-client

GEM
remote: https://rubygems.org/
Expand Down
3 changes: 3 additions & 0 deletions fastlane/.env.SAMPLE
Original file line number Diff line number Diff line change
Expand Up @@ -12,3 +12,6 @@ GITHUB_PULL_REQUEST_TEAM_REVIEWERS=

# Optional for updating changelog. Can be the same as GITHUB_PULL_REQUEST_API_TOKEN and improves issues with github api rate limits.
GITHUB_TOKEN=

# Optional for triggering CircleCI pipelines using the CircleCI API
CIRCLE_TOKEN=
43 changes: 24 additions & 19 deletions fastlane/Fastfile
Original file line number Diff line number Diff line change
Expand Up @@ -129,7 +129,7 @@ platform :ios do
# For platforms that fail to run StoreKit tests.
# See https://developer.apple.com/forums/thread/724068 and `FB12223404`.
skip_sk_tests = options[:skip_sk_tests]

if generate_snapshots
if skip_sk_tests
test_plan = "CI-RevenueCat-Snapshots"
Expand Down Expand Up @@ -391,12 +391,12 @@ platform :ios do
lane :push_revenuecat_pod do |options|
pod_push(path: "RevenueCat.podspec", synchronous: true)
end

desc "Release to CocoaPods"
lane :push_revenuecatui_pod do |options|
pod_push(path: "RevenueCatUI.podspec", synchronous: true)
end

desc "Tag current branch with current version number"
lane :tag_current_branch do |options|
version_number = current_version_number
Expand All @@ -406,6 +406,11 @@ platform :ios do
push_git_tags(tag: version_number)
end

desc "Trigger bump"
lane :trigger_bump do
trigger_action_in_circle_ci(action: 'bump', repo_name: repo_name)
end

desc "Checks whether the RevenueCat-Swift.h is up to date"
private_lane :check_autogenerated_header_up_to_date do |options|
ensure_git_status_clean
Expand All @@ -429,14 +434,14 @@ platform :ios do
end

desc "Trigger CircleCI job to generate snapshots for RevenueCat"
lane :generate_snapshots_RC do
lane :generate_snapshots_RC do
generate_snapshots(
pipeline: "generate_snapshots"
)
end

desc "Trigger CircleCI job to generate snapshots for RevenueCatUI"
lane :generate_snapshots_RCUI do
lane :generate_snapshots_RCUI do
generate_snapshots(
pipeline: "generate_revenuecatui_snapshots"
)
Expand Down Expand Up @@ -497,7 +502,7 @@ platform :ios do
push_snapshot_pr(
version: options[:version],
repo: "revenuecat/#{snapshots_repo_name}",
base_branch: "main",
base_branch: "main",
files_to_add: "."
)
}
Expand All @@ -506,20 +511,20 @@ platform :ios do
private_lane :push_snapshot_pr do |options|
version = options[:version]
base_branch = options[:base_branch]
build_number = ENV["CIRCLE_BUILD_NUM"]
build_number = ENV["CIRCLE_BUILD_NUM"]

branch_name = "generated_snapshots/#{base_branch}-#{build_number}-#{version}"

sh("git", "checkout", "-b", branch_name)
sh("git", "add", options[:files_to_add])

file_count = sh("git diff --cached --numstat | wc -l").strip.to_i

if file_count == 0
UI.important("No files to be committed")
else
sh("git", "commit", "-m", "[skip ci] Generating new test snapshots")
sh("git", "push", "origin", branch_name)
sh("git", "push", "origin", branch_name)

circle_user = ENV["CIRCLE_USERNAME"]
branch_link = "https://github.com/RevenueCat/purchases-ios/tree/#{base_branch}"
Expand Down Expand Up @@ -584,7 +589,7 @@ platform :ios do
enable_bitcode: false,
include_debug_symbols: true
)

# sh runs from the Fastfile's location, but other commands run from the project root.
output_directory_for_sh = "../#{output_directory}"

Expand Down Expand Up @@ -630,7 +635,7 @@ platform :ios do
output_directory: "fastlane/test_output/xctest/ios"
)
end


desc "Update swift package commit"
lane :update_swift_package_commit do
Expand Down Expand Up @@ -675,7 +680,7 @@ platform :ios do
)

sh(
"codesign",
"codesign",
"--timestamp",
"-v",
"--sign", "Apple Distribution: RevenueCat, Inc. (8SXR2327BM)",
Expand Down Expand Up @@ -727,7 +732,7 @@ platform :ios do
docs_repo_base_url = ENV["DOCS_REPO_BASE_URL"]
docs_repo_name = ENV["DOCS_REPO_NAME"]
ios_version = ENV['DOCS_IOS_VERSION'] || "16.1"

UI.user_error!("Missing environment variable: DOCS_REPO_BASE_URL") unless docs_repo_base_url
UI.user_error!("Missing environment variable: DOCS_REPO_NAME") unless docs_repo_name

Expand Down Expand Up @@ -758,7 +763,7 @@ platform :ios do
"--transform-for-static-hosting",
"--enable-inherited-docs",
"--additional-symbol-graph-dir", ".build")

docs_index_path = File.join(Dir.pwd, "scripts/docs/index.html")
docs_migration_guide_path = File.join(Dir.pwd, "scripts/docs/v4_api_migration_guide.html")
# clone docs repo
Expand Down Expand Up @@ -799,7 +804,7 @@ platform :ios do
build_number: latest_testflight_build_number(platform: 'ios') + 1,
xcodeproj: 'PurchaseTester.xcodeproj'
)

match(readonly: true)
build_ios_app(
workspace: "PurchaseTester.xcworkspace",
Expand All @@ -817,7 +822,7 @@ platform :ios do
build_number: latest_testflight_build_number(platform: 'osx') + 1,
xcodeproj: 'PurchaseTester.xcodeproj'
)

match(readonly: true, platform: "macos", additional_cert_types: "mac_installer_distribution")
build_mac_app(
workspace: "PurchaseTester.xcworkspace",
Expand Down Expand Up @@ -1007,10 +1012,10 @@ lane :check_pods do
# Fix-me: add `visionOS` when we start building with Xcode 15.1
pod_lib_lint(
verbose: true,
podspec: 'RevenueCat.podspec',
podspec: 'RevenueCat.podspec',
platforms: 'ios,osx,tvos,watchos',
fail_fast: true
)
)
pod_lib_lint(
verbose: true,
podspec: 'RevenueCatUI.podspec',
Expand Down Expand Up @@ -1047,4 +1052,4 @@ end
def update_snapshots_commit(hash)
File.write(snapshots_commit_file, hash)
end

8 changes: 8 additions & 0 deletions fastlane/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -234,6 +234,14 @@ Release to CocoaPods

Tag current branch with current version number

### ios trigger_bump

```sh
[bundle exec] fastlane ios trigger_bump
```

Trigger bump

### ios generate_snapshots_RC

```sh
Expand Down

0 comments on commit e65c323

Please sign in to comment.