iOS 通过github自动打包ipa
1.在apple的developer里创建好identifiers
2.在终端输入fastlane init (初始化)
3.终端输入 vim fastlane 然后选择appfile
4.在其中增加一下两行:
app_identifier("com.tech.OnePass") # The bundle identifier of your app
apple_id("audrieherreslmw32@gmail.com") # Your Apple email address
把matchfile的代码改成以下格式:
git_url("git@gitlab.com:applesoftware/fastlane-certificates.git")
git_branch("wanghai")
storage_mode("git")
type("development") # The default type, can be: appstore, adhoc, enterprise or development
app_identifier(["com.tech.OnePass"])
username("audrieherreslmw32@gmail.com")
# app_identifier(["tools.fastlane.app", "tools.fastlane.app2"])
# username("user@fastlane.tools") # Your Apple Developer Portal username
# For all available options run `fastlane match --help`
# Remove the # in the beginning of the line to enable the other options
# The docs are available on https://docs.fastlane.tools/actions/match
5.在终端输入fastlane match development(初始化的时候不用输–readonly)——创建debug的证书
6.先把别的目录的device.txt拷贝到这个文件下:
cp ../tomato-clock-ios/devices.txt .
这段命令的意思是:
-‘cp’就是拷贝copy
-’…/tomato-clock-ios/devices.txt’这个文件
-’.’ 到当前目录下
7.在终端输入vim fastlane/Fastfile,把以下代码加入其中,是跑fastlane的时候刷设备号,跑真机用的:
desc "Add devices"
lane :devices do
register_devices(devices_file: "./devices.txt")
match(type: "development", force_for_new_devices: true)
end
7.在终端输入fastlane match appstore——创建relase的证书
8.改一下fastlane中Fastfile的文件内容,主要是以下几点:
8.1 把Apple Distribution改成当前的开发者——code_sign_identity: “Apple Distribution: hai wang (9ZX5JT86V6)”
8.2 把app的名字改成当前的名字 targets: “OnePass”,
8.3 把team ID也改成当前的9ZX5JT86V6
default_platform(:ios)
platform :ios do
desc "Add devices"
lane :devices do
register_devices(devices_file: "./devices.txt")
match(type: "development", force_for_new_devices: true)
end
desc "match"
lane :setup_match do
setup
match(
type: "appstore",
readonly: true,
keychain_name: "action.keychain",
keychain_password: ENV["MATCH_PASSWORD"]
)
end
desc "build"
lane :build do
setup_match
app_store_connect_api_key(
key_id: ENV["KEY_ID"],
issuer_id: ENV["ISSUER_ID"],
key_content: ENV["AUTHKEY"],
duration: 1200,
in_house: false,
is_key_content_base64: true
)
update_code_signing_settings(
use_automatic_signing: false,
path: "OnePass.xcodeproj",
team_id: "9ZX5JT86V6",
targets: "OnePass",
code_sign_identity: "Apple Distribution: hai wang (9ZX5JT86V6)"
)
build_app(
workspace: "OnePass.xcworkspace",
scheme: "OnePass",
export_method: "app-store",
output_directory: "ipas",
clean: true,
export_team_id: "9ZX5JT86V6",
output_name: "OnePass.ipa",
export_options: {
method: "app-store",
signingCertificate: "Apple Distribution: hai wang (9ZX5JT86V6)",
teamID: "9ZX5JT86V6",
signingStyle: "manual",
provisioningProfiles: {
"com.tech.OnePass" => "match AppStorecom.tech.OnePasss",
}
}
)
upload_to_testflight(skip_submission: true, skip_waiting_for_build_processing: true)
slack_message(targets: "OnePass")
end
#### Private ####
private_lane :setup do
create_keychain(
name: "action.keychain",
password: ENV["MATCH_PASSWORD"],
default_keychain: true,
unlock: true,
timeout: 3600,
lock_when_sleeps: false,
require_create: true
)
sh("security list-keychains -d user")
sh("security default-keychain -d user")
sh("security find-identity -v -p codesigning action.keychain")
end
private_lane :slack_message do |options|
build_number = get_build_number(xcodeproj: "OnePass.xcodeproj")
slack(
message: "App successfully uploaded to iTunesConnect.",
success: true,
slack_url: ENV["SLACK_URL"],
attachment_properties: {
fields: [
{
title: "Build number",
value: build_number,
},
{
title: "Targets",
value: options[:targets],
}
]
})
end
end
8.在终端输入ag hai
9.在github上创建一个这个邮箱的账号,新建一个仓库
10.在gitlab中选择设置,点击repositories,选择Mirroring repositories,按照以下格式输入:
11.在终端输入(必须要输入):
cp -r ../loancalc-ios/.github .
12.在终端输入(必须要输入):
cp ../tomatolifeios/Gemfile .
bundle
13.在github新建的仓库中选中setting,然后选中secrets,新建仓库的secret:
- AUTHKEY:
cat ~/Downloads/AuthKey_XXXXX.p8|base64|pbcopy
-
ISSUER_ID & KEY_ID:
-
MATCH_PASSWORD:
123123
- SLACK_URL:
https://hooks.slack.com/services/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
- SSH_PRIVATE_KEY:
cd tomatolifeios
cd ssh
cat id_rsa|pbcopy
输入完之后,将代码git push完之后,输入git tag build-1就会自动打包了(git tag build - X)X是当前的build号
之后在github上就可以找到这个提交的代码了
在action里查看打包的进程: