anaseto / boohu

Break Out Of Hareka's Underground, a roguelike game.
https://codeberg.org/anaseto/boohu
ISC License
128 stars 8 forks source link

Add version or commit using -v #3

Closed erf closed 6 years ago

erf commented 6 years ago

Add version ( if release version ) or commit using -v

anaseto commented 6 years ago

I've added a variable so that if you build using these flags go get -u -ldflags "-X main.Version=$(git describe --tags)" github.com/anaseto/boohu, you get a complete version number using -v. Without flags I'll put just the last release version.

anaseto commented 6 years ago

Now that I think about it, perhaps I should add version to character dump too.

Thanks for ponting this stuff out!

erf commented 6 years ago

Thanks! The reason i thought of this was because i wanted to see if i was on the latest version. Now it shows v0.3 after i do a go get -u github.com/anaseto/boohu so I'm obviously on the latest version but if the commit version also was there ( if possible ), i could check against the git repo if i'm all up to date. Btw. Great game!

anaseto commented 6 years ago

Actually I wasn't very clear in my previous comment, but if you want the commit version along with the last version (and not only the version), you can do that by using -ldflags this way:

cd $GOPATH/src/github.com/anaseto/boohu
go get -u -ldflags "-X main.Version=$(git describe --tags)" github.com/anaseto/boohu

This will change at build time the value of the variable Version using git describe --tags and giving something like v0.3-36-g20517bb (so 36 commits after v0.3). You could put these two commands in a script. Perhaps I could write a Makefile with this.

Hope this helps, and I'm glad you like the game!

erf commented 6 years ago

I actually tried that but it boohu -v still outputs v0.3. I'm not familiar with go-lang, so maybe i'm doing something silly.

anaseto commented 6 years ago

Oh, probably the go get -u command did nothing because you already had the latest version. If that's the case, just remove the binary in $GOPATH/bin/boohu and try again (doing a touch on a file instead of removing the binary will do it too, I think).

erf commented 6 years ago

Thanks, that works!