mirror of https://github.com/knative/func.git
enable build from tag
This commit is contained in:
parent
b7a738b8d5
commit
cb0a74714c
|
@ -8,7 +8,6 @@ on:
|
||||||
|
|
||||||
jobs:
|
jobs:
|
||||||
build:
|
build:
|
||||||
name: Release
|
|
||||||
runs-on: ubuntu-latest
|
runs-on: ubuntu-latest
|
||||||
steps:
|
steps:
|
||||||
- uses: actions/checkout@v2
|
- uses: actions/checkout@v2
|
||||||
|
|
11
Makefile
11
Makefile
|
@ -4,7 +4,6 @@ BIN := faas
|
||||||
CODE := $(shell find . -name '*.go')
|
CODE := $(shell find . -name '*.go')
|
||||||
DATE := $(shell date -u +"%Y%m%dT%H%M%SZ")
|
DATE := $(shell date -u +"%Y%m%dT%H%M%SZ")
|
||||||
HASH := $(shell git rev-parse --short HEAD 2>/dev/null)
|
HASH := $(shell git rev-parse --short HEAD 2>/dev/null)
|
||||||
BRCH := $(shell git symbolic-ref --short -q HEAD | sed 's/\//-/g')
|
|
||||||
VTAG := $(shell git tag --points-at HEAD)
|
VTAG := $(shell git tag --points-at HEAD)
|
||||||
VERS := $(shell [ -z $(VTAG) ] && echo 'tip' || echo $(VTAG) )
|
VERS := $(shell [ -z $(VTAG) ] && echo 'tip' || echo $(VTAG) )
|
||||||
|
|
||||||
|
@ -12,22 +11,20 @@ all: $(BIN)
|
||||||
build: all
|
build: all
|
||||||
|
|
||||||
$(BIN): $(CODE)
|
$(BIN): $(CODE)
|
||||||
go build -ldflags "-X main.brch=$(BRCH) -X main.date=$(DATE) -X main.vers=$(VERS) -X main.hash=$(HASH)" ./cmd/$(BIN)
|
go build -ldflags "-X main.date=$(DATE) -X main.vers=$(VERS) -X main.hash=$(HASH)" ./cmd/$(BIN)
|
||||||
|
|
||||||
test:
|
test:
|
||||||
go test -cover -coverprofile=coverage.out ./...
|
go test -cover -coverprofile=coverage.out ./...
|
||||||
|
|
||||||
image: Dockerfile
|
image: Dockerfile
|
||||||
docker build -t $(REPO):$(BRCH) \
|
docker build -t $(REPO):$(VERS) \
|
||||||
-t $(REPO):$(VERS) \
|
|
||||||
-t $(REPO):$(HASH) \
|
-t $(REPO):$(HASH) \
|
||||||
-t $(REPO):$(BRCH)-$(DATE)-$(VERS)-$(HASH) .
|
-t $(REPO):$(DATE)-$(VERS)-$(HASH) .
|
||||||
|
|
||||||
push: image
|
push: image
|
||||||
docker push $(REPO):$(BRCH)
|
|
||||||
docker push $(REPO):$(VERS)
|
docker push $(REPO):$(VERS)
|
||||||
docker push $(REPO):$(HASH)
|
docker push $(REPO):$(HASH)
|
||||||
docker push $(REPO):$(BRCH)-$(DATE)-$(VERS)-$(HASH)
|
docker push $(REPO):$(DATE)-$(VERS)-$(HASH)
|
||||||
|
|
||||||
clean:
|
clean:
|
||||||
-@rm -f $(BIN)
|
-@rm -f $(BIN)
|
||||||
|
|
|
@ -6,9 +6,9 @@ import (
|
||||||
|
|
||||||
// Statically-populated build metadata set
|
// Statically-populated build metadata set
|
||||||
// by `make build`.
|
// by `make build`.
|
||||||
var brch, date, vers, hash string
|
var date, vers, hash string
|
||||||
|
|
||||||
func main() {
|
func main() {
|
||||||
cmd.SetMeta(brch, date, vers, hash)
|
cmd.SetMeta(date, vers, hash)
|
||||||
cmd.Execute()
|
cmd.Execute()
|
||||||
}
|
}
|
||||||
|
|
|
@ -23,15 +23,13 @@ func version(cmd *cobra.Command, args []string) {
|
||||||
// Populated at build time by `make build`, plumbed through
|
// Populated at build time by `make build`, plumbed through
|
||||||
// main using SetMeta()
|
// main using SetMeta()
|
||||||
var (
|
var (
|
||||||
brch string // the branch built from
|
|
||||||
date string // datestamp
|
date string // datestamp
|
||||||
vers string // verstionof git commit or `tip`
|
vers string // verstionof git commit or `tip`
|
||||||
hash string // git hash built from
|
hash string // git hash built from
|
||||||
)
|
)
|
||||||
|
|
||||||
// SetMeta from the build process, used for verbose version tagging.
|
// SetMeta from the build process, used for verbose version tagging.
|
||||||
func SetMeta(buildBranch, buildTimestamp, commitVersionTag, commitHash string) {
|
func SetMeta(buildTimestamp, commitVersionTag, commitHash string) {
|
||||||
brch = buildBranch
|
|
||||||
date = buildTimestamp
|
date = buildTimestamp
|
||||||
vers = commitVersionTag
|
vers = commitVersionTag
|
||||||
hash = commitHash
|
hash = commitHash
|
||||||
|
@ -44,5 +42,5 @@ func verboseVersion() string {
|
||||||
if vers == "" { // not statically populatd
|
if vers == "" { // not statically populatd
|
||||||
return "v0.0.0-source"
|
return "v0.0.0-source"
|
||||||
}
|
}
|
||||||
return fmt.Sprintf("%s-%s-%s-%s", brch, date, vers, hash)
|
return fmt.Sprintf("%s-%s-%s", date, vers, hash)
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue