mirror of
https://github.com/kovetskiy/mark.git
synced 2025-06-16 04:32:40 +08:00
Get version from ldflags
This commit is contained in:
parent
8c061c49d4
commit
733b3222b3
4
Makefile
4
Makefile
@ -1,7 +1,7 @@
|
|||||||
NAME = $(notdir $(PWD))
|
NAME = $(notdir $(PWD))
|
||||||
|
|
||||||
VERSION = $(shell git describe --tags --abbrev=0)
|
VERSION = $(shell git describe --tags --abbrev=0)
|
||||||
|
COMMIT = $(shell git rev-parse HEAD)
|
||||||
GO111MODULE = on
|
GO111MODULE = on
|
||||||
|
|
||||||
REMOTE = kovetskiy
|
REMOTE = kovetskiy
|
||||||
@ -15,7 +15,7 @@ get:
|
|||||||
build:
|
build:
|
||||||
@echo :: building go binary $(VERSION)
|
@echo :: building go binary $(VERSION)
|
||||||
CGO_ENABLED=0 go build \
|
CGO_ENABLED=0 go build \
|
||||||
-ldflags "-X main.version=$(VERSION)" \
|
-ldflags "-X main.version=$(VERSION) -X main.commit=$(COMMIT)" \
|
||||||
-gcflags "-trimpath $(GOPATH)/src"
|
-gcflags "-trimpath $(GOPATH)/src"
|
||||||
|
|
||||||
test:
|
test:
|
||||||
|
10
main.go
10
main.go
@ -2,6 +2,7 @@ package main
|
|||||||
|
|
||||||
import (
|
import (
|
||||||
"context"
|
"context"
|
||||||
|
"fmt"
|
||||||
"os"
|
"os"
|
||||||
|
|
||||||
"github.com/kovetskiy/mark/util"
|
"github.com/kovetskiy/mark/util"
|
||||||
@ -9,8 +10,13 @@ import (
|
|||||||
"github.com/urfave/cli/v3"
|
"github.com/urfave/cli/v3"
|
||||||
)
|
)
|
||||||
|
|
||||||
|
|
||||||
|
var (
|
||||||
|
version = "dev"
|
||||||
|
commit = "none"
|
||||||
|
)
|
||||||
|
|
||||||
const (
|
const (
|
||||||
version = "14.0.2"
|
|
||||||
usage = "A tool for updating Atlassian Confluence pages from markdown."
|
usage = "A tool for updating Atlassian Confluence pages from markdown."
|
||||||
description = `Mark is a tool to update Atlassian Confluence pages from markdown. Documentation is available here: https://github.com/kovetskiy/mark`
|
description = `Mark is a tool to update Atlassian Confluence pages from markdown. Documentation is available here: https://github.com/kovetskiy/mark`
|
||||||
)
|
)
|
||||||
@ -20,7 +26,7 @@ func main() {
|
|||||||
Name: "mark",
|
Name: "mark",
|
||||||
Usage: usage,
|
Usage: usage,
|
||||||
Description: description,
|
Description: description,
|
||||||
Version: version,
|
Version: fmt.Sprintf("%s@%s", version, commit),
|
||||||
Flags: util.Flags,
|
Flags: util.Flags,
|
||||||
EnableShellCompletion: true,
|
EnableShellCompletion: true,
|
||||||
HideHelpCommand: true,
|
HideHelpCommand: true,
|
||||||
|
Loading…
x
Reference in New Issue
Block a user