我有一个简单的GH操作工作流yaml与以下内容:
name: CI
on:
push:
jobs:
ci:
runs-on: macos-latest
defaults:
run:
shell: bash
working-directory: working_directory_here
steps:
- name: Checkout
uses: actions/checkout@v3
- name: Install the Apple certificate and provisioning profile for Xcode
env:
BUILD_CERTIFICATE_BASE64: ${{ secrets.BUILD_CERTIFICATE_BASE64 }}
P12_PASSWORD: ${{ secrets.P12_PASSWORD }}
BUILD_PROVISION_PROFILE_BASE64: ${{ secrets.BUILD_PROVISION_PROFILE_BASE64 }}
KEYCHAIN_PASSWORD: ${{ secrets.KEYCHAIN_PASSWORD }}
run: |
# create variables
CERTIFICATE_PATH=$RUNNER_TEMP/build_certificate.p12
PP_PATH=$RUNNER_TEMP/build_pp.mobileprovision
KEYCHAIN_PATH=$RUNNER_TEMP/app-signing.keychain-db
# import certificate and provisioning profile from secrets
echo -n "$BUILD_CERTIFICATE_BASE64" | base64 --decode --output $CERTIFICATE_PATH
echo -n "$BUILD_PROVISION_PROFILE_BASE64" | base64 --decode --output $PP_PATH
# create temporary keychain
security create-keychain -p "$KEYCHAIN_PASSWORD" $KEYCHAIN_PATH
security set-keychain-settings -lut 21600 $KEYCHAIN_PATH
security unlock-keychain -p "$KEYCHAIN_PASSWORD" $KEYCHAIN_PATH
# import certificate to keychain
security import $CERTIFICATE_PATH -P "$P12_PASSWORD" -A -t cert -f pkcs12 -k $KEYCHAIN_PATH
security list-keychain -d user -s $KEYCHAIN_PATH
# apply provisioning profile
mkdir -p ~/Library/MobileDevice/Provisioning\ Profiles
cp $PP_PATH ~/Library/MobileDevice/Provisioning\ Profiles
- name: Install
run: pod install
- name: Build
run: xcodebuild -workspace something.xcworkspace -sdk iphonesimulator -scheme Development build
- name: Deploy
run: |
xcodebuild clean -workspace something.xcworkspace -scheme Development
xcodebuild archive -workspace something.xcworkspace -scheme Development -archivePath something.xcarchive -destination generic/platform=iOS
Apple证书和配置文件摘自Github中的这篇文章。pod install
、xcodebuild build
和xcodebuild clean
命令即使没有Apple证书步骤也可以工作。
我的xcodebuild archive
步骤失败,出现以下错误:
error: No profiles for 'something.something.development' were found: Xcode couldn't find any iOS App Development provisioning profiles matching 'something.something.development'. Automatic signing is disabled and unable to generate a profile.
添加-allowProvisioningUpdates
并没有什么不同--它仍然会失败,但是在Github Actions输出中根本不会返回任何错误,包括启用调试模式。
1条答案
按热度按时间r8xiu3jd1#
您可能在命令行中缺少参数,在这里我将特别指出
provisioningProfiles
参数。要确保可以正确运行命令,您可以:
1.在开发机器上打开Xcode,如果尚未取消选中,则禁用自动签名
1.仍然在Xcode中,选择您的方案,然后从菜单中运行
Product
〉Archive
。在新窗口中单击Distribute app
并完成步骤。确保您在此步骤中选择了有效的预配配置文件和证书。转到最后并导出(不要转到AppStore),Xcode会生成一个导出文件夹,您应该会在该文件夹中看到一个名为ExportOptions.plist
的文件,如下所示:1.打开导出的文件夹,查找名为
ExportOptions.plist
的文件,该文件基本上包含了传递给CI命令行的参数,以模拟Xcode在本地执行的操作1.将此文件编码为base64并将其存储为Github Actions机密,例如
IOS_EXPORT_OPTIONS_PLIST
1.在Github Action步骤中解析文件,并从base64解码,将其存储在某个地方,例如$EXPORT_OPTIONS_PATH
1.使用此添加的选项运行命令行:
xcodebuild archive -yourparams -exportOptionsPlist $EXPORT_OPTIONS_PATH
注意:您可以运行
xcodebuild -h
来查看可以添加到ExportOptions.plist文件中的所有可用选项。