codemagic-ci-cd / cli-tools

Various utilities to managing Android and iOS app builds, code signing, and deployment.
https://codemagic.io/start/
GNU General Public License v3.0
244 stars 42 forks source link

keychain: command not found #285

Closed agorkiy closed 1 year ago

agorkiy commented 1 year ago

Hi I'm using codemagic cli tools in github workflow to build ios app. It worked fine 6 days ago, but now gives this error:

writing RSA key
/Users/runner/work/_temp/4f71b5b3-3bfa-44b6-a102-64964826b285.sh: line 5: keychain: command not found

Here is the entire workflow step:

      - name: Setup certificates
        env:
          APP_STORE_CONNECT_ISSUER_ID: ${{ secrets.APPSTORE_API_KEY_ID }}
          APP_STORE_CONNECT_KEY_IDENTIFIER: ${{ secrets.APPSTORE_ISSUER_ID }}
          P12_PASSWORD: ${{ secrets.P12_PASSWORD }}
        run: |
          pip3 install codemagic-cli-tools
          echo -n ${{ secrets.APPSTORE_API_PRIVATE_KEY }} | base64 --decode > appstore_key.p8
          echo -n ${{ secrets.BUILD_CERTIFICATE_BASE64 }} | base64 --decode > build_cert.p12
          openssl pkcs12 -in build_cert.p12 -nodes -nocerts -passin pass:$P12_PASSWORD | openssl rsa -out cert_key
          keychain initialize
          app-store-connect fetch-signing-files $(xcode-project detect-bundle-id) \
              --platform IOS \
              --type IOS_APP_STORE \
              --certificate-key=@file:cert_key \
              --private-key=@file:appstore_key.p8 \
              --create
          keychain add-certificates
          xcode-project use-profiles

Here is full log:

Run pip3 install codemagic-cli-tools

Collecting codemagic-cli-tools
  Downloading codemagic_cli_tools-0.36.2-py3-none-any.whl (22.3 MB)
     ━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━ 22.3/22.3 MB 43.9 MB/s eta 0:00:00
Collecting cryptography!=37.0.0,<38.0.0,>=3.3
  Downloading cryptography-37.0.4-cp36-abi3-macosx_10_10_x86_64.whl (2.8 MB)
     ━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━ 2.8/2.8 MB 14.7 MB/s eta 0:00:00
Collecting google-api-python-client>=1.7.12
  Downloading google_api_python_client-2.65.0-py2.py3-none-any.whl (10.4 MB)
     ━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━ 10.4/10.4 MB 51.1 MB/s eta 0:00:00
Collecting httplib2>=0.19.0
  Downloading httplib2-0.21.0-py3-none-any.whl (96 kB)
     ━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━ 96.8/96.8 kB 6.9 MB/s eta 0:00:00
Collecting oauth2client>=4.1.3
  Downloading oauth2client-4.1.3-py2.py3-none-any.whl (98 kB)
     ━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━ 98.2/98.2 kB 13.3 MB/s eta 0:00:00
Collecting psutil>=5.8.0
  Downloading psutil-5.9.3.tar.gz (483 kB)
     ━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━ 483.6/483.6 kB 35.8 MB/s eta 0:00:00
  Installing build dependencies: started
  Installing build dependencies: finished with status 'done'
  Getting requirements to build wheel: started
  Getting requirements to build wheel: finished with status 'done'
  Installing backend dependencies: started
  Installing backend dependencies: finished with status 'done'
  Preparing metadata (pyproject.toml): started
  Preparing metadata (pyproject.toml): finished with status 'done'
Collecting pyjwt<3.0.0,>=2.4.0
  Downloading PyJWT-2.6.0-py3-none-any.whl (20 kB)
Collecting requests>=2.25
  Downloading requests-2.28.1-py3-none-any.whl (62 kB)
     ━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━ 62.8/62.8 kB 6.2 MB/s eta 0:00:00
Collecting cffi>=1.12
  Downloading cffi-1.15.1-cp311-cp311-macosx_10_9_x86_64.whl (179 kB)
     ━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━ 179.2/179.2 kB 2.3 MB/s eta 0:00:00
Collecting google-auth<3.0.0dev,>=1.19.0
  Downloading google_auth-2.14.0-py2.py3-none-any.whl (175 kB)
     ━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━ 175.0/175.0 kB 20.8 MB/s eta 0:00:00
Collecting google-auth-httplib2>=0.1.0
  Downloading google_auth_httplib2-0.1.0-py2.py3-none-any.whl (9.3 kB)
Collecting google-api-core!=2.0.*,!=2.1.*,!=2.2.*,!=2.3.0,<3.0.0dev,>=1.31.5
  Downloading google_api_core-2.10.2-py3-none-any.whl (115 kB)
     ━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━ 115.6/115.6 kB 17.4 MB/s eta 0:00:00
Collecting uritemplate<5,>=3.0.1
  Downloading uritemplate-4.1.1-py2.py3-none-any.whl (10 kB)
Collecting pyparsing!=3.0.0,!=3.0.1,!=3.0.2,!=3.0.3,<4,>=2.4.2
  Downloading pyparsing-3.0.9-py3-none-any.whl (98 kB)
     ━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━ 98.3/98.3 kB 15.0 MB/s eta 0:00:00
Collecting pyasn1>=0.1.7
  Downloading pyasn1-0.4.8-py2.py3-none-any.whl (77 kB)
     ━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━ 77.1/77.1 kB 7.0 MB/s eta 0:00:00
Collecting pyasn1-modules>=0.0.5
  Downloading pyasn1_modules-0.2.8-py2.py3-none-any.whl (155 kB)
     ━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━ 155.3/155.3 kB 2.2 MB/s eta 0:00:00
Collecting rsa>=3.1.4
  Downloading rsa-4.9-py3-none-any.whl (34 kB)
Collecting six>=1.6.1
  Downloading six-1.16.0-py2.py3-none-any.whl (11 kB)
Collecting charset-normalizer<3,>=2
  Downloading charset_normalizer-2.1.1-py3-none-any.whl (39 kB)
Collecting idna<4,>=2.5
  Downloading idna-3.4-py3-none-any.whl (61 kB)
     ━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━ 61.5/61.5 kB 10.2 MB/s eta 0:00:00
Collecting urllib3<1.27,>=1.21.1
  Downloading urllib3-1.26.12-py2.py3-none-any.whl (140 kB)
     ━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━ 140.4/140.4 kB 3.4 MB/s eta 0:00:00
Requirement already satisfied: certifi>=2017.4.17 in /Library/Frameworks/Python.framework/Versions/3.11/lib/python3.11/site-packages (from requests>=2.25->codemagic-cli-tools) (2022.9.24)
Collecting pycparser
  Downloading pycparser-2.21-py2.py3-none-any.whl (118 kB)
     ━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━ 118.7/118.7 kB 16.1 MB/s eta 0:00:00
Collecting googleapis-common-protos<2.0dev,>=1.56.2
  Downloading googleapis_common_protos-1.56.4-py2.py3-none-any.whl (211 kB)
     ━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━ 211.7/211.7 kB 24.8 MB/s eta 0:00:00
Collecting protobuf!=3.20.0,!=3.20.1,!=4.21.0,!=4.21.1,!=4.21.2,!=4.21.3,!=4.21.4,!=4.21.5,<5.0.0dev,>=3.19.5
  Downloading protobuf-4.21.9-cp37-abi3-macosx_10_9_universal2.whl (483 kB)
     ━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━ 483.8/483.8 kB 26.3 MB/s eta 0:00:00
Collecting cachetools<6.0,>=2.0.0
  Downloading cachetools-5.2.0-py3-none-any.whl (9.3 kB)
Building wheels for collected packages: psutil
  Building wheel for psutil (pyproject.toml): started
  Building wheel for psutil (pyproject.toml): finished with status 'done'
  Created wheel for psutil: filename=psutil-5.9.3-cp311-cp311-macosx_10_9_universal2.whl size=270420 sha256=aa565121ab944073a8aede614b9369a0064e6cdfcb6fc7c97cf0f9c780f1f24b
  Stored in directory: /Users/runner/Library/Caches/pip/wheels/f7/62/d7/397c42c63b442586c3667a8facad29e859c6d081bf1161a359
Successfully built psutil
Installing collected packages: pyasn1, urllib3, uritemplate, six, rsa, pyparsing, pyjwt, pycparser, pyasn1-modules, psutil, protobuf, idna, charset-normalizer, cachetools, requests, httplib2, googleapis-common-protos, google-auth, cffi, oauth2client, google-auth-httplib2, google-api-core, cryptography, google-api-python-client, codemagic-cli-tools
Successfully installed cachetools-5.2.0 cffi-1.15.1 charset-normalizer-2.1.1 codemagic-cli-tools-0.36.2 cryptography-37.0.4 google-api-core-2.10.2 google-api-python-client-2.65.0 google-auth-2.14.0 google-auth-httplib2-0.1.0 googleapis-common-protos-1.56.4 httplib2-0.21.0 idna-3.4 oauth2client-4.1.3 protobuf-4.21.9 psutil-5.9.3 pyasn1-0.4.8 pyasn1-modules-0.2.8 pycparser-2.21 pyjwt-2.6.0 pyparsing-3.0.9 requests-2.28.1 rsa-4.9 six-1.16.0 uritemplate-4.1.1 urllib3-1.26.12

Notice:  A new release of pip available: 22.3 -> 22.3.1
Notice:  To update, run: /Library/Frameworks/Python.framework/Versions/3.11/bin/python -m pip install --upgrade pip
writing RSA key
/Users/runner/work/_temp/4f71b5b3-3bfa-44b6-a102-64964826b285.sh: line 5: keychain: command not found
Error: Process completed with exit code 127.

Any idea what went wrong? I see that your tools were updated recently, as well as macos on github from 11.7 to 11.7.1. Already tried dowgrade your tools version to 0.34 (which worked before)/updated macos to 12.6.1 - all this gave no effect.

priitlatt commented 1 year ago

Hi @agorkiy. This is most likely due to changes that were made to macOS runner image. There is also a relevant issue for that in in the runner images repo: https://github.com/actions/runner-images/issues/6507. Unfortunately we don't have any control over that.

For now the easiest workaround seems to be to add

/Library/Frameworks/Python.framework/Versions/Current/bin

to system PATH as was suggested by @ssrobins in this comment.

agorkiy commented 1 year ago

@priitlatt this fixed an issue, thank you.