Hacker News new | ask | show | jobs
by grumbel 1487 days ago
Sometimes people don't use git to get the source. The "Download ZIP" function on Github for example includes no version number at all as far as I can tell, only the branch name in the filename.

For GitLab there there exist a workaround by using .gitattributes to create a VERSION file with "$Format:%(describe:tags)$" which will get expanded to the git describe string on archive creation, so the version number even survives in a .zip. GitHub however ignores .gitattributes and so far I haven't seen another way to get a version number into the .zip other than just including it in the source.

2 comments

Not related to your broader point, but you can download source from a release via https://github.com/<org>/<repo>/archive/refs/tags/<tag>.zip
This works too: https://github.com/<org>/<repo>/archive/HEAD.zip

Gives a HEAD.zip that contains a "<repo>-<sha1>/" folder and the latest source.

I'm fine with this sacrifice -- if someone downloads HEAD, they are not running a "version", so it would be misleading to have the source think it's at 1.0 or 1.1 if really it's at a commit between those two versions. I have my build scripts call the version "develop" or similar if this is the case.