使用 Github 操作安装私有 Pod

发布于 2025-01-10 02:47:11 字数 3260 浏览 0 评论 0原文

我正在尝试使用 Github 操作部署应用程序,但由于我的应用程序中有一个私有 Pod,因此遇到了很多问题。我查看了如何解决此问题的各种建议,但找到的答案都没有帮助我部署应用程序。我的脚本如下所示:

name: deploy

on:
  push:
    branches: [ develop ]
    tags: [ v* ]

jobs:
  deploy:
    runs-on: macos-latest

    steps:
      - name: Checkout project
        uses: actions/checkout@v2

      - name: Set environment variables from project settings
        run: |
          exec .github/scripts/set-env-from-xcodeproj.sh                              

      - name: Import signing certificate
        env:
          SIGNING_CERTIFICATE_P12_DATA: ${{ secrets.SIGNING_CERTIFICATE_P12_DATA }}
          SIGNING_CERTIFICATE_PASSWORD: ${{ secrets.SIGNING_CERTIFICATE_PASSWORD }}
        run: |
          exec .github/scripts/import-certificate.sh

      - name: Import provisioning profile
        env:
          PROVISIONING_PROFILE_DATA: ${{ secrets.PROVISIONING_PROFILE_DATA }}
        run: |
          exec .github/scripts/import-profile.sh

      - name: Credentials setup
        run: |
          git config --global credential.helper store
          echo "https://username:${{ secrets.GIT_TOKEN }}@github.com" > ~/.git-credentials
        
      - name: Dependencies install
        run: |
          pod install

      - name: Build app
        run: |
          fastlane run build_app

      - name: Upload build artifacts
        uses: actions/upload-artifact@v2
        with:
          name: build.log
          path: ~/Library/Logs/gym/*.log

      - name: Upload release assets
        if: startsWith(github.ref, 'refs/tags/v')
        uses: softprops/action-gh-release@v1
        with:
          files: |
            ${{ env.PRODUCT_NAME }}.ipa
            ${{ env.PRODUCT_NAME }}.app.dSYM.zip
        env:
          GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}

      - name: Upload app to App Store Connect
        if: startsWith(github.ref, 'refs/tags/v')
        env:
          APP_STORE_CONNECT_USERNAME: ${{ secrets.APP_STORE_CONNECT_USERNAME }}
          APP_STORE_CONNECT_PASSWORD: ${{ secrets.APP_STORE_CONNECT_PASSWORD }}
        run: |
          xcrun altool --upload-app -t ios -f "$PRODUCT_NAME.ipa" -u "$APP_STORE_CONNECT_USERNAME" -p "$APP_STORE_CONNECT_PASSWORD"

我的 podfile:

# Uncomment the next line to define a global platform for your project
platform :ios, '13.0'

source 'https://github.com/organization/privatepod.git'
source 'https://github.com/CocoaPods/Specs.git'

post_install do |installer_representation|
    installer_representation.pods_project.targets.each do |target|
        target.build_configurations.each do |config|
            config.build_settings['ONLY_ACTIVE_ARCH'] = 'NO'
            config.build_settings['BUILD_LIBRARY_FOR_DISTRIBUTION'] = 'YES'
        end
    end
end
  
target 'Target' do
  # Comment the next line if you don't want to use dynamic frameworks
  use_frameworks!
    
  # Pods for LHTest
  pod 'privatepodname', '~>2.2.6'
  pod 'Firebase/Core'
  pod 'Firebase/Analytics'
  pod 'Firebase/Messaging'
  pod 'Firebase/Crashlytics'
    
end

我收到一条错误消息: fatal: Could not read from Remote repository。 请确保您拥有正确的访问权限。

我还尝试了一种通过 pod repo add 命令手动添加存储库的方法,但仍然收到错误。我的理解是,脚本中的“凭据设置”行应该足以验证我的 github 帐户并允许我安装私人存储库,但它似乎不起作用。

I'm trying to deploy an app using Github actions, and I have a lot of issues due to the fact that I have a private pod in my app. I looked at various suggestions how to solve this but none of the answers I found helped me in deploying the app. Here is how my script looks like:

name: deploy

on:
  push:
    branches: [ develop ]
    tags: [ v* ]

jobs:
  deploy:
    runs-on: macos-latest

    steps:
      - name: Checkout project
        uses: actions/checkout@v2

      - name: Set environment variables from project settings
        run: |
          exec .github/scripts/set-env-from-xcodeproj.sh                              

      - name: Import signing certificate
        env:
          SIGNING_CERTIFICATE_P12_DATA: ${{ secrets.SIGNING_CERTIFICATE_P12_DATA }}
          SIGNING_CERTIFICATE_PASSWORD: ${{ secrets.SIGNING_CERTIFICATE_PASSWORD }}
        run: |
          exec .github/scripts/import-certificate.sh

      - name: Import provisioning profile
        env:
          PROVISIONING_PROFILE_DATA: ${{ secrets.PROVISIONING_PROFILE_DATA }}
        run: |
          exec .github/scripts/import-profile.sh

      - name: Credentials setup
        run: |
          git config --global credential.helper store
          echo "https://username:${{ secrets.GIT_TOKEN }}@github.com" > ~/.git-credentials
        
      - name: Dependencies install
        run: |
          pod install

      - name: Build app
        run: |
          fastlane run build_app

      - name: Upload build artifacts
        uses: actions/upload-artifact@v2
        with:
          name: build.log
          path: ~/Library/Logs/gym/*.log

      - name: Upload release assets
        if: startsWith(github.ref, 'refs/tags/v')
        uses: softprops/action-gh-release@v1
        with:
          files: |
            ${{ env.PRODUCT_NAME }}.ipa
            ${{ env.PRODUCT_NAME }}.app.dSYM.zip
        env:
          GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}

      - name: Upload app to App Store Connect
        if: startsWith(github.ref, 'refs/tags/v')
        env:
          APP_STORE_CONNECT_USERNAME: ${{ secrets.APP_STORE_CONNECT_USERNAME }}
          APP_STORE_CONNECT_PASSWORD: ${{ secrets.APP_STORE_CONNECT_PASSWORD }}
        run: |
          xcrun altool --upload-app -t ios -f "$PRODUCT_NAME.ipa" -u "$APP_STORE_CONNECT_USERNAME" -p "$APP_STORE_CONNECT_PASSWORD"

And my podfile:

# Uncomment the next line to define a global platform for your project
platform :ios, '13.0'

source 'https://github.com/organization/privatepod.git'
source 'https://github.com/CocoaPods/Specs.git'

post_install do |installer_representation|
    installer_representation.pods_project.targets.each do |target|
        target.build_configurations.each do |config|
            config.build_settings['ONLY_ACTIVE_ARCH'] = 'NO'
            config.build_settings['BUILD_LIBRARY_FOR_DISTRIBUTION'] = 'YES'
        end
    end
end
  
target 'Target' do
  # Comment the next line if you don't want to use dynamic frameworks
  use_frameworks!
    
  # Pods for LHTest
  pod 'privatepodname', '~>2.2.6'
  pod 'Firebase/Core'
  pod 'Firebase/Analytics'
  pod 'Firebase/Messaging'
  pod 'Firebase/Crashlytics'
    
end

I get an error saying fatal: Could not read from remote repository.
Please make sure you have the correct access rights.

I also tried an approach to manually add the repo via pod repo add command but still get the error. My undersntanding was that the line "Credentials setup" form the script should be enough to authenticate my github account and allow me to install the private repo but it doesn't seem to work.

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

等风也等你 2025-01-17 02:47:11

要对私有存储库进行身份验证,您必须使用 SSH 密钥而不是 https - https 仅使用钥匙串密码,并提示输入用户/密码(如果不存在) - 它不会'不要在 CI 上工作。

切换到:
[电子邮件受保护]:organization/privatepod.git

此外,如果您启用了 2FA(我希望您这样做)- 您需要使用用于身份验证的 PERSONAL_TOKEN:

https://docs.github.com/en/authentication/keeping-your-account-and-data-secure/creating-a-personal-access-token

To authenticate to the private repository you have to use SSH keys rather than https - https is only using keychain password and prompting for user/password if it's not there - it won't work on CI.

Switch to:
[email protected]:organization/privatepod.git

Also if you have 2FA enabled (I hope you do) - you need to use a PERSONAL_TOKEN for authentication:

https://docs.github.com/en/authentication/keeping-your-account-and-data-secure/creating-a-personal-access-token

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文