Skip to content

Commit

Permalink
Update fastfile
Browse files Browse the repository at this point in the history
  • Loading branch information
danielsaidi committed Dec 2, 2022
1 parent 2d99eb4 commit 8c42668
Showing 1 changed file with 34 additions and 22 deletions.
56 changes: 34 additions & 22 deletions Fastlane/Fastfile
Original file line number Diff line number Diff line change
Expand Up @@ -5,45 +5,57 @@ default_platform :ios

platform :ios do

library_name = "MockingKit"
pod_name = "MockingKit"
main_branch = "master"
build_folder_docs = ".build/docs"


# Documentation ==============

desc "Build Documentation"
desc "Generate documentation"
lane :documentation do
docc_web
docc_web
end


# Linting ====================
# Lint =======================

desc "Run SwiftLint"
lane :lint do
swiftlint(strict: true)
end


# Test =======================
# Test ===================

desc "Run unit tests"
lane :test do
sh("swift test")
end


# Version ====================
# Validate ===================

desc "Create a new version"
lane :version do |options|
desc "Ensure that the repo is valid for release"
lane :ensure_release_ready do
ensure_git_status_clean
ensure_git_branch(branch: 'master')

ensure_git_branch(branch: main_branch)
lint
test
end


# Version ================

desc "Create a new version"
lane :version do |options|
ensure_release_ready
documentation

bump_type = options[:type]
version = version_bump_podspec(
path: "MockingKit.podspec",
path: pod_name + '.podspec',
bump_type: bump_type)

git_commit(path: "*", message: "Bump to #{version}")
Expand All @@ -58,7 +70,7 @@ platform :ios do

desc "Build documentation for all platforms"
lane :docc do
sh('cd .. && rm -rf Docs')
sh('cd .. && rm -rf ' + build_folder_docs)
docc_platform(destination: 'iOS', name: 'ios')
docc_platform(destination: 'OS X', name: 'osx')
docc_platform(destination: 'tvOS', name: 'tvos')
Expand All @@ -67,23 +79,23 @@ platform :ios do

desc "Build documentation for a single platform"
lane :docc_platform do |values|
sh('cd .. && mkdir -p Docs')
docc_delete_derived_data
sh('cd .. && mkdir -p ' + build_folder_docs)
docc_delete_derived_data(lib: library_name)
sh('cd .. && xcodebuild docbuild \
-scheme MockingKit \
-scheme ' + library_name + ' \
-destination \'generic/platform=' + values[:destination] + '\'')
sh('cd .. && \
find ~/Library/Developer/Xcode/DerivedData \
-name "MockingKit.doccarchive" \
-exec cp -R {} Docs \;')
-name "' + library_name + '.doccarchive" \
-exec cp -R {} ' + build_folder_docs + ' \;')
sh('cd .. && \
mv Docs/MockingKit.doccarchive Docs/MockingKit_' + values[:name] + '.doccarchive')
mv ' + build_folder_docs + '/' + library_name + '.doccarchive ' + build_folder_docs + '/' + library_name + '_' + values[:name] + '.doccarchive')
end

desc "Delete documentation derived data (may be historic duplicates)"
lane :docc_delete_derived_data do
sh('find ~/Library/Developer/Xcode/DerivedData \
-name "MockingKit.doccarchive" \
-name "' + library_name + '.doccarchive" \
-exec rm -Rf {} \; || true')
end

Expand All @@ -99,9 +111,9 @@ platform :ios do
desc "Build static documentation website for a single platform"
lane :docc_web_platform do |values|
sh('cd .. && $(xcrun --find docc) process-archive \
transform-for-static-hosting Docs/MockingKit_' + values[:name] + '.doccarchive \
--output-path Docs/web_' + values[:name] + ' \
--hosting-base-path MockingKit')
transform-for-static-hosting ' + build_folder_docs + '/' + library_name + '_' + values[:name] + '.doccarchive \
--output-path ' + build_folder_docs + '/web_' + values[:name] + ' \
--hosting-base-path ' + library_name + '')
end

end

0 comments on commit 8c42668

Please sign in to comment.