我已经尝试将我的应用程序从 GitHub Actions 上传到 TestFlight 一段时间了,但没有成功。
工作流程yml文件:
name: iOS Build and Upload to TestFlight
on:
workflow_dispatch:
jobs:
build-ios:
runs-on: macos-latest
steps:
- name: Checkout code
uses: actions/checkout@v4
- name: Set up Ruby
uses: ruby/setup-ruby@v1
with:
ruby-version: '3.3'
# Install Bundler and CocoaPods
- name: Install Bundler and CocoaPods
run: |
gem install bundler
sudo gem install cocoapods
- name: Install Node.js dependencies
run: npm install
- name: Navigate to iOS directory, clean Pods, and remove Podfile.lock
run: |
cd ios
pod deintegrate
rm -rf Podfile.lock
pod install --repo-update
- name: Install Fastlane dependencies
run: |
cd ios
bundle install
- name: Update OpenSSL
run: |
brew install openssl@3
brew link --force openssl@3
- name: Check OpenSSL Version and Path
run: |
which openssl
openssl version
- name: Decode and set up iOS certificate
run: |
echo "${{ secrets.IOS_DISTRIBUTION_CREDENTIALS }}" | base64 --decode > ios_distribution.p12
echo "${{ secrets.PROVISIONING_PROFILE }}" | base64 --decode > provisioning.mobileprovision
shell: bash
- name: Import certificate to keychain
run: |
security create-keychain -p "" build.keychain
security import ios_distribution.p12 -k build.keychain -P "${{ secrets.P12_PASSWORD }}" -T /usr/bin/codesign
security set-keychain-settings build.keychain
security unlock-keychain -p "" build.keychain
security set-key-partition-list -S apple-tool:,apple: -s -k "" build.keychain
security list-keychains -d user -s build.keychain $(security list-keychains -d user | tr -d '"')
security list-keychains -s build.keychain
shell: bash
- name: Set provisioning profile
run: |
mkdir -p ~/Library/MobileDevice/Provisioning\ Profiles
cp provisioning.mobileprovision ~/Library/MobileDevice/Provisioning\ Profiles/
shell: bash
- name: Print Current Directory
run: pwd
- name: Set Permissions for API JSON File
run: chmod 600 ios/fastlane/api.json
- name: Build and upload to TestFlight
run: |
cd ios
bundle exec fastlane beta
env:
# APP_STORE_CONNECT_API_KEY_PATH: ios/AuthKey.json
FASTLANE_USER: ${{ secrets.FASTLANE_USER }}
FASTLANE_PASSWORD: ${{ secrets.FASTLANE_PASSWORD }}
快速文件:
default_platform(:ios)
platform :ios do
desc "Push a new beta build to TestFlight"
lane :beta do
# Increment build number automatically
increment_build_number(
xcodeproj: "somename.xcodeproj"
)
Dir.chdir("../") do
sh "bundle exec pod install"
sh "npm install"
end
# Build the app using your specific workspace and scheme
build_app(
workspace: "somename.xcworkspace",
scheme: "somenameQA",
export_method: "app-store",
export_options: {
provisioningProfiles: {
"com.somename.app.qa" => "com.somename.app.qa"
}
}
)
app_store_connect_api_key(
path: "fastlane/api.json"
)
# Upload the build to TestFlight
pilot
end
end
我不断收到以下错误:
[13:52:25]: Called from Fastfile at line 29
[13:52:25]:
[13:52:25]: 27:
[13:52:25]: 28: # Upload the build to TestFlight
[13:52:25]: => 29: pilot( api_key_path: "fastlane/api.json" )
[13:52:25]: 30: end
[13:52:25]: 31: end
[13:52:25]:
[13:52:25]: unexpected token at '{
"key_id": "39BDY8TU5D%9",
"issuer_id": "2323AAsa-2f53-4853-97fe-fb7d0777b2aa",
"key": "-----BEGIN PRIVATE KEY-----\nMIGHAgSASFDFDdsdgfdgfSM49AwEHBG0wawIBAQQgN3TOiJNOCNVV8nlQ3oqIvYjZgZcKqNul75mZoasdgasdgasdgADSFNeLgKR+3NMEcoZyzC/TCGER6vHEaThF1uFHAmZny4dri+SDJSOdUBkN7jSz0L1gYDKujDIlpQAYNjz+7Srg\n-----END PRIVATE KEY-----",
"duration": 1200, # optional (maximum 1200)
"in_house": false # optional but may be required if using match/sigh
}'
+----------------------------------------------+
| fastlane summary |
+------+-------------------------+-------------+
| Step | Action | Time (in s) |
+------+-------------------------+-------------+
| 1 | default_platform | 0 |
| 2 | increment_build_number | 0 |
| 3 | bundle exec pod install | 16 |
| 4 | npm install | 7 |
| 5 | build_app | 441 |
| 💥 | pilot | 0 |
+------+-------------------------+-------------+
[13:52:25]: fastlane finished with errors
Looking for related GitHub issues on fastlane/fastlane...
bundler: failed to load command: fastlane (/Users/runner/hostedtoolcache/Ruby/3.3.6/arm64/bin/fastlane)
/Users/runner/hostedtoolcache/Ruby/3.3.6/arm64/lib/ruby/gems/3.3.0/gems/json-2.7.2/lib/json/common.rb:220:in parse': [!] unexpected token at '{ (JSON::ParserError)
"key_id": "1234123SDADSF",
"issuer_id": "12341234-2f1234124353-1243-3223-12421342134",
"key": "-----BEGIN PRIVATE KEY-----\nsomeprivatekey\n-----END PRIVATE KEY-----",
"duration": 1200, # optional (maximum 1200)
"in_house": false # optional but may be required if using match/sigh
}'
from /Users/runner/hostedtoolcache/Ruby/3.3.6/arm64/lib/ruby/gems/3.3.0/gems/json-2.7.2/lib/json/common.rb:220:in parse'
from /Users/runner/hostedtoolcache/Ruby/3.3.6/arm64/lib/ruby/gems/3.3.0/gems/fastlane-2.225.0/spaceship/lib/spaceship/connect_api/token.rb:39:in from_json_file'
from /Users/runner/hostedtoolcache/Ruby/3.3.6/arm64/lib/ruby/gems/3.3.0/gems/fastlane-2.225.0/spaceship/lib/spaceship/connect_api/token.rb:34:in from'
from /Users/runner/hostedtoolcache/Ruby/3.3.6/arm64/lib/ruby/gems/3.3.0/gems/fastlane-2.225.0/pilot/lib/pilot/manager.rb:23:in login'
from /Users/runner/hostedtoolcache/Ruby/3.3.6/arm64/lib/ruby/gems/3.3.0/gems/fastlane-2.225.0/pilot/lib/pilot/manager.rb:19:in start'
from /Users/runner/hostedtoolcache/Ruby/3.3.6/arm64/lib/ruby/gems/3.3.0/gems/fastlane-2.225.0/pilot/lib/pilot/build_manager.rb:17:in upload'
from /Users/runner/hostedtoolcache/Ruby/3.3.6/arm64/lib/ruby/gems/3.3.0/gems/fastlane-2.225.0/fastlane/lib/fastlane/actions/upload_to_testflight.rb:34:in run'
from /Users/runner/hostedtoolcache/Ruby/3.3.6/arm64/lib/ruby/gems/3.3.0/gems/fastlane-2.225.0/fastlane/lib/fastlane/runner.rb:263:in block (2 levels) in execute_action'
from /Users/runner/hostedtoolcache/Ruby/3.3.6/arm64/lib/ruby/gems/3.3.0/gems/fastlane-2.225.0/fastlane/lib/fastlane/actions/actions_helper.rb:69:in execute_action'
from /Users/runner/hostedtoolcache/Ruby/3.3.6/arm64/lib/ruby/gems/3.3.0/gems/fastlane-2.225.0/fastlane/lib/fastlane/runner.rb:255:in block in execute_action'
from /Users/runner/hostedtoolcache/Ruby/3.3.6/arm64/lib/ruby/gems/3.3.0/gems/fastlane-2.225.0/fastlane/lib/fastlane/runner.rb:229:in chdir'
from /Users/runner/hostedtoolcache/Ruby/3.3.6/arm64/lib/ruby/gems/3.3.0/gems/fastlane-2.225.0/fastlane/lib/fastlane/runner.rb:229:in execute_action'
from /Users/runner/hostedtoolcache/Ruby/3.3.6/arm64/lib/ruby/gems/3.3.0/gems/fastlane-2.225.0/fastlane/lib/fastlane/runner.rb:157:in trigger_action_by_name'
from /Users/runner/hostedtoolcache/Ruby/3.3.6/arm64/lib/ruby/gems/3.3.0/gems/fastlane-2.225.0/fastlane/lib/fastlane/fast_file.rb:159:in method_missing'
from Fastfile:29:in block (2 levels) in parsing_binding'
from /Users/runner/hostedtoolcache/Ruby/3.3.6/arm64/lib/ruby/gems/3.3.0/gems/fastlane-2.225.0/fastlane/lib/fastlane/lane.rb:41:in call'
from /Users/runner/hostedtoolcache/Ruby/3.3.6/arm64/lib/ruby/gems/3.3.0/gems/fastlane-2.225.0/fastlane/lib/fastlane/runner.rb:49:in block in execute'
from /Users/runner/hostedtoolcache/Ruby/3.3.6/arm64/lib/ruby/gems/3.3.0/gems/fastlane-2.225.0/fastlane/lib/fastlane/runner.rb:45:in chdir'
from /Users/runner/hostedtoolcache/Ruby/3.3.6/arm64/lib/ruby/gems/3.3.0/gems/fastlane-2.225.0/fastlane/lib/fastlane/runner.rb:45:in execute'
from /Users/runner/hostedtoolcache/Ruby/3.3.6/arm64/lib/ruby/gems/3.3.0/gems/fastlane-2.225.0/fastlane/lib/fastlane/lane_manager.rb:46:in cruise_lane'
from /Users/runner/hostedtoolcache/Ruby/3.3.6/arm64/lib/ruby/gems/3.3.0/gems/fastlane-2.225.0/fastlane/lib/fastlane/command_line_handler.rb:34:in handle'
from /Users/runner/hostedtoolcache/Ruby/3.3.6/arm64/lib/ruby/gems/3.3.0/gems/fastlane-2.225.0/fastlane/lib/fastlane/commands_generator.rb:110:in block (2 levels) in run'
from /Users/runner/hostedtoolcache/Ruby/3.3.6/arm64/lib/ruby/gems/3.3.0/gems/commander-4.6.0/lib/commander/command.rb:187:in call'
from /Users/runner/hostedtoolcache/Ruby/3.3.6/arm64/lib/ruby/gems/3.3.0/gems/commander-4.6.0/lib/commander/command.rb:157:in run'
from /Users/runner/hostedtoolcache/Ruby/3.3.6/arm64/lib/ruby/gems/3.3.0/gems/commander-4.6.0/lib/commander/runner.rb:444:in run_active_command'
from /Users/runner/hostedtoolcache/Ruby/3.3.6/arm64/lib/ruby/gems/3.3.0/gems/fastlane-2.225.0/fastlane_core/lib/fastlane_core/ui/fastlane_runner.rb:124:in run!'
from /Users/runner/hostedtoolcache/Ruby/3.3.6/arm64/lib/ruby/gems/3.3.0/gems/commander-4.6.0/lib/commander/delegates.rb:18:in run!'
from /Users/runner/hostedtoolcache/Ruby/3.3.6/arm64/lib/ruby/gems/3.3.0/gems/fastlane-2.225.0/fastlane/lib/fastlane/commands_generator.rb:363:in run'
from /Users/runner/hostedtoolcache/Ruby/3.3.6/arm64/lib/ruby/gems/3.3.0/gems/fastlane-2.225.0/fastlane/lib/fastlane/commands_generator.rb:43:in start'
from /Users/runner/hostedtoolcache/Ruby/3.3.6/arm64/lib/ruby/gems/3.3.0/gems/fastlane-2.225.0/fastlane/lib/fastlane/cli_tools_distributor.rb:123:in take_off'
from /Users/runner/hostedtoolcache/Ruby/3.3.6/arm64/lib/ruby/gems/3.3.0/gems/fastlane-2.225.0/bin/fastlane:23:in <top (required)>'
from /Users/runner/hostedtoolcache/Ruby/3.3.6/arm64/bin/fastlane:25:in load'
from /Users/runner/hostedtoolcache/Ruby/3.3.6/arm64/bin/fastlane:25:in <top (required)>'
from /Users/runner/hostedtoolcache/Ruby/3.3.6/arm64/lib/ruby/gems/3.3.0/gems/bundler-2.5.18/lib/bundler/cli/exec.rb:58:in load'
from /Users/runner/hostedtoolcache/Ruby/3.3.6/arm64/lib/ruby/gems/3.3.0/gems/bundler-2.5.18/lib/bundler/cli/exec.rb:58:in kernel_load'
from /Users/runner/hostedtoolcache/Ruby/3.3.6/arm64/lib/ruby/gems/3.3.0/gems/bundler-2.5.18/lib/bundler/cli/exec.rb:23:in run'
from /Users/runner/hostedtoolcache/Ruby/3.3.6/arm64/lib/ruby/gems/3.3.0/gems/bundler-2.5.18/lib/bundler/cli.rb:455:in exec'
from /Users/runner/hostedtoolcache/Ruby/3.3.6/arm64/lib/ruby/gems/3.3.0/gems/bundler-2.5.18/lib/bundler/vendor/thor/lib/thor/command.rb:28:in run'
from /Users/runner/hostedtoolcache/Ruby/3.3.6/arm64/lib/ruby/gems/3.3.0/gems/bundler-2.5.18/lib/bundler/vendor/thor/lib/thor/invocation.rb:127:in invoke_command'
from /Users/runner/hostedtoolcache/Ruby/3.3.6/arm64/lib/ruby/gems/3.3.0/gems/bundler-2.5.18/lib/bundler/vendor/thor/lib/thor.rb:527:in dispatch'
from /Users/runner/hostedtoolcache/Ruby/3.3.6/arm64/lib/ruby/gems/3.3.0/gems/bundler-2.5.18/lib/bundler/cli.rb:35:in dispatch'
from /Users/runner/hostedtoolcache/Ruby/3.3.6/arm64/lib/ruby/gems/3.3.0/gems/bundler-2.5.18/lib/bundler/vendor/thor/lib/thor/base.rb:584:in start'
from /Users/runner/hostedtoolcache/Ruby/3.3.6/arm64/lib/ruby/gems/3.3.0/gems/bundler-2.5.18/lib/bundler/cli.rb:29:in start'
from /Users/runner/hostedtoolcache/Ruby/3.3.6/arm64/lib/ruby/gems/3.3.0/gems/bundler-2.5.18/exe/bundle:28:in block in <top (required)>'
from /Users/runner/hostedtoolcache/Ruby/3.3.6/arm64/lib/ruby/gems/3.3.0/gems/bundler-2.5.18/lib/bundler/friendly_errors.rb:117:in with_friendly_errors'
from /Users/runner/hostedtoolcache/Ruby/3.3.6/arm64/lib/ruby/gems/3.3.0/gems/bundler-2.5.18/exe/bundle:20:in <top (required)>'
from /Users/runner/hostedtoolcache/Ruby/3.3.6/arm64/bin/bundle:25:in load'
from /Users/runner/hostedtoolcache/Ruby/3.3.6/arm64/bin/bundle:25:in <main>'
Error: Process completed with exit code 1.
我尝试对密钥进行硬编码,我尝试将其编码为 Base64,但我被卡住了。 根据 Fastlane 的文档,这应该可行。 如有任何帮助,我们将不胜感激!
JSON 文件中不能有注释。
以
#
开头的注释只是为了帮助您理解示例。您需要将它们从您的文件中删除。