Skip to content
This repository has been archived by the owner on Jun 1, 2024. It is now read-only.

Commit

Permalink
ci: iOS update podspec version and tag independently so hotfix works (#…
Browse files Browse the repository at this point in the history
  • Loading branch information
theffc authored Sep 3, 2020
1 parent d105c9c commit 4c6be3c
Show file tree
Hide file tree
Showing 3 changed files with 54 additions and 32 deletions.
5 changes: 3 additions & 2 deletions Beagle.podspec
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ Pod::Spec.new do |spec|

spec.name = "Beagle"

spec.version = "1.0.0"
spec.version = '1.2.0'

spec.summary = "A framework to help implement Server-Driven UI in your apps natively."
spec.description = <<-DESC
Expand All @@ -44,7 +44,8 @@ Pod::Spec.new do |spec|

# ――― Source Location ―――――――――――――――――――――――――――――――――――――――――――――――――――――――――― #

source = { :git => "https://github.com/ZupIT/beagle.git", :tag => spec.version.to_s }
tag = spec.version.to_s
source = { :git => "https://github.com/ZupIT/beagle.git", :tag => tag }
spec.source = source

# ――― Source Code ―――――――――――――――――――――――――――――――――――――――――――――――――――――――――――――― #
Expand Down
5 changes: 3 additions & 2 deletions BeagleSchema.podspec
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ Pod::Spec.new do |spec|

spec.name = "BeagleSchema"

spec.version = "1.0.0"
spec.version = '1.2.0'

spec.summary = "Describe Beagle components structure"
spec.description = <<-DESC
Expand All @@ -43,7 +43,8 @@ Pod::Spec.new do |spec|

# ――― Source Location ―――――――――――――――――――――――――――――――――――――――――――――――――――――――――― #

source = { :git => "https://github.com/ZupIT/beagle.git", :tag => spec.version.to_s }
tag = spec.version.to_s
source = { :git => "https://github.com/ZupIT/beagle.git", :tag => tag }
spec.source = source

# ――― Source Code ―――――――――――――――――――――――――――――――――――――――――――――――――――――――――――――― #
Expand Down
76 changes: 48 additions & 28 deletions fastlane/Fastfile
Original file line number Diff line number Diff line change
Expand Up @@ -69,62 +69,82 @@ platform :android do
end

###
### iOS
### iOS - Begin
###

platform :ios do

desc "Pull Request verification"
lane :pull_request_verification do
xcversion(version: "~> 11.5.0")
iOSSwiftLint
# TODO: see if it's ok to remove this SwiftLint, since we already have it inside xcode and danger
swiftlint(
mode: :lint, # :lint (default) or :autocorrect
ignore_exit_status: true # Allow fastlane to continue even if SwiftLint returns a non-zero exit status
)
scan(
workspace: "iOS/Beagle.xcworkspace/",
scheme: "All",
device: "iPhone 11"
)
run_codecov(platform: 'ios')
iOSCocoaPodsIntegration
end

desc "Run iOS SwiftLint"
private_lane :iOSSwiftLint do
swiftlint(
mode: :lint, # SwiftLint mode: :lint (default) or :autocorrect
ignore_exit_status: true # Allow fastlane to continue even if SwiftLint returns a non-zero exit status
)
check_if_beagle_works_via_cocoapods_integration
end

desc "CocoaPods Integration test"
private_lane :iOSCocoaPodsIntegration do
desc "Check wether Beagle is working via CocoaPods in an Example Project"
private_lane :check_if_beagle_works_via_cocoapods_integration do
xcversion(version: "~> 11.5.0")
installCocoaPods
cocoapods(
clean_install: true,
podfile: "iOS/Example/CocoaPodsTest/Podfile"
)
scan(
workspace: "iOS/Example/CocoaPodsTest/CocoaPodsTest.xcworkspace",
scheme: "CocoaPodsTest",
device: "iPhone 11"
)
end

desc "Release Pods"
lane :release_pods do |options|
version = options[:version] # 1.0.0
tag = options[:tag] # 1.0.0[-iOS]

desc "Install CocoaPods"
private_lane :installCocoaPods do
cocoapods(
clean_install: true,
podfile: "iOS/Example/CocoaPodsTest/Podfile"
)
[
{ path: "BeagleSchema.podspec" },
{ path: "Beagle.podspec", depends_on_other_beagle_pod: true }
]
.each do |pod|
update_podspec(path: pod[:path], version: version, tag: tag)

pod_push(path: pod[:path], allow_warnings: true, synchronous: pod[:depends_on_other_beagle_pod])
end
end
end

desc "Updates versions on Podspec"
lane :release do
version_bump_podspec(path: "Beagle.podspec", version_number: last_git_tag)
version_bump_podspec(path: "BeagleSchema.podspec", version_number: last_git_tag)
pod_push(path: "BeagleSchema.podspec", allow_warnings: true)
pod_push(path: "Beagle.podspec", allow_warnings: true, synchronous: true)
def update_podspec(path:, version:, tag:)
rootPath = "../" + path
file = File.read(rootPath)

version_regex = /\.version = (.*)\n/
tag_regex = /tag = (.*)\n/

has_version_and_tag = version_regex.match(file) && tag_regex.match(file)
if not has_version_and_tag
UI.user_error!("podspec at #{path} should have version and tag")
end

new_content = file
.gsub(version_regex, ".version = '#{version}'\n")
.gsub(tag_regex, "tag = '#{tag}'\n")

File.write(rootPath, new_content)
end

###
### iOS - END
###

desc "Publish new release based on last two tags"
lane :deploy do
sh "git fetch"
Expand All @@ -146,7 +166,7 @@ lane :deploy do

if platformHotfix == "iOS"
puts "iOS Hotfix release"
sh "fastlane ios release"
sh "fastlane ios release_pods version:#{versionNumber} tag:#{tagName}"
elsif platformHotfix == "android"
puts "Android Hotfix release"
sh "fastlane android deploy_to_production"
Expand All @@ -157,7 +177,7 @@ lane :deploy do
puts "Normal Release"
sh "fastlane android deploy_to_production"
sh "fastlane backend deploy_to_production"
sh "fastlane ios release"
sh "fastlane ios release_pods version:#{versionNumber} tag:#{tagName}"
end

releaseNotes = release_notes(versionDeploy: tagName)
Expand Down

0 comments on commit 4c6be3c

Please sign in to comment.