karaggeorge / electron-builder-notarize

Notarize Electron applications using electron-builder
MIT License
80 stars 20 forks source link

The "data" argument must be of type string or ... #17

Closed andyoknen closed 2 years ago

andyoknen commented 2 years ago

This problem only shows up if I use GitHub Actions I have now checked the build according to the instructions from this repository - everything works Maybe the problem is not here - but I hope for help, because I can't find a solution yet. Thanks!

Start notarizing app.pocketnet.gui found at ...
  ⨯ The "data" argument must be of type string or an instance of Buffer, TypedArray, or DataView. Received an instance of Error  failedTask=build stackTrace=TypeError [ERR_INVALID_ARG_TYPE]: The "data" argument must be of type string or an instance of Buffer, TypedArray, or DataView. Received an instance of Error

I followed these instructions https://github.com/samuelmeuli/action-electron-builder#notarization https://samuelmeuli.com/blog/2019-12-28-notarizing-your-electron-app

My build.yml:

name: Build Desktop App

on:
  push:
    #tags: v*.*.*

jobs:
  release:
    runs-on: ${{ matrix.os }}

    strategy:
      matrix:
        os: [macos-latest] # , ubuntu-latest, windows-latest

    steps:
      - name: Check out Git repository
        uses: actions/checkout@v1

      - name: Install Node.js, NPM and Yarn
        uses: actions/setup-node@v1
        with:
          node-version: 14

      - name: Prepare for app notarization
        if: startsWith(matrix.os, 'macos')
        run: |
          mkdir -p ~/private_keys/
          echo '${{ secrets.APPLE_API_KEY }}' > ~/private_keys/AuthKey_${{ secrets.APPLE_API_KEY_ID }}.p8

      - name: Build/release Electron app
        uses: samuelmeuli/action-electron-builder@v1
        with:
          github_token: ${{ secrets.release_token }}
          release: ${{ startsWith(github.ref, 'refs/tags/v') }}
          mac_certs: ${{ secrets.mac_certs }}
          mac_certs_password: ${{ secrets.mac_certs_password }}
        env:
          # TEAM_SHORT_NAME: ${{ secrets.apple_team_short_name }}
          # APPLE_ID: ${{ secrets.apple_id }}
          # APPLE_ID_PASSWORD: ${{ secrets.apple_id_password }}
          API_KEY_ID: ${{ secrets.APPLE_API_KEY_ID }}
          API_KEY_ISSUER_ID: ${{ secrets.APPLE_API_KEY_ISSUER_ID }}
bornova commented 2 years ago

Same problem here. Worked great with macos-10.15 but fails to notarize using macos-latest or macos-12. And since macos-10.15 is now deprecated, I am no longer able to notarize my app using Github Actions.

bornova commented 2 years ago

UPDATE Switching to authenticate with username and password (APPLE_ID and APPLE_ID_PASSWORD) instead of API_KEY has resolved the issue for me. Updated my build.yml as follows:

env:
  APPLE_ID: ${{ secrets.apple_id }}
  APPLE_ID_PASSWORD: ${{ secrets.apple_id_password }}

where APPLE_ID String - The username of your apple developer account APPLE_ID_PASSWORD String - The app-specific password (not your Apple ID password)

juli1 commented 2 years ago

I have exactly the same issue :(

Even by putting APPLE_ID and APPLE_ID_PASSWORD, I still have the issue.

andyoknen commented 2 years ago

I'm not sure which of these helped me, but this configuration signs my code and notarizes successfully

- name: Prepare for app notarization
  run: |
    mkdir -p ~/private_keys/
    echo '${{ secrets.APPLE_API_KEY }}' > ~/private_keys/AuthKey_${{ secrets.APPLE_API_KEY_ID }}.p8
    echo '${{ secrets.APPLECERT }}' | base64 -d > applecert.p12
- name: Building
  env:
    APPLEID: ${{ secrets.APPLEID }}
    APPLEIDPASS: ${{ secrets.APPLEIDPASS }}
    API_KEY_ID: ${{ secrets.APPLE_API_KEY_ID }}
    API_KEY_ISSUER_ID: ${{ secrets.APPLE_API_KEY_ISSUER_ID }}
    CSC_LINK: 'file://applecert.p12'
    CSC_KEY_PASSWORD: ${{ secrets.APPLECERTPWD }}
rkbhochalya commented 2 years ago

Maybe the problem is not here - but I hope for help, because I can't find a solution yet. Thanks!

  ⨯ The "data" argument must be of type string or an instance of Buffer, TypedArray, or DataView. Received an instance of Error  failedTask=build stackTrace=TypeError [ERR_INVALID_ARG_TYPE]: The "data" argument must be of type string or an instance of Buffer, TypedArray, or DataView. Received an instance of Error

@andyoknen the error handling part in the package is throwing this error. You are not able to see the actual error due to this.

https://github.com/karaggeorge/electron-builder-notarize/blob/f78f7644edb8a0554c2d5a99e9aad72f537f70ff/index.js#L99

I'll submit a PR with the fix.

juli1 commented 2 years ago

@juli1 thanks! Would love to have more information about what is going on!

juli1 commented 2 years ago

@andyoknen do you still use samuelmeuli/action-electron-builder@v1? Do you mind sharing your entire configuration?

Thanks,

andyoknen commented 2 years ago

@andyoknen do you still use samuelmeuli/action-electron-builder@v1? Do you mind sharing your entire configuration?

I'm sorry, I mixed up the workflow - in the example above, I use electron-builder to build. Here is my action to build the release now - it looks like everything is fine with it now. I think I fixed the notarization for a long time, but I don't remember exactly how :)

https://github.com/pocketnetteam/pocketnet.gui/blob/master/.github/workflows/build.release.yml

andyoknen commented 2 years ago

I think the issue can be closed - my question is exhausted