Enable detect version by git tags (#63)

This commit is contained in:
Hongcai Ren 2020-12-08 10:06:32 +08:00 committed by GitHub
parent e7d751bbc8
commit e9d590264b
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 18 additions and 5 deletions

View File

@ -39,6 +39,10 @@ jobs:
steps:
- name: checkout code
uses: actions/checkout@v2
with:
# Number of commits to fetch. 0 indicates all history for all branches and tags.
# We need to guess version via git tags.
fetch-depth: 0
- name: install Go
uses: actions/setup-go@v2
with:

View File

@ -12,11 +12,20 @@ REGISTRY_USER_NAME?=""
REGISTRY_PASSWORD?=""
REGISTRY_SERVER_ADDRESS?=""
# Set you version by env or using latest tags from git
VERSION?=$(shell git describe --tags)
# We don't have tags yet, so just use hardcode one
VERSION="latest"
# Set your version by env or using latest tags from git
VERSION?=""
ifeq ($(VERSION), "")
$(info "Guessing version from git latest tags...")
LATEST_TAG=$(shell git describe --tags)
ifeq ($(LATEST_TAG),)
# Forked repo may not sync tags from upstream, so give it a default tag to make CI happy.
$(info "no tags found, set version with unknown")
VERSION="unknown"
else
$(info "using latest git tag($(LATEST_TAG)) as version")
VERSION=$(LATEST_TAG)
endif
endif
all: karmada-controller-manager karmadactl