Giter Site home page Giter Site logo

buildnumbr-api's Introduction

BuildNumbr.com

ci

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

❯ 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 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: versionCode project.hasProperty('versionCode') ? project.property('versionCode') as int : 1 then pass the version code 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

Credits

This service is brought to you by Yorty Ruiz Hernandez

buildnumbr-api's People

Contributors

yortyrh avatar

Stargazers

Yeinier Ferrás Cecilio avatar  avatar

Watchers

 avatar

buildnumbr-api's Issues

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.