Skip to content

Commit e5c85bd

Browse files
[CI] Update publish release flow (#589)
1 parent 04986d8 commit e5c85bd

File tree

2 files changed

+10
-32
lines changed

2 files changed

+10
-32
lines changed

.github/workflows/release-publish.yml

Lines changed: 2 additions & 28 deletions
Original file line numberDiff line numberDiff line change
@@ -1,24 +1,16 @@
11
name: "Publish new release"
22

33
on:
4-
pull_request:
4+
push:
55
branches:
66
- main
7-
types:
8-
- closed
97

108
workflow_dispatch:
11-
inputs:
12-
version:
13-
description: 'Release version'
14-
type: string
15-
required: true
169

1710
jobs:
1811
release:
1912
name: Publish new release
2013
runs-on: macos-13
21-
if: ${{ github.event_name == 'workflow_dispatch' || github.event.pull_request.merged == true }} # only merged pull requests must trigger this job
2214
steps:
2315
- name: Connect Bot
2416
uses: webfactory/[email protected]
@@ -29,28 +21,10 @@ jobs:
2921

3022
- uses: ./.github/actions/ruby-cache
3123

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
41-
42-
- name: Extract version from branch name (for release branches)
43-
if: ${{ github.event_name == 'pull_request' && startsWith(github.event.pull_request.head.ref, 'release/') }}
44-
run: |
45-
BRANCH_NAME="${{ github.event.pull_request.head.ref }}"
46-
VERSION=${BRANCH_NAME#release/}
47-
echo "RELEASE_VERSION=$VERSION" >> $GITHUB_ENV
48-
4924
- name: "Fastlane - Publish Release"
50-
if: ${{ github.event_name == 'workflow_dispatch' || startsWith(github.event.pull_request.head.ref, 'release/') }}
5125
env:
5226
GITHUB_TOKEN: ${{ secrets.CI_BOT_GITHUB_TOKEN }}
5327
COCOAPODS_TRUNK_TOKEN: ${{ secrets.COCOAPODS_TRUNK_TOKEN }}
5428
MATCH_PASSWORD: ${{ secrets.MATCH_PASSWORD }}
5529
APPSTORE_API_KEY: ${{ secrets.APPSTORE_API_KEY }}
56-
run: bundle exec fastlane publish_release version:${{ env.RELEASE_VERSION }} --verbose
30+
run: bundle exec fastlane publish_release --verbose

fastlane/Fastfile

Lines changed: 8 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,7 @@ source_packages_path = 'spm_cache'
1616
buildcache_xcargs = 'CC=clang CPLUSPLUS=clang++ LD=clang LDPLUSPLUS=clang++'
1717
is_localhost = !is_ci
1818
project_package_resolved = "#{xcode_project}/project.xcworkspace/xcshareddata/swiftpm/Package.resolved"
19+
swift_environment_path = File.absolute_path('../Sources/StreamChatSwiftUI/Generated/SystemEnvironment+Version.swift')
1920
@force_check = false
2021

2122
before_all do |lane|
@@ -67,7 +68,6 @@ desc 'Release a new version'
6768
lane :release do |options|
6869
previous_version_number = last_git_tag
6970
artifacts_path = File.absolute_path('../StreamChatSwiftUIArtifacts.json')
70-
swift_environment_path = File.absolute_path('../Sources/StreamChatSwiftUI/Generated/SystemEnvironment+Version.swift')
7171
extra_changes = lambda do |release_version|
7272
# Set the framework version on the artifacts
7373
artifacts = JSON.parse(File.read(artifacts_path))
@@ -100,23 +100,27 @@ end
100100

101101
desc "Publish a new release to GitHub and CocoaPods"
102102
lane :publish_release do |options|
103-
xcversion(version: '15.0.1')
103+
release_version = File.read(swift_environment_path).match(/String\s+=\s+"([\d.]+)"/)[1]
104+
UI.user_error!("Release #{release_version} has already been published.") if git_tag_exists(tag: release_version, remote: true)
105+
UI.user_error!('Release version cannot be empty') if release_version.to_s.empty?
106+
ensure_git_branch(branch: 'main')
104107

108+
xcversion(version: '15.0.1')
105109
clean_products
106110
build_xcframeworks
107111
compress_frameworks
108112
clean_products
109113

110114
publish_ios_sdk(
111115
skip_git_status_check: false,
112-
version: options[:version],
116+
version: release_version,
113117
sdk_names: sdk_names,
114118
podspec_names: ['StreamChatSwiftUI', 'StreamChatSwiftUI-XCFramework'],
115119
github_repo: github_repo,
116120
upload_assets: ['Products/StreamChatSwiftUI.zip']
117121
)
118122

119-
update_spm(version: options[:version])
123+
update_spm(version: release_version)
120124

121125
merge_main_to_develop
122126
end

0 commit comments

Comments
 (0)