diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index 8340a95cd..cbd99f08e 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -70,6 +70,8 @@ jobs: runs-on: ubuntu-22.04 steps: - uses: actions/checkout@b4ffde65f46336ab88eb53be808477a3936bae11 # v4.1.1 + with: + fetch-tags: true - uses: actions/setup-go@0c52d547c9bc32b1aa3301fd7a9cb496313a4491 # v5.0.0 with: go-version-file: 'go.mod' diff --git a/.github/workflows/release-branch.yml b/.github/workflows/release-branch.yml index 33e8de40e..e2e2820cf 100644 --- a/.github/workflows/release-branch.yml +++ b/.github/workflows/release-branch.yml @@ -215,6 +215,7 @@ jobs: - name: Checkout Repository uses: actions/checkout@9bb56186c3b09b4f86b1c65136769dd318469633 # v4.1.2 with: + fetch-tags: true ref: ${{ inputs.releaseBranch }} - name: Setup go diff --git a/Makefile b/Makefile index 9df9dcca7..51d5cf785 100644 --- a/Makefile +++ b/Makefile @@ -48,7 +48,7 @@ MANIFEST_DIR ?= /var/lib/nginx-agent DIRS = $(BUILD_DIR) $(TEST_BUILD_DIR) $(BUILD_DIR)/$(DOCS_DIR) $(BUILD_DIR)/$(DOCS_DIR)/$(PROTO_DIR) $(shell mkdir -p $(DIRS)) -VERSION ?= "v3.0.0" +VERSION ?= $(shell git describe --tags --abbrev=0) COMMIT = $(shell git rev-parse --short HEAD) DATE = $(shell date +%F_%H-%M-%S) LDFLAGS = "-s -w -X main.version=$(VERSION) -X main.commit=$(COMMIT) -X main.date=$(DATE)"