guumaster / hostctl

Your dev tool to manage /etc/hosts like a pro!
http://guumaster.github.io/hostctl
MIT License
1.05k stars 45 forks source link

Version flag #42

Closed smhmd closed 4 years ago

smhmd commented 4 years ago
$ hostctl -v || hostctl --version
hostctl 0.10.0

or add it to the output of the help command?

guumaster commented 4 years ago

implemented on v0.10.2. :+1:

UPDATE: there is a bug on Arch linux builds that is not using $VERSION to build and always report version dev.

smhmd commented 4 years ago

@guumaster

$ hostctl -v
hostctl version dev

dev as a version is not helpful, because it'll be dev all the time, it seems. (this was true of 0.10.1 and is true now of 0.10.2.)

guumaster commented 4 years ago

It should be filled by the build workflow, that's a bug. I'll check it.

UPDATE: @smhmd How did you get dev as version? I've just downloaded the binary for v0.10.2 and reports the version just fine. Are you building from source?

smhmd commented 4 years ago

@guumaster Yes, I'm using the AUR: yay -S hostctl. If you wanna supply a hostctl-bin package, too, I would use it. Less carbon footprint.

guumaster commented 4 years ago

@BarbUk do you know how to pass -ldflags parameter to PKGBUILD so the build script add the proper version to the binary?

BarbUk commented 4 years ago

the pkgbuild is already building with -ldflags:

build() {
  cd $pkgname-$pkgver
  go build \
    -trimpath \
    -ldflags "-extldflags $LDFLAGS" \
    -o $pkgname .
}

How do you pass the version to go build ?

BarbUk commented 4 years ago
-X github.com/guumaster/hostctl/cmd.version=$pkgver

Made the change in the pkgbuild.

❯ hostctl -v
hostctl version 1.0.2
smhmd commented 4 years ago

hostctl -v still outputs hostctl version dev on my end (installed through the AUR).

highlighted line illustrates that I have a feature only available on 1.0.8 https://github.com/guumaster/hostctl/releases/tag/v1.0.8

image

BarbUk commented 4 years ago

Ldflags need to be updated following 007b4154c19923e1c59a53ca8d6e2ad4d471de62.

The update is available in https://aur.archlinux.org/cgit/aur.git/commit/?h=hostctl&id=42f1eed07bba06554ffb4f73a3ea9871771ba920

I did not update pkgrel to not break the package release automation.

@smhmd, you can reinstall the package or wait for the next release.

BarbUk commented 4 years ago

@guumaster, your new commit break the version passed via ldflags.

guumaster commented 4 years ago

I fixed the goreleaser yml and also just updated the PKGBUILD file, can you confirm it works on Arch?

BarbUk commented 4 years ago

yes:

$ hostctl -v
hostctl version 1.0.9