Last active
February 13, 2021 08:46
-
-
Save fromkk/fb184d3b86c33b5c9cb785f87bbf2a72 to your computer and use it in GitHub Desktop.
DSYMsのダウンロード・アップロードに対応したFastfile
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
require "net/http" | |
require "uri" | |
require "pty" | |
require "expect" | |
require "fastlane" | |
require "spaceship" | |
require "json" | |
require 'zip' | |
fastlane_version "2.174.0" | |
platform :ios do | |
#参考: https://blog.kishikawakatsumi.com/entry/2021/01/26/171137 | |
lane :udpate_session do | |
cmd = "fastlane spaceauth" | |
PTY.spawn(cmd) do |i, o| | |
o.sync = true | |
# 有効なセッションクッキーがある場合は何もしない | |
i.expect(/Pass the following via the FASTLANE_SESSION environment variable:/, 10) do |match| | |
if match | |
o.puts "y" | |
return | |
end | |
end | |
# セッションが無効で2FAの入力が必要な場合 | |
i.expect(/Please enter the 6 digit code you received at .+:/, 60) do |match| | |
raise "UnknownError" unless match | |
sleep 30 | |
# SMS APIから2FAのSMSを取得する | |
uri = URI.parse("https://script.google.com/macros/s/${YOUR_GAS_API_ID}/exec") | |
response = Net::HTTP.get_response(uri) | |
if response.code == "302" | |
response = Net::HTTP.get_response(URI.parse(response.header['location'])) | |
end | |
result = JSON.parse(response.body) | |
# SMSの本文から2FAのコードを取得する | |
code = result["code"] | |
if code.nil? | |
raise "NotFoundError" | |
end | |
# コードを入力する | |
o.puts code | |
end | |
i.expect(/Pass the following via the FASTLANE_SESSION environment variable:/, 10) do |match| | |
raise "UnknownError" unless match | |
o.puts "y" | |
end | |
begin | |
while (i.eof? == false) | |
puts i.gets | |
end | |
rescue Errno::EIO | |
end | |
end | |
end | |
lane :dsyms do |options| | |
download_dsyms(version: 'latest') | |
unzip(zip: lane_context[SharedValues::DSYM_PATHS][0], dest: options[:dest]) | |
clean_build_artifacts | |
end | |
lane :unzip do |options| | |
zipFile = options[:zip] | |
dest = options[:dest] | |
Zip::File.open(zipFile) do |zip| | |
zip.each do |entry| | |
zip.extract(entry, dest + entry.name) { true } | |
end | |
end | |
end | |
end |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment