diff --git a/Makefile b/Makefile new file mode 100644 index 0000000..793cb6e --- /dev/null +++ b/Makefile @@ -0,0 +1,12 @@ +.PHONY: build install test + +version=$(shell ./version.sh) + +build: + go build -ldflags "-X main.version=${version}" ./cmd/gofs + +install: + go install -ldflags "-X main.version=${version}" ./cmd/gofs + +test: + go test ./... diff --git a/cmd/gofs/main.go b/cmd/gofs/main.go index 733c1cd..c489b49 100644 --- a/cmd/gofs/main.go +++ b/cmd/gofs/main.go @@ -15,18 +15,23 @@ import ( "time" "github.com/alecthomas/units" - - cid "github.com/ipfs/go-cid" - - "github.com/gochain-io/gofs" - "github.com/gochain-io/gochain/v3/common" "github.com/gochain-io/gochain/v3/core/types" "github.com/gochain-io/gochain/v3/crypto" + "github.com/gochain-io/gofs" "github.com/gochain-io/web3" + cid "github.com/ipfs/go-cid" "github.com/urfave/cli" ) +var version string + +func init() { + if version == "" { + version = "unknown" + } +} + func main() { // Interrupt cancellation. ctx, cancelFn := context.WithCancel(context.Background()) @@ -41,7 +46,7 @@ func main() { app := cli.NewApp() app.Name = "gofs" - app.Version = "0.0.1" + app.Version = version app.Usage = "GoChain filesystem cli tool" var api, rpc, contract string //TODO var recursive bool diff --git a/tag.sh b/tag.sh new file mode 100755 index 0000000..7206490 --- /dev/null +++ b/tag.sh @@ -0,0 +1,2 @@ +#!/bin/bash +git tag -f -a "v$1" -m "version $1" diff --git a/version.sh b/version.sh new file mode 100755 index 0000000..a59629c --- /dev/null +++ b/version.sh @@ -0,0 +1,2 @@ +#!/bin/bash +git describe --always --dirty