How to deploy a package to using codemagic.yaml

In order to get publishing permissions, you first need to log in to locally. You can do this by running pub publish --dry-run.

This will create the credentials.json file, which you can use to log in without the need for Google confirmation through the browser. Credentials will be created in the pub cache directory (~/.pub-cache/credentials.json on macOS and Linux, %APPDATA%\Pub\Cache\credentials.json on Windows).

  1. Open your Codemagic app settings, and go to the Environment variables tab.

  2. Enter the desired Variable name, e.g. PUB_DEV_CREDENTIALS.

  3. Enter the token value as Variable value.

  4. Make sure the Secure option is selected.

  5. Click the Add button to add the variable.

  6. Configure publishing in codemagic.yaml

  # ...

    - name: Publish to
      script: | 
        echo $PUB_DEV_CREDENTIALS > "$FLUTTER_ROOT/.pub-cache/credentials.json"
        flutter pub publish --dry-run
        flutter pub publish -f