Skip to content

Instantly share code, notes, and snippets.

@ctreffs
Created February 5, 2021 13:36
Show Gist options
  • Save ctreffs/c90be699c7e38063b17e07d59024b160 to your computer and use it in GitHub Desktop.
Save ctreffs/c90be699c7e38063b17e07d59024b160 to your computer and use it in GitHub Desktop.
Get build number from git
#!/bin/sh
GIT=$1
if [[ -z $GIT ]]; then
GIT=git
fi
# Use the commit count before HEAD as CFBundleVersion
head_date=`"${GIT}" show -s --format=%cI`
printf `"${GIT}" rev-list --all --before $head_date | wc -l | tr -d ' '`
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment