Skip to content

Commit aaa67cb

Browse files
[CI] Update release-related fastlane lanes (#583)
1 parent 143696d commit aaa67cb

File tree

5 files changed

+30
-53
lines changed

5 files changed

+30
-53
lines changed

.github/workflows/release-merge.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,7 @@ jobs:
2424
- uses: ./.github/actions/ruby-cache
2525

2626
- name: Merge
27-
run: bundle exec fastlane merge_release_to_main author:"$USER_LOGIN" --verbose
27+
run: bundle exec fastlane merge_release author:"$USER_LOGIN" --verbose
2828
env:
2929
GITHUB_TOKEN: ${{ secrets.ADMIN_API_TOKEN }} # A token with the "admin:org" scope to get the list of the team members on GitHub
3030
GITHUB_PR_NUM: ${{ github.event.issue.number }}

.github/workflows/release-publish.yml

Lines changed: 22 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -7,32 +7,47 @@ on:
77
types:
88
- closed
99

10+
workflow_dispatch:
11+
inputs:
12+
version:
13+
description: 'Release version'
14+
type: string
15+
required: true
16+
1017
jobs:
1118
release:
1219
name: Publish new release
1320
runs-on: macos-13
14-
if: github.event.pull_request.merged == true # only merged pull requests must trigger this job
21+
if: ${{ github.event_name == 'workflow_dispatch' || github.event.pull_request.merged == true }} # only merged pull requests must trigger this job
1522
steps:
1623
- name: Connect Bot
1724
uses: webfactory/[email protected]
1825
with:
1926
ssh-private-key: ${{ secrets.BOT_SSH_PRIVATE_KEY }}
2027

2128
- uses: actions/[email protected]
22-
with:
23-
fetch-depth: 0
29+
30+
- uses: ./.github/actions/ruby-cache
31+
32+
- name: Extract version from input (for workflow dispatch)
33+
if: ${{ github.event_name == 'workflow_dispatch' }}
34+
run: |
35+
BRANCH_NAME=$(git rev-parse --abbrev-ref HEAD)
36+
if [ "$BRANCH_NAME" != "main" ]; then
37+
echo "This workflow can only be run on the main branch."
38+
exit 1
39+
fi
40+
echo "RELEASE_VERSION=${{ github.event.inputs.version }}" >> $GITHUB_ENV
2441
2542
- name: Extract version from branch name (for release branches)
26-
if: startsWith(github.event.pull_request.head.ref, 'release/')
43+
if: ${{ github.event_name == 'pull_request' && startsWith(github.event.pull_request.head.ref, 'release/') }}
2744
run: |
2845
BRANCH_NAME="${{ github.event.pull_request.head.ref }}"
2946
VERSION=${BRANCH_NAME#release/}
3047
echo "RELEASE_VERSION=$VERSION" >> $GITHUB_ENV
3148
32-
- uses: ./.github/actions/ruby-cache
33-
3449
- name: "Fastlane - Publish Release"
35-
if: startsWith(github.event.pull_request.head.ref, 'release/')
50+
if: ${{ github.event_name == 'workflow_dispatch' || startsWith(github.event.pull_request.head.ref, 'release/') }}
3651
env:
3752
GITHUB_TOKEN: ${{ secrets.CI_BOT_GITHUB_TOKEN }}
3853
COCOAPODS_TRUNK_TOKEN: ${{ secrets.COCOAPODS_TRUNK_TOKEN }}

Gemfile.lock

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -199,7 +199,7 @@ GEM
199199
fastlane
200200
pry
201201
fastlane-plugin-sonarcloud_metric_kit (0.2.1)
202-
fastlane-plugin-stream_actions (0.3.60)
202+
fastlane-plugin-stream_actions (0.3.61)
203203
xctest_list (= 1.2.1)
204204
fastlane-plugin-versioning (0.5.2)
205205
ffi (1.17.0)
@@ -427,7 +427,7 @@ DEPENDENCIES
427427
fastlane-plugin-create_xcframework
428428
fastlane-plugin-lizard
429429
fastlane-plugin-sonarcloud_metric_kit
430-
fastlane-plugin-stream_actions (= 0.3.60)
430+
fastlane-plugin-stream_actions (= 0.3.61)
431431
fastlane-plugin-versioning
432432
jazzy
433433
json

fastlane/Fastfile

Lines changed: 4 additions & 42 deletions
Original file line numberDiff line numberDiff line change
@@ -94,6 +94,10 @@ lane :release do |options|
9494
)
9595
end
9696

97+
lane :merge_release do |options|
98+
merge_release_to_main(author: options[:author])
99+
end
100+
97101
desc "Publish a new release to GitHub and CocoaPods"
98102
lane :publish_release do |options|
99103
xcversion(version: '15.0.1')
@@ -117,48 +121,6 @@ lane :publish_release do |options|
117121
merge_main_to_develop
118122
end
119123

120-
lane :merge_release_to_main do |options|
121-
ensure_git_status_clean
122-
123-
release_branch =
124-
if is_ci
125-
# This API operation needs the "admin:org" scope.
126-
ios_team = sh('gh api orgs/GetStream/teams/ios-developers/members -q ".[].login"', log: false).split
127-
UI.user_error!("#{options[:author]} is not a member of the iOS Team") unless ios_team.include?(options[:author])
128-
129-
current_branch
130-
else
131-
release_branches = sh(command: 'git branch -a', log: false).delete(' ').split("\n").grep(%r(origin/.*release/))
132-
UI.user_error!("Expected 1 release branch, found #{release_branches.size}") if release_branches.size != 1
133-
134-
release_branches.first
135-
end
136-
137-
UI.user_error!("`#{release_branch}`` branch does not match the release branch pattern: `release/*`") unless release_branch.start_with?('release/')
138-
139-
sh('git checkout origin/main')
140-
sh('git pull origin main')
141-
142-
# Merge release branch to main. For more info, read: https://notion.so/iOS-Branching-Strategy-37c10127dc26493e937769d44b1d6d9a
143-
sh("git merge #{release_branch} --ff-only")
144-
sh('git push origin main')
145-
146-
comment = "[Publication of the release](https://github.com/#{github_repo}/actions/workflows/release-publish.yml) has been launched 👍"
147-
UI.important(comment)
148-
pr_comment(text: comment)
149-
end
150-
151-
lane :merge_main_to_develop do
152-
ensure_git_status_clean
153-
sh('git checkout main')
154-
sh('git pull origin main')
155-
sh('git checkout origin/develop')
156-
sh('git pull origin develop')
157-
sh('git log develop..main')
158-
sh('git merge main')
159-
sh('git push origin develop')
160-
end
161-
162124
private_lane :appstore_api_key do
163125
@appstore_api_key ||= app_store_connect_api_key(
164126
key_id: 'MT3PRT8TB7',

fastlane/Pluginfile

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,4 +5,4 @@
55
gem 'fastlane-plugin-versioning'
66
gem 'fastlane-plugin-sonarcloud_metric_kit'
77
gem 'fastlane-plugin-create_xcframework'
8-
gem 'fastlane-plugin-stream_actions', '0.3.60'
8+
gem 'fastlane-plugin-stream_actions', '0.3.61'

0 commit comments

Comments
 (0)