BuildNumbr

Incrementing ios build numbers and android version codes as a service.

How does it work?

Just send a request to https://buildnumbr.com with a chosen identifier. The response will be 1, and the number will increase with each subsequent request.

 curl -s https://buildnumbr.com/my-app
1
 curl -s https://buildnumbr.com/my-app
2
 curl -s https://buildnumbr.com/my-app
3
 curl -s https://buildnumbr.com/my-other-app
1
 curl -s https://buildnumbr.com/my-other-app/set/1234
1234
 curl -s https://buildnumbr.com/my-other-app
1235
# Get the current value without incrementing
 curl -s https://buildnumbr.com/my-other-app/get
1235

Why?

Integrating with your project

IOS projects

Move into the folder where your Info.plist is and execute this command:

/usr/libexec/PlistBuddy -c "Set :CFBundleVersion (curl https://buildnumbr.com/my-app)" Info.plist

Android projects

  1. In your build.gradle, make the versionCode variable like this:
android {
    ...
    defaultConfig {
        ...
        versionCode project.hasProperty('versionCode') ? project.property('versionCode') as int : 1
        ...
    }
    ...
}
  1. Then the build command will be like this:
./gradlew assembleRelease -PversionCode=$(curl https://buildnumbr.com/my-app)

Fastlane

For iOS projects, use this step:

increment_build_number(
  xcodeproj: './ios/MyAwesomeApp.xcodeproj',
  build_number: sh('curl -s https://buildnumbr.com/my-app-ios')
)

For Android projects, first change the build.gradle file as described above. Then specify the versionCode during your Gradle step:

gradle(task: 'assemble', build_type: 'Release', properties: {
  versionCode: sh('curl -s https://buildnumbr.com/my-app-android')
})

Expo

Update app.json

#!/usr/bin/env node
const fs = require('fs');
const execSync = require('child_process').execSync;
const config = require('./app.json');

const BUILD_NUMBER_COMPONENT_ID = 'my-app-ios';
const VERSION_CODE_COMPONENT_ID = 'my-app-android';

config.expo.ios.buildNumber = String(
  execSync(`curl -s https://buildnumbr.com/${BUILD_NUMBER_COMPONENT_ID}`),
);
config.expo.android.versionCode = Number(
  execSync(`curl -s https://buildnumbr.com/${VERSION_CODE_COMPONENT_ID}`),
);

fs.writeFileSync('app.json', JSON.stringify(config, null, 2));

Use app.config.js

const execSync = require('child_process').execSync;

const BUILD_NUMBER_COMPONENT_ID = 'my-app-ios';
const VERSION_CODE_COMPONENT_ID = 'my-app-android';

module.exports = ({ config }) => {
  const buildNumber = String(
    execSync(`curl -s https://buildnumbr.com/${BUILD_NUMBER_COMPONENT_ID}`),
  );
  const versionCode = Number(
    execSync(`curl -s https://buildnumbr.com/${VERSION_CODE_COMPONENT_ID}`),
  );

  return {
    ...config,
    ios: {
      ...config.ios,
      buildNumber,
    },
    android: {
      ...config.android,
      versionCode,
    },
  };
};

FAQ

curl -s https://buildnumbr.com/my-app
npx ulid | sed -e 's/\(.*\)/\L\1/'
# Get the current build number
 curl -s https://buildnumbr.com/my-app/get
456
# Set the previous value (There isn't any service to decrease the value)
 curl -s https://buildnumbr.com/my-app/set/455
455
export BUILD = $(curl https://buildnumbr.com/my-app)
re='^[0-9]+$'
    if ! [[ $BUILD =~ $re ]] ; then
    echo "error: Not a number" >&2; exit 1
fi
curl https://buildnumbr.com/my-app/set/123