Skip to content

Instantly share code, notes, and snippets.

@zackdotcomputer
Created April 27, 2020 21:56
Show Gist options
  • Save zackdotcomputer/41605c03d09ce113c0add0fa635f5ad4 to your computer and use it in GitHub Desktop.
Save zackdotcomputer/41605c03d09ce113c0add0fa635f5ad4 to your computer and use it in GitHub Desktop.
Fastlane Ruby Build Number Function
# Generates a build number that will consistently increase worldwide.
# Useful for coordinating build uploads between teams in different timezones.
# Format is "YYYYMMDDsss" where "sss" is the 1000ths slice of the day.
# For example, I just ran it in NYC at 5:55pm on 2020-04-27 and got back: 20200427913
# If anyone else worldwide (with a correct system clock) runs it after this,
# they will get a bigger number guaranteed.
def generate_build_number()
time = Time.new.getutc
date = time.strftime("%Y%m%d")
daySlice = 1000 * ((((time.hour * 60) + time.min) * 60) + time.sec) / (24 * 60 * 60)
return date + daySlice.to_s
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment