This isn't possible if you want to truly assume nothing about the build process, as that means you can't assume that the build process makes any record of anything back into your version control system (e.g. you could have a deploy process that simply issues a git pull on a box somewhere).
If you make an assumption that your build process is building from a given branch (e.g. master), and tagging the branch every time it makes a build, then git describe master will tell you the latest tag in the master branch.
In this case, this may only tell you about the latest build, not the latest deployment. In this sense the tags are release candidates, and you'd have to make more assumptions in order to find the latest deployment.
We use the following strategy:
M─┐ [v2] [release] Merge branch 'feature-Y' into release
│ o [feature-Y] Commit F
│ o Commit E
│ o Commit D
M─┤ [v1] [master] Merge branch 'feature-X' into release
│ o [feature-X] Commit C
│ o Commit B
│ o Commit A
I─┘ Initial commit
This tells you a few things:
- We only maintain one version of this application.
- masterpoints at the current production version. (So- v1is currently live.)
- Commits are made in feature branches and merged into releasewhen ready.
- Here, the new feature-Yis our release candidate, which has been build and tagged asv2by our build process.
- This is deployed to a pre-production environment for testing.
- Once testing is complete, the build is promoted to live.
- Once everyone is happy that it's working in live, masteris fast-forwarded torelease(git push origin release:master) and nowv2is live.
- Repeat!
If at any point the release candidate fails testing, the release branch is thrown away and rewound back to master (git push -f origin master:release), so feature-Y is no longer part of the mainline. However, v2 still exists in git for posterity.