File tree Expand file tree Collapse file tree 3 files changed +18
-16
lines changed Expand file tree Collapse file tree 3 files changed +18
-16
lines changed Original file line number Diff line number Diff line change
1
+ /main.go export-subst
Original file line number Diff line number Diff line change 1
1
BIN := yubikey-touch-detector
2
- VERSION := $(shell sed -nr 's/const appVersion\s * =\s * "(. * ) "/\1/p' main.go )
2
+ VERSION := $(shell git describe --tags )
3
3
4
4
PREFIX ?= /usr
5
5
LIB_DIR = $(DESTDIR )$(PREFIX ) /lib
@@ -35,25 +35,15 @@ clean:
35
35
rm -rf vendor
36
36
37
37
.PHONY : dist
38
- dist : clean vendor build
39
- $(eval TMP := $(shell mktemp -d) )
40
- mkdir " $( TMP) /$( BIN) -$( VERSION) "
41
- cp -r * " $( TMP) /$( BIN) -$( VERSION) "
42
- (cd " $( TMP) " && tar -cvzf " $( BIN) -$( VERSION) -src.tar.gz" " $( BIN) -$( VERSION) " )
43
-
44
- mkdir "$(TMP)/$(BIN)-$(VERSION)-linux64"
45
- cp "$(BIN)" "$(BIN).service" "$(BIN).socket" LICENSE README.md "$(TMP)/$(BIN)-$(VERSION)-linux64"
46
- (cd "$(TMP)" && tar -cvzf "$(BIN)-$(VERSION)-linux64.tar.gz" "$(BIN)-$(VERSION)-linux64")
47
-
38
+ dist : clean vendor
48
39
mkdir -p dist
49
- mv "$(TMP)/$(BIN)-$(VERSION)"-*.tar.gz dist
50
40
git archive -o " dist/$( BIN) -$( VERSION) .tar.gz" --format tar.gz --prefix " $( BIN) -$( VERSION) /" " $( VERSION) "
41
+ git archive -o " dist/$( BIN) -$( VERSION) -src.tar.gz" --format tar.gz $$(find vendor -type f -printf '--prefix=$(BIN ) -$(VERSION ) /%h/ --add-file=%p ' ) --prefix " $( BIN) -$( VERSION) /" " $( VERSION) "
51
42
52
43
for file in dist/*; do \
53
44
gpg --detach-sign --armor "$$file"; \
54
45
done
55
46
56
- rm -rf "$(TMP)"
57
47
rm -f "dist/$(BIN)-$(VERSION).tar.gz"
58
48
59
49
.PHONY : install
Original file line number Diff line number Diff line change 4
4
"flag"
5
5
"fmt"
6
6
"os"
7
+ "os/exec"
7
8
"os/signal"
8
9
"path"
9
10
"path/filepath"
@@ -18,8 +19,6 @@ import (
18
19
"github.com/maximbaz/yubikey-touch-detector/notifier"
19
20
)
20
21
21
- const appVersion = "1.12.3"
22
-
23
22
func main () {
24
23
truthyValues := map [string ]bool {"true" : true , "yes" : true , "1" : true }
25
24
@@ -42,7 +41,7 @@ func main() {
42
41
flag .Parse ()
43
42
44
43
if version {
45
- fmt .Println ("YubiKey touch detector version:" , appVersion )
44
+ fmt .Println ("YubiKey touch detector version:" , appVersion () )
46
45
os .Exit (0 )
47
46
}
48
47
@@ -152,3 +151,15 @@ func setupExitSignalWatch(exits *sync.Map) {
152
151
log .Debug ("Stopping YubiKey touch detector" )
153
152
os .Exit (0 )
154
153
}
154
+
155
+ func appVersion () string {
156
+ version := "$Format:%(describe)$"
157
+ if strings .HasPrefix (version , "$" ) {
158
+ out , err := exec .Command ("git" , "describe" , "--tags" ).Output ()
159
+ if err != nil {
160
+ panic (fmt .Sprintf ("Failed to determine version using 'git describe': %v" , err ))
161
+ }
162
+ version = strings .TrimSpace (string (out ))
163
+ }
164
+ return version
165
+ }
You can’t perform that action at this time.
0 commit comments