Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Error uploading after updating to XCode 13 #27

Open
JesperNJessen opened this issue Nov 29, 2021 · 10 comments
Open

Error uploading after updating to XCode 13 #27

JesperNJessen opened this issue Nov 29, 2021 · 10 comments

Comments

@JesperNJessen
Copy link

JesperNJessen commented Nov 29, 2021

I'm getting this error even though I can see my .p8 file in ~/private_keys

Is there something I need to change or do on my mac action runner machine?

Error message:

The file 'AuthKey_***.p8' could not be found in any of these locations: '~/actions-runner/_work/ProjectName/ProjectName/private_keys', '~/private_keys', '~/.private_keys', '~/.appstoreconnect/private_keys'.

Full output:

<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
<plist version="1.0">
<dict>
	<key>os-version</key>
	<string>12.0.1</string>
	<key>product-errors</key>
	<array>
		<dict>
			<key>code</key>
			<integer>-1011</integer>
			<key>message</key>
			<string>Unable to upload archive.</string>
			<key>userInfo</key>
			<dict>
				<key>NSLocalizedDescription</key>
				<string>Unable to upload archive.</string>
				<key>NSLocalizedFailureReason</key>
				<string>Failed to authenticate with errors: (
    "Error Domain=ITunesConnectionAuthenticationErrorDomain Code=-26000 \"Failed to generate JWT token: Error Domain=NSCocoaErrorDomain Code=-43 \"Failed to load AuthKey file.\" UserInfo={NSLocalizedDescription=Failed to load AuthKey file., NSLocalizedFailureReason=The file 'AuthKey_***.p8' could not be found in any of these locations: '~/actions-runner/_work/ProjectName/ProjectName/private_keys', '~/private_keys', '~/.private_keys', '~/.appstoreconnect/private_keys'.}\" UserInfo={NSLocalizedRecoverySuggestion=Failed to generate JWT token: Error Domain=NSCocoaErrorDomain Code=-43 \"Failed to load AuthKey file.\" UserInfo={NSLocalizedDescription=Failed to load AuthKey file., NSLocalizedFailureReason=The file 'AuthKey_***.p8' could not be found in any of these locations: '~/actions-runner/_work/ProjectName/ProjectName/private_keys', '~/private_keys', '~/.private_keys', '~/.appstoreconnect/private_keys'.}, NSLocalizedDescription=Failed to generate JWT token: Error Domain=NSCocoaErrorDomain Code=-43 \"Failed to load AuthKey file.\" UserInfo={NSLocalizedDescription=Failed to load AuthKey file., NSLocalizedFailureReason=The file 'AuthKey_***.p8' could not be found in any of these locations: '~/actions-runner/_work/ProjectName/ProjectName/private_keys', '~/private_keys', '~/.private_keys', '~/.appstoreconnect/private_keys'.}, NSLocalizedFailureReason=App Store operation failed.}"
)</string>
			</dict>
		</dict>
	</array>
	<key>tool-path</key>
	<string>/Applications/Xcode.app/Contents/SharedFrameworks/ContentDeliveryServices.framework/Versions/A/Frameworks/AppStoreService.framework</string>
	<key>tool-version</key>
	<string>4.060.1220</string>
</dict>
</plist>

EDIT: I managed to upload the IPA manually from my mac. The IPA was saved correctly and altool accepted the upload when I did it through the terminal. However, when I try to use my Github Action for this, it always fails with this same error message.

I have included my workflow file here for context:

on:
  workflow_dispatch:

jobs:
  iOS:
    runs-on: macOS
    steps:
    - uses: actions/checkout@v2
      with:
        fetch-depth: 0 
    - uses: actions/setup-dotnet@v1
      with:
        dotnet-version: '3.1.x'
    - uses: nuget/setup-nuget@v1
      with:
        nuget-version: 'latest'
    - name: Import signing certificate
      uses: Apple-Actions/import-codesign-certs@v1
      with:
        keychain: ${{ runner.temp }}/signing_temp
        p12-file-base64: ${{ secrets.SIGNING_CERTIFICATE_DATA }}
        p12-password: ${{ secrets.SIGNING_CERTIFICATE_PASSWORD }}
    - name: Import provisioning profile
      env:
        PROVISIONING_PROFILE: ${{secrets.PROVISIONING_PROFILE_DATA}}
      run: |
        mkdir -p ~/Library/MobileDevice/Provisioning\ Profiles
        echo "$PROVISIONING_PROFILE" | base64 --decode > ~/Library/MobileDevice/Provisioning\ Profiles/profile.mobileprovision
    - name: Build ipa
      run: |
        nuget restore ProjectName.sln
        cd ProjectName
        msbuild ProjectName.iOS/ProjectName.iOS.csproj \
        /p:Configuration=Release /p:Platform=iPhone \
        /p:BuildIpa=true \
        /p:FirebaseCrashlyticsUploadSymbolsEnabled=true \
        /p:IpaPackageDir=$GITHUB_WORKSPACE/ProjectName/ProjectName.iOS/bin/iPhone/Release \
        "/p:Codesignkey=iPhone Distribution"
    - name: Upload a Build Artifact
      uses: actions/upload-artifact@v2
      with:
        path: ${{ github.workspace }}/ProjectName/ProjectName.iOS/bin/iPhone/Release/*ipa
    - name: 'Upload app to TestFlight'
      uses: apple-actions/upload-testflight-build@v1
      with: 
        app-path: '${{ github.workspace }}/ProjectName/ProjectName.iOS/bin/iPhone/Release/ProjectName.ipa' 
        issuer-id: ${{ secrets.APP_KEY_ISSUER }}
        api-key-id: ${{ secrets.APPLE_CONNECT_KEY_ID_APP_MANAGER }}
        api-private-key: ${{ secrets.APPLE_CONNECT_API_PKCS8 }}
@timnew
Copy link

timnew commented Dec 13, 2021

I ran into the exactly same issue

@NPSconsultingLLC
Copy link

I am having the same problem, did anybody find a work around for this ?

@wangchaodong
Copy link

I ran into the exactly same issue

@rudrankriyam
Copy link

Curious to know if anyone found a workaround for this or pinpointed the issue causing this? Is this happening randomly for everyone?

@Miiite
Copy link

Miiite commented Mar 7, 2022

I've been trying to use the task for a few days, but I end up with the same results as everyone else.
The thing is, even if I don't use the task and use the command-line tool instead

xcrun altool --output-format xml --upload-app --file "the-ring.io preprod.ipa" \
           --type ios --apiKey ${{ secrets.APPSTORE_API_KEY_ID }} \
           --apiIssuer ${{ secrets.APPSTORE_ISSUER_ID }}

I end up with this authentication issue. So something must have changed for this process with the latest XCode version, but I'm having trouble finding what exactly.

But this command-line fails only when ran on a github action agent. Locally on my dev machine it's working fine. So my guess is it has something to do with certificates ?

@VlasiukVV
Copy link

Hey guys! I split this flow into two steps:

  • The first one is creating the secret key file in the app folder.
  • The second one is running publish script.

Example of the code:

# CD part
      - name: Install private API key P8
        env:
          PRIVATE_API_KEY_BASE64: ${{ secrets.PRIVATE_API_KEY_BASE64 }}
          API_KEY: ${{ secrets.API_KEY }}
        run: | 
          mkdir -p ~/private_keys
          echo -n "$PRIVATE_API_KEY_BASE64" | base64 --decode --output ~/private_keys/AuthKey_$API_KEY.p8

      - name: Upload app to TestFlight
        env:
          API_KEY: ${{ secrets.API_KEY }}
          API_ISSUER : ${{ secrets.API_ISSUER  }}
        run: xcrun altool --output-format xml --upload-app -f path/to/your.ipa -t ios --apiKey $API_KEY --apiIssuer $API_ISSUER

@pckz
Copy link

pckz commented Apr 14, 2022

thanks @VlasiukVV
In my case I have to:

  1. create an API KEY here: https://appstoreconnect.apple.com/access/api
  2. download file *.p8, record Key ID and Issuer ID
  3. create folder "private_keys" in home and move *.p8 file there mkdir -p ~/private_keys; cp *.p8 ~/private_keys
  4. use command xcrun altool --upload-app -f IPA_FILE.ipa --type ios --apiKey KEY_ID --apiIssuer ISSUER_ID

worked like a charm

@danryu
Copy link

danryu commented Sep 12, 2022

Have the same error on XCode 13.4.1.
Looks like this repo is unmaintained now, ~18 months since activity.
Back to using xcrun alttool manually I guess.

@taatiq882
Copy link

taatiq882 commented Jul 1, 2023

I have been stuck on this for days
"no such file or directory, open '/Users/runner/private_keys/AuthKey_.p8" .*
So I even manually placed the p8 file in the directory but still got this issue. Any idea why its happening?
Screenshot 2023-07-01 at 9 25 06 PM

@scarlac
Copy link

scarlac commented Mar 4, 2024

Setting the environment variable API_PRIVATE_KEYS_DIR to the directory that contains the file also works, although the file still MUST to be named in the format AuthKey_<Key ID>.p8 where Key ID is the one seen in the App Store Connect web UI:

API_PRIVATE_KEYS_DIR=/my/custom/folder xcrun altool --list-apps --apiKey ABC12FGH12 --apiIssuer 424242429-4242-4242-4242-424242424242

Such that you store your key as /my/custom/folder/AuthKey_ABC12FGH12.p8.

Which is described in the man page for altool:

              --apiKey api_key
                     apiKey. Required for JWT authentication (in lieu of username/password). This option will search the following directories in sequence for a private key file with the name of
                     'AuthKey_<api_key>.p8': './private_keys', '~/private_keys', '~/.private_keys', and '~/.appstoreconnect/private_keys'. Additionally, you can set the environment variable
                     $API_PRIVATE_KEYS_DIR or a user default API_PRIVATE_KEYS_DIR to specify the directory where your AuthKey file is located.

              --apiIssuer issuer_id
                     Issuer ID. Required if --apiKey is specified.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests