mirror of
https://github.com/zhigang1992/R.swift.git
synced 2026-01-12 17:33:08 +08:00
155 lines
4.3 KiB
Ruby
155 lines
4.3 KiB
Ruby
fastlane_version "1.86.0"
|
|
|
|
lane :release do |options|
|
|
if options[:skip_git_checks] != true
|
|
ensure_git_branch(branch: "master")
|
|
ensure_git_status_clean
|
|
else
|
|
Helper.log.info "Skipping the 'git status clean' and branch check!".yellow
|
|
end
|
|
|
|
git_pull
|
|
|
|
libraryVersionUsed = read_podspec['dependencies']['R.swift.Library'].first
|
|
libraryPodspecVersion = version_get_podspec(path: 'R.swift.Library/R.swift.Library.podspec')
|
|
unless prompt(text: "R.swift.Library #{libraryVersionUsed} is defined as dependency, current version seems to be #{libraryPodspecVersion}.\nAdjust podspec now if needed. Ready to continue?".green, boolean: true, ci_input: "")
|
|
raise "Aborted by user".red
|
|
end
|
|
|
|
currentVersion = version_get_podspec()
|
|
Helper.log.info "Current R.swift podspec version is #{currentVersion}"
|
|
|
|
isPrerelease = false
|
|
if options[:skip_version_bump] != true
|
|
bumpType = prompt(text: "What kind of release is this? (major/minor/patch/custom)".green, boolean: false, ci_input: "")
|
|
case bumpType
|
|
when "major", "minor", "patch"
|
|
version_bump_podspec(bump_type: bumpType)
|
|
when "custom"
|
|
newVersion = prompt(text: "What is the new custom version number?".green, boolean: false, ci_input: "")
|
|
version_bump_podspec(version_number: newVersion)
|
|
|
|
isPrerelease = prompt(text: "Is this a prerelease version?".green, boolean: true, ci_input: "")
|
|
else
|
|
raise "Invalid release type: #{bumpType}".red
|
|
end
|
|
|
|
newVersion = version_get_podspec()
|
|
changelog = prompt(text: "Please provide release notes:".green, boolean: false, ci_input: "", multi_line_end_keyword: "FIN")
|
|
af_insert_text_into_file(
|
|
file_path: "Changelog.md",
|
|
text: "## #{newVersion}\n\n#{changelog}\n\n",
|
|
insert_at_bottom: false
|
|
)
|
|
else
|
|
isPrerelease = prompt(text: "Is this a prerelease version?".green, boolean: true, ci_input: "")
|
|
end
|
|
|
|
# Sync version.swift with version in podspec
|
|
filepath = '../R.swift/version.swift'
|
|
newVersion = version_get_podspec()
|
|
|
|
content = File.read(filepath).sub(/let version = "(.*)"/, "let version = \"#{newVersion}\"")
|
|
File.open(filepath, 'wb') { |file| file.write(content) }
|
|
|
|
if options[:skip_tests] != true
|
|
runalltests
|
|
else
|
|
Helper.log.info "Skipping tests!".yellow
|
|
end
|
|
|
|
archivePath = 'rswift.xcarchive'
|
|
|
|
xcodebuild(
|
|
workspace: 'R.swift.xcworkspace',
|
|
scheme: 'rswift',
|
|
archivePath: archivePath,
|
|
archive: true
|
|
)
|
|
|
|
zipPath = "/tmp/rswift-#{newVersion}.zip"
|
|
sh "rm -f #{zipPath}"
|
|
|
|
junk_zip(
|
|
paths: ["#{archivePath}/Products/usr/local/bin/rswift", "./License"],
|
|
output_path: zipPath
|
|
)
|
|
|
|
unless is_ci
|
|
notification(
|
|
title: "R.swift release",
|
|
message: "💡 Needs your attention."
|
|
)
|
|
end
|
|
|
|
unless prompt(text: "#{newVersion} has been build and prepped for release. If you have any additional changes you would like to make, please do those before continuing. Would you like to commit, tag, push and release #{newVersion} including all uncommitted changes?".green, boolean: true, ci_input:"y")
|
|
raise "Aborted by user".red
|
|
end
|
|
|
|
unless `git status --porcelain`.empty?
|
|
git_commit(
|
|
path: ".",
|
|
message: "Preparing for the #{newVersion} release"
|
|
)
|
|
end
|
|
|
|
push_to_git_remote
|
|
|
|
af_create_github_release(
|
|
owner: 'mac-cain13',
|
|
repository: 'r.swift',
|
|
tag_name: "v#{newVersion}",
|
|
target_commitish: 'master',
|
|
name: "#{newVersion}",
|
|
body: "#{changelog}",
|
|
prerelease: isPrerelease
|
|
)
|
|
|
|
af_upload_asset_for_github_release(
|
|
file_path: zipPath
|
|
)
|
|
|
|
pod_push
|
|
|
|
unless is_ci
|
|
notification(
|
|
title: "R.swift.Library release",
|
|
message: "🎉 Version #{newVersion} is released."
|
|
)
|
|
end
|
|
end
|
|
|
|
desc "Runs all the tests"
|
|
lane :runalltests do
|
|
cocoapods(repo_update: false)
|
|
|
|
scan(
|
|
workspace: "R.swift.xcworkspace",
|
|
scheme: "rswift",
|
|
clean: true
|
|
)
|
|
scan(
|
|
workspace: "R.swift.xcworkspace",
|
|
scheme: "ResourceApp",
|
|
sdk: "iphonesimulator",
|
|
destination: "name=iPhone 6",
|
|
clean: true
|
|
)
|
|
scan(
|
|
workspace: "R.swift.xcworkspace",
|
|
scheme: "ResourceApp-tvOS",
|
|
sdk: "iphonesimulator",
|
|
destination: "name=Apple TV 1080p",
|
|
clean: true
|
|
)
|
|
end
|
|
|
|
error do |lane, exception|
|
|
unless is_ci
|
|
notification(
|
|
title: "R.swift.Library #{lane}",
|
|
message: "❌ Failed with an exception."
|
|
)
|
|
end
|
|
end
|