1

I found this question, which is similar – How do I automatically set the version of my Inno Setup installer according to my application version? – setting installer version based off application version. I want to set based off the git describe command.

I did try the help described in the link I attached, however my version appears blank when I adapt the example code into mine. I don't know how to set this version in the executable – which is why I want to grab it from git. Seems either git or the executable are good places to grab the version, unless someone can describe otherwise for me. If setting the executable version is better, how do I do that?

My question: How do I automatically set the version of my Inno Setup installer according to the latest git describe command?

0

2 Answers 2

1

This is much closer to what you need:
Inno Setup: How to update AppVersion [Setup] value from Config.xml file


  • Write a PowerShell (or any other) script that can save the version number retrieved from git describe to a text file.
  • Use the Exec preprocessor function to execute your script (or if you have an overall build script, just have it generate the text file before you run the iscc compiler).
  • Then you can use the FileOpen and FileRead preprocessor functions to inject the information into your .iss script.
1

You can obtain the SHA1 hash of the last commit using the following command:

git.exe log "--pretty=format:%H" -n 1

The result can be written to file like this:

git.exe log "--pretty=format:%H" -n 1 > revision.txt

Using Inno's preprocessor, this can be done on the fly like this:

#define GetRevision() \
  Local[0] = "/S /C git.exe log ""--pretty=format:%H"" -n 1 > revision.txt", \
  Local[1] = Exec("cmd.exe", Local[0], SourcePath, , SW_HIDE), \
  Local[2] = FileOpen(AddBackslash(SourcePath) + "revision.txt"), \
  Local[3] = FileRead(Local[2]), \
  FileClose(Local[2]), \
  Local[3] 

Finally, you can use the hash anywhere you want in your setup script, e.g. like this:

[Setup]
VersionInfoProductTextVersion={#GetRevision()}

Not the answer you're looking for? Browse other questions tagged or ask your own question.