How can I get the Git build number and embed it in a file?

前端 未结 6 1880
离开以前
离开以前 2020-12-14 21:43

I want to introduce a versioning constant grabbed from the version in Git. I know how to do this -- in a very hackish way in svn --

any ideas on how to do this with

6条回答
  •  难免孤独
    2020-12-14 22:16

    Here's what I do:

    As part of my build process I run the following script (paraphrased, since I'm not at Xcode right now)

    git describe --all > version.txt
    

    Inside my application I read the version number out of this file and display it to the user (when necessary). Make sure you add version.txt to your .gitignore. The benefit of doing it this way is that if you tag your releases git describe will just output the tag, otherwise it'll output the commit hash.

提交回复
热议问题