Codemagic
Codemagic runs publishing scripts after the build. Add one that uploads the file from your artifacts; Node is already on Codemagic machines. Codemagic runs publishing scripts even when the build failed, so the last build script writes ~/SUCCESS and the upload runs only when that file is there. With no script at all, Connect Codemagic (Pro and Team) imports finished builds with your Codemagic API token.
1. Add your token
Create an API token under Dashboard, Settings, API tokens (Pro and Team). Team or app settings, Environment variables, add APPFORSHARE_TOKEN as Secure in a group (for example appforshare), and import the group in the workflow. The CLI reads it from the APPFORSHARE_TOKEN environment variable.
2. codemagic.yaml (Android)
Codemagic has no commit message variable, so the script reads it with git log. The Mark success script runs only when every build script before it passed.
workflows:
android-beta:
name: Android beta
environment:
groups: [appforshare]
flutter: stable
scripts:
- name: Build apk
script: flutter build apk --release
- name: Mark success
script: touch ~/SUCCESS
artifacts:
- build/app/outputs/flutter-apk/app-release.apk
publishing:
scripts:
- name: Share with testers
script: |
if [ -f ~/SUCCESS ]; then
npx --yes appforshare upload build/app/outputs/flutter-apk/app-release.apk \
--notes "$(git log -1 --pretty=%B) ($CM_BRANCH, ${CM_COMMIT:0:7})" --channel beta
fi3. codemagic.yaml (iOS ad hoc)
Codemagic fetches or makes the ad hoc profile for the bundle id in ios_signing, xcode-project use-profiles writes it to the project and to /Users/builder/export_options.plist, and flutter build ipa exports with that file. Do not add --export-method: Flutter does not take it together with --export-options-plist. Ad hoc builds install on the iPhones in the profile; add a tester's UDID to Apple and run the workflow again for a new device.
workflows:
ios-adhoc:
name: iOS ad hoc
environment:
groups: [appforshare]
flutter: stable
ios_signing:
distribution_type: ad_hoc
bundle_identifier: io.acme.notes
scripts:
- name: Use profiles
script: xcode-project use-profiles
- name: Build ipa
script: flutter build ipa --release --export-options-plist=/Users/builder/export_options.plist
- name: Mark success
script: touch ~/SUCCESS
artifacts:
- build/ios/ipa/*.ipa
publishing:
scripts:
- name: Share with testers
script: |
if [ -f ~/SUCCESS ]; then
npx --yes appforshare upload build/ios/ipa \
--notes "$(git log -1 --pretty=%B) ($CM_BRANCH, ${CM_COMMIT:0:7})" --channel beta
fi4. Shorter, with CLI 1.20.0 or later
On Codemagic the CLI fills the release notes from the last commit, the branch and the short commit, links the Codemagic build page on the build, picks the newest .ipa, .apk or .aab from the build output folders, and --if-success skips the upload when ~/SUCCESS is missing (in the Workflow Editor it reads CM_BUILD_STEP_STATUS instead).
publishing:
scripts:
- name: Share with testers
script: npx --yes appforshare@latest upload --if-success --channel betaGood to know
- Without the ~/SUCCESS check, a failed build still runs the upload: it fails on a missing file, or sends an older file an earlier step left behind.
- Tag builds clone with depth 1, branch builds with depth 50; git log -1 works for both.
- Pull requests: add GITHUB_TOKEN (a GitHub token that can write pull requests) as a Secure variable and --pr-comment; the CLI reads CM_PULL_REQUEST_NUMBER and CM_REPO_SLUG and puts the install links and QR codes in one comment. GitHub repositories only.
- Add --channel beta to keep one stable link for testers, and --fail-on blocked to stop the pipeline when the store readiness check finds a blocker (exit code 2; the build stays uploaded).
- The command prints the install link. Add --json for url, slug, version and channel as JSON. All options are on Upload from CI.
Questions
- Can I upload the .aab Codemagic builds for Google Play?
- Yes. AppForShare turns an .aab into one APK testers can install, signed with a test key made for your account or with your own upload key on Pro and Team. On Pro and Team the original .aab is kept, so an Admin can send it to a Google Play testing track from the build page.
- Does it work with the Workflow Editor instead of YAML?
- Yes. The Workflow Editor is for Flutter apps; other apps use codemagic.yaml. Add a post-publish script with the token as an environment variable, and check $CM_BUILD_STEP_STATUS (Workflow Editor only): if [ "$CM_BUILD_STEP_STATUS" = "success" ]; then npx --yes appforshare upload build/ios/ipa; fi. With CLI 1.20.0 or later, upload --if-success does the same check.
- Can AppForShare pick up Codemagic builds with no script?
- Yes, on Pro and Team. With Connect Codemagic an Owner or Admin pastes a Codemagic API token and maps a Codemagic app and workflow to a project and channel. AppForShare checks for finished builds every 5 minutes and imports one file per build and platform: the .ipa, and for Android the .apk (the .aab when there is no .apk). Builds that finished before the mapping are not imported. It only reads from Codemagic, and the token acts with your Codemagic role. The token is stored encrypted and never shown again; disconnecting deletes it.
Other CI systems
GitHub Actions and FastlaneCircleCIGitLab CIBitbucket PipelinesJenkinsAzure PipelinesXcode CloudBitriseExpo EAS