Skip to content

Commit

Permalink
[CI] Update publish release flow (#589)
Browse files Browse the repository at this point in the history
  • Loading branch information
testableapple authored Aug 22, 2024
1 parent 04986d8 commit e5c85bd
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 32 deletions.
30 changes: 2 additions & 28 deletions .github/workflows/release-publish.yml
Original file line number Diff line number Diff line change
@@ -1,24 +1,16 @@
name: "Publish new release"

on:
pull_request:
push:
branches:
- main
types:
- closed

workflow_dispatch:
inputs:
version:
description: 'Release version'
type: string
required: true

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

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

- name: Extract version from input (for workflow dispatch)
if: ${{ github.event_name == 'workflow_dispatch' }}
run: |
BRANCH_NAME=$(git rev-parse --abbrev-ref HEAD)
if [ "$BRANCH_NAME" != "main" ]; then
echo "This workflow can only be run on the main branch."
exit 1
fi
echo "RELEASE_VERSION=${{ github.event.inputs.version }}" >> $GITHUB_ENV
- name: Extract version from branch name (for release branches)
if: ${{ github.event_name == 'pull_request' && startsWith(github.event.pull_request.head.ref, 'release/') }}
run: |
BRANCH_NAME="${{ github.event.pull_request.head.ref }}"
VERSION=${BRANCH_NAME#release/}
echo "RELEASE_VERSION=$VERSION" >> $GITHUB_ENV
- name: "Fastlane - Publish Release"
if: ${{ github.event_name == 'workflow_dispatch' || startsWith(github.event.pull_request.head.ref, 'release/') }}
env:
GITHUB_TOKEN: ${{ secrets.CI_BOT_GITHUB_TOKEN }}
COCOAPODS_TRUNK_TOKEN: ${{ secrets.COCOAPODS_TRUNK_TOKEN }}
MATCH_PASSWORD: ${{ secrets.MATCH_PASSWORD }}
APPSTORE_API_KEY: ${{ secrets.APPSTORE_API_KEY }}
run: bundle exec fastlane publish_release version:${{ env.RELEASE_VERSION }} --verbose
run: bundle exec fastlane publish_release --verbose
12 changes: 8 additions & 4 deletions fastlane/Fastfile
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@ source_packages_path = 'spm_cache'
buildcache_xcargs = 'CC=clang CPLUSPLUS=clang++ LD=clang LDPLUSPLUS=clang++'
is_localhost = !is_ci
project_package_resolved = "#{xcode_project}/project.xcworkspace/xcshareddata/swiftpm/Package.resolved"
swift_environment_path = File.absolute_path('../Sources/StreamChatSwiftUI/Generated/SystemEnvironment+Version.swift')
@force_check = false

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

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

xcversion(version: '15.0.1')
clean_products
build_xcframeworks
compress_frameworks
clean_products

publish_ios_sdk(
skip_git_status_check: false,
version: options[:version],
version: release_version,
sdk_names: sdk_names,
podspec_names: ['StreamChatSwiftUI', 'StreamChatSwiftUI-XCFramework'],
github_repo: github_repo,
upload_assets: ['Products/StreamChatSwiftUI.zip']
)

update_spm(version: options[:version])
update_spm(version: release_version)

merge_main_to_develop
end
Expand Down

0 comments on commit e5c85bd

Please sign in to comment.