Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

VERSION string not correctly set-up #1380

Closed
rabser opened this issue Jun 20, 2023 · 4 comments
Closed

VERSION string not correctly set-up #1380

rabser opened this issue Jun 20, 2023 · 4 comments
Labels
bug Something isn't working

Comments

@rabser
Copy link

rabser commented Jun 20, 2023

Version:

  • listmonk: v2.4.0
  • OS: any

Description of the bug and steps to reproduce:
Building listmonk from a git clone, sets the VERSION string to the latest commit, even if the build is done from a checkout on another tag. Building listmonk from the source tar.gz (or zip) the VERSION string is set to 0.0.0.

Screenshots:
this is the result of a build starting from the tar.gz
[root@myhost Build]# ./listmonk --version
v0.0.0 (#c668523c 2023-06-20T12:48:35+0000)

I believe that line #5 in Makefile it's wrong (almost for the tar.gz) and should be as such:

VERSION := ( o r (shell git describe --tags --abbrev=0 2> /dev/null),$(shell grep -oP "tag: \K(.*)" VERSION),"v0.0.0")

where the bold part it's the relevant part.
For the build from git clone I was not able to find a pretty solution to substitute the git describe.

@rabser rabser added the bug Something isn't working label Jun 20, 2023
@knadh
Copy link
Owner

knadh commented Jun 23, 2023

Building listmonk from a git clone, sets the VERSION string to the latest commit

This isn't right. If it's a git repository, make will use the git describe command to get the tag. Below is the output from a git clone'd copy of listmonk. The VERSION file here is immaterial.

make dist
CGO_ENABLED=0 go build -o listmonk -ldflags="-s -w -X 'main.buildString=v2.4.0 (#530165f 2023-06-23T09:45:50+0000)' -X 'main.versionString=v2.4.0'" cmd/*.go

Building listmonk from the source tar.gz (or zip) the VERSION string is set to 0.0.0.

Unfortunately, there is no way to get the latest tag of out of a git archive (which is what powers the GitHub archive download). Whatever is in the generated VERSION file is described in .gitattributes.

@rabser
Copy link
Author

rabser commented Jun 23, 2023

Thanks for your kind reply.
For the first problem, you're right, sorry, I don't know why, but in some of my tests, the git describe didn´t return the current tag, but the v2.4.0 ... I don't know, but surely was my mistake.

For the second problem, what I see it's that the VERSION file in the root folder is actualized with the right values, so the Makefile should be able to get the right numbers, IMHO the grep should be changed as I suggested:

"tag: \K(.)(?=,)" should be "tag: \K(.)"

and the versioning will be correctly composed. With the (?=,) the grep return an empty string (no match), and without it returns the v2.X.Y as expected: I'm wrong on this?

@knadh
Copy link
Owner

knadh commented Jun 24, 2023

For the second problem, what I see it's that the VERSION file in the root folder is actualized with the right values

Are you see the same values in the downloaded archive? It has the last commit, but not the version tag. I did some digging and looks like it's not possible to export tags during archival.

$ cat VERSION 
530165f5
HEAD -> master

@knadh knadh added needs-investigation Potential bug. Needs investigation and removed bug Something isn't working labels Jun 24, 2023
@rabser
Copy link
Author

rabser commented Jun 26, 2023

This is the cat VERSION from the source tar.gz taken from the "Releases" link:

$cat VERSION
c668523c
tag: v2.4.0

the same happens with older ones, using the same url schema and changing the release number that you want to build.

@knadh knadh closed this as completed in 5af6252 Sep 19, 2023
@knadh knadh added bug Something isn't working and removed needs-investigation Potential bug. Needs investigation labels Sep 19, 2023
yash-git-dev pushed a commit to yash-git-dev/listmonk that referenced this issue Oct 6, 2023
ai-armageddon pushed a commit to Twitter-outreach/ListMonk that referenced this issue Mar 11, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

No branches or pull requests

2 participants