Appflow provides an auto-incrementing environment variable (
CI_BUILD_NUMBER) that can be used to automatically increment build numbers for your Capacitor app on iOS and Android after each build.
To do this, first install the
@capacitor/configure project into your app:
npm install -D @firstname.lastname@example.org
Next, create a simple
appflow.yml file with the following contents:
Finally, add the
appflow:build script to your npm scripts in
package.json to run this configuration during an Appflow build:
"appflow:build": "npx cap-config run appflow.yml -y && npm run build"
Make sure to keep your build command as the second part of the
appflow:build script to ensure your app web assets build properly.
Setting Initial Build Number
If you'd like to start incrementing at a certain number, use the following
appflow:build command instead, substituting your initial build number for the number
1234. All subsequent build numbers will be added to this number:
"appflow:build": "CI_BUILD_NUMBER=$(($CI_BUILD_NUMBER + 1234)) npx cap-config run appflow.yml -y && npm run build"