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?
- Automatically increasing the build number provides an easy means to identify the latest build in the sequence.
- Assigning a unique build number/version code to each build facilitates quick identification of problematic builds when issues arise.
- iOS’s developers must increment the build number for each uploaded binary; failure to do so leads to rejection, requiring recompilation and re-upload.
- Android developers must raise the version code for each app bundle upload; overlooking this results in rejection, even for a previous version.
- Ensuring continuous integration, without the need to manually commit build number/version code increments, is desirable.
- Achieving decentralized builds allows a subset of the team to build and deploy to Google Play/App Store while ensuring continuous incrementation of version codes/build numbers with each deployment.
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
- In your build.gradle, make the
versionCode
variable like this:
android {
...
defaultConfig {
...
versionCode project.hasProperty('versionCode') ? project.property('versionCode') as int : 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
- My cURL also prints the progress, not just the build number!
Try to add the -s flag to prevent progress being printed:
curl -s https://buildnumbr.com/my-app
-
There is no authentication! How do I prevent others from incrementing my build number?
Just use an identifier that is really hard to guess, like https://buildnumbr.com/01hmqaf00ft6c98h1ytdxh6286. Maybe not that one exactly, but you get the idea. -
How can I get a really hard to guess unique identifier?
npx ulid | sed -e 's/\(.*\)/\L\1/'
- I incremented by accident. Can I go back?
# 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
- I want to make sure the build number you are providing is actually a number
You can add a check that the response that you get from buildnumbr.com is purely numeric.
export BUILD = $(curl https://buildnumbr.com/my-app)
re='^[0-9]+$'
if ! [[ $BUILD =~ $re ]] ; then
echo "error: Not a number" >&2; exit 1
fi
- My current build number is already at
123
. How can I make buildnumbr.com start from this number?
There is another endpoint for this. Simply append/set/{your_number}
and your counter will jump to this number.
curl https://buildnumbr.com/my-app/set/123