Untitled

 avatar
unknown
plain_text
4 years ago
4.6 kB
4
Indexable
fastlane_version "2.19.3"
testingDevice = "iPhone X"

default_platform(:ios)

platform :ios do
  before_all do
		ENV["FASTLANE_XCODEBUILD_SETTINGS_TIMEOUT"] = "180"
		ENV["FASTLANE_XCODEBUILD_SETTINGS_RETRIES"] = "10"
		ENV["FASTLANE_EXPLICIT_OPEN_SIMULATOR"] = "1"
	end

	def setupCodeSigning(keychainPassword, certificatePassword, profilePath, certificatePath)
		create_keychain(
			name: "CI",
			password: keychainPassword,
			default_keychain: true,
			unlock: true,
			timeout: 3600,
			lock_when_sleeps: false
		  )
		install_provisioning_profile(path: profilePath)

		import_certificate(
			certificate_path: certificatePath,
			certificate_password: certificatePassword,
			keychain_name: "CI",
			keychain_password: keychainPassword
		)
	end

  desc "setup Certificate"
  lane :get_dev_certs do
	cert(
		development: true
	)
	sigh(
		development: true
	)
  end

	

  desc "Submit to Firebase App Distribution (UseeTV Staging)"
	lane :firebase_beta_release do |options|
		UI.message("firebase_beta build number = #{options[:build_number]}")
		UI.message("firebase_beta configuration = #{options[:configuration]}")

		ensure_clean

		cocoapods(
			try_repo_update_on_error: true
		)

		scheme = "UseeTV Staging"

		build_staging(
			scheme:scheme,
			export_method:"development",
			build_number:options[:build_number],
			configuration:options[:configuration]
		)

		configuration = options[:configuration]
		configuration ||= "Release"

		appId = "1:681662740886:ios:3ded03f70f378e428785b7" # UseeTV Staging
		if configuration == "Production"
			appId = "1:566249055346:ios:0fe311eb8571db67" # UseeTV Production
		end

		generateGitLog

		groups = "useetvgo-tester-qa"

		build_path = "./UseeTV-#{configuration}-development-#{get_app_version}.ipa"

		firebase_app_distribution(
			app: appId,
			groups: groups,
			release_notes: Actions.lane_context[SharedValues::FL_CHANGELOG],
			firebase_cli_path: "/usr/local/bin/firebase",
			ipa_path: build_path
		)

		upload_DSYM_to_firebase(app_id: appId)
	end

  desc "Upload DSYM"
	lane :upload_DSYM_to_firebase do |options|
		app_id = options[:app_id]
		upload_symbols_to_crashlytics(app_id: app_id)
	end

	############## PRIVATE LANES ##############
	private_lane :build_staging do |options|
		derived_data_path = "./derivedData/"
		build_path = "./archive/"
		buildlog_path = "./buildLog/"
		team_id = "S39WRXUKHC"

		# setupCodeSigning(ENV["Sambelgoreng321"], ENV["telkom123"], './path-to-your-profile/your-profile.mobileprovision', './path-to-your-certificate/certificate.p12')
		get_dev_certs
		
		app_identifiers = [
			"com.telkomdev.useetvgo",
			"com.telkomdev.useetvgo.UseeTVNotificationService",
		]

		provisioningProfiles = {
			"com.telkomdev.useetvgo" => "UseeTV_Dev_telkomdev",
			"com.telkomdev.useetvgo.UseeTVNotificationService" => "UseeTV_Notification_Dev_telkomdev",
		}

		scheme = options[:scheme]
		if scheme == "UseeTV Staging"
			update_code_signing_settings(
				path: "UseeTV.xcodeproj",
				team_id: team_id,
				use_automatic_signing: false,
				code_sign_identity: "Apple Development: Arif Rachman (2W844PQCNR)",
				entitlements_file_path: "UseeTVNotificationService/UseeTVNotificationService.entitlements"
			)
		end

		xcversion(version: "~> 12.3")
		export_method = options[:export_method]
		build_number = options[:build_number]
		configuration = options[:configuration]

		clear_derived_data(derived_data_path: derived_data_path)

		if build_number.nil?
			increment_build_number()
		else
			increment_build_number(build_number:build_number)
		end

		output_name = "UseeTV-#{configuration}-#{export_method}-#{get_app_version}.ipa"

		gym(
			scheme: scheme,
			configuration: configuration,
			output_name: output_name,
			derived_data_path: derived_data_path,
			build_path: build_path,
			buildlog_path: buildlog_path,
			skip_profile_detection: true,
			skip_package_ipa: false,
			skip_archive: false,
			include_bitcode: false,
			clean: true,
			codesigning_identity: "Apple Development: Arif Rachman (2W844PQCNR)",
			export_options: {
				teamID: team_id,
				method: export_method,
				provisioningProfiles: provisioningProfiles
			}
		)
	end

	private_lane :generateGitLog do
		changelog_from_git_commits(
			commits_count: 10,
			pretty: "- %h | %s"
		)
	end

	private_lane :ensure_clean do
		begin
			ensure_git_status_clean
		rescue Exception
			reset_git_repo(force: true)
		end
	end

	private_lane :get_app_version do
		version_number = get_version_number(target:"UseeTV")
		build_number = get_build_number
		"#{version_number}.#{build_number}"
	end
end
Editor is loading...