15

Auto-incrementing Build Numbers

 2 years ago
source link: https://ionic.io/docs/appflow/cookbook/auto-incrementing-build-numbers?__hstc=57877749.13fec86b9386e1387ca32c12f14fc618.1641427479017.1641427479017.1641427479017.1&__hssc=57877749.1.1641427479024&__hsfp=3069437029
Go to the source link to view the article. You can view the picture content, updated content and better typesetting reading experience. If the link is broken, please click the button below to view the snapshot at that time.
neoserver,ios ssh client

Auto-incrementing Build Numbers in Capacitor

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 @capacitor/configure

Next, create a simple appflow.yml file with the following contents:

vars:  CI_BUILD_NUMBER:    default: 1
platforms:  ios:    buildNumber: $CI_BUILD_NUMBER  android:    versionCode: $CI_BUILD_NUMBER

Finally, add the appflow:build script to your npm scripts in package.json to run this configuration during an Appflow build:

  "scripts": {    "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:

  "scripts": {    "appflow:build": "CI_BUILD_NUMBER=$(($CI_BUILD_NUMBER + 1234)) npx cap-config run appflow.yml -y && npm run build"  },

Learn more#

The Capacitor Configure utility has a number of additional features that may be useful in your build pipeline. Explore the ionic-team/capacitor-configure repo to learn more.


About Joyk


Aggregate valuable and interesting links.
Joyk means Joy of geeK