Incrementing and identifying version and build

Whether this is the “best” practice is in the eyes of the beholder, but what I’ve ended up doing is keeping a separate version number just for my JavaScript bundle. I have a simple file called build.json that has a single property:

{
  "jsBuildNumber": 1
}

Then, I have a node.js script that wraps expo publish, incrementing the build number just before publishing:

const shell = require('shelljs');
const jsonfile = require('jsonfile');
const file = 'build.json';

const data = jsonfile.readFileSync(file);
data.jsBuildNumber = data.jsBuildNumber + 1;

jsonfile.writeFileSync(file, data, { spaces: 2, EOL: '\r\n' });
shell.exec('expo publish');

Then I include that build.json file in my app and display that number along with the version number and build number in our app settings screen, like “1.0.2 / 16 / 1” (version/ build/ JS build).

I think something like this works best in terms of support. I want my version numbers to match what’s on the App Store so nobody is wondering why the app says one thing and the store says another, and, even if they don’t fully understand the OTA updates, I’d like our support folks to be able to communicate a version number to me that tells me if we’re dealing with an OTA update or what was originally published to the store.

One other thing I like to do with this is reset the JS build number when I publish another store version. So then my full three-part version number indicates on its own if its the first store build of that version or a later JS update.

7 Likes