@@ -28,6 +28,7 @@ outstanding_status = '🚀' # Outstanding performance
28
28
before_all do |lane |
29
29
if is_ci
30
30
setup_ci
31
+ sh ( 'git config --global user.name "Stream Bot"' )
31
32
xcversion ( version : xcode_version ) unless [ :publish_release , :allure_launch , :allure_upload , :copyright , :pod_lint ] . include? ( lane )
32
33
end
33
34
end
@@ -123,31 +124,39 @@ lane :publish_release do |options|
123
124
merge_main_to_develop
124
125
end
125
126
126
- lane :merge_release_to_main do
127
+ lane :merge_release_to_main do | options |
127
128
ensure_git_status_clean
128
- sh ( 'git checkout main' )
129
- sh ( 'git pull' )
130
129
131
- # Grep all remote release branches and ensure there's only one
132
- release_branches = sh ( command : 'git branch -a' , log : false ) . delete ( ' ' ) . split ( "\n " ) . grep ( %r(origin/.*release/) )
133
- UI . user_error! ( "Expected 1 release branch, found #{ release_branches . size } " ) if release_branches . size != 1
130
+ release_branch =
131
+ if is_ci
132
+ # This API operation needs the "admin:org" scope.
133
+ ios_team = sh ( 'gh api orgs/GetStream/teams/ios-developers/members -q ".[].login"' , log : false ) . split
134
+ UI . user_error! ( "#{ options [ :author ] } is not a member of the iOS Team" ) unless ios_team . include? ( options [ :author ] )
135
+
136
+ current_branch
137
+ else
138
+ release_branches = sh ( command : 'git branch -a' , log : false ) . delete ( ' ' ) . split ( "\n " ) . grep ( %r(origin/.*release/) )
139
+ UI . user_error! ( "Expected 1 release branch, found #{ release_branches . size } " ) if release_branches . size != 1
140
+
141
+ release_branches . first
142
+ end
143
+
144
+ UI . user_error! ( "`#{ release_branch } `` branch does not match the release branch pattern: `release/*`" ) unless release_branch . start_with? ( 'release/' )
145
+
146
+ sh ( 'git checkout origin/main' )
147
+ sh ( 'git pull origin main' )
134
148
135
149
# Merge release branch to main. For more info, read: https://notion.so/iOS-Branching-Strategy-37c10127dc26493e937769d44b1d6d9a
136
- sh ( "git merge #{ release_branches . first } --ff-only" )
137
- UI . user_error! ( 'Not pushing changes' ) unless prompt ( text : 'Will push changes. All looking good?' , boolean : true )
138
- sh ( 'git push' )
139
- UI . important ( 'Please, wait for the `Publish new release` workflow to pass on GitHub Actions: ' \
140
- "https://github.com/#{ github_repo } /actions/workflows/publish-release.yml" )
150
+ sh ( "git merge #{ release_branch } --ff-only" )
151
+ sh ( 'git push origin main' )
152
+
153
+ comment = "[Publication of the release](https://github.com/#{ github_repo } /actions/workflows/release-publish.yml) has been launched 👍"
154
+ UI . important ( comment )
155
+ create_pr_comment ( pr_num : ENV . fetch ( 'GITHUB_PR_NUM' ) , text : comment )
141
156
end
142
157
143
158
lane :merge_main_to_develop do
144
- if is_ci
145
- sh ( 'git config --global user.name "Stream Bot"' )
146
- sh ( 'git reset --hard' )
147
- else
148
- ensure_git_status_clean
149
- end
150
-
159
+ ensure_git_status_clean
151
160
sh ( 'git checkout main' )
152
161
sh ( 'git pull origin main' )
153
162
sh ( 'git checkout origin/develop' )
@@ -408,7 +417,6 @@ private_lane :update_spm do |options|
408
417
File . open ( './Package.swift' , 'w' ) { |file | file << file_data }
409
418
410
419
# Update the repo
411
- sh ( 'git config --global user.name "Stream Bot"' )
412
420
sh ( 'git add -A' )
413
421
sh ( "git commit -m 'Bump #{ version } '" )
414
422
sh ( 'git push' )
622
630
private_lane :create_pr_comment do |options |
623
631
if is_ci && !options [ :pr_num ] . to_s . empty?
624
632
last_comment = sh ( "gh pr view #{ options [ :pr_num ] } --json comments --jq '.comments | map(select(.author.login == \" Stream-iOS-Bot\" )) | last'" )
625
- edit_last_comment = last_comment . include? ( options [ :edit_last_comment_with_text ] ) ? '--edit-last' : ''
633
+ edit_last_comment = options [ :edit_last_comment_with_text ] && last_comment . include? ( options [ :edit_last_comment_with_text ] ) ? '--edit-last' : ''
626
634
sh ( "gh pr comment #{ options [ :pr_num ] } #{ edit_last_comment } -b '#{ options [ :text ] } '" )
627
635
end
628
636
end
0 commit comments