How to deploy a package to pub.dev using codemagic.yaml
In order to get publishing permissions, you first need to log in to pub.dev 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).
Open your Codemagic app settings, and go to the Environment variables tab.
Enter the desired Variable name, e.g.
Enter the token value as Variable value.
Make sure the Secure option is selected.
Click the Add button to add the variable.
Configure publishing in
environment: vars: PUB_DEV_CREDENTIALS # ... scripts: - name: Publish to pub.dev script: | echo $PUB_DEV_CREDENTIALS > "$FLUTTER_ROOT/.pub-cache/credentials.json" flutter pub publish --dry-run flutter pub publish -f