From 8a3c2fc53f4fb3e98fda309437840a0eb553b73d Mon Sep 17 00:00:00 2001 From: GuruOrGoru Date: Fri, 10 Oct 2025 13:35:52 +0545 Subject: [PATCH 1/2] fix: ensure piped plugins display correct version information Add version ldflags to plugin build process to inject version, git commit, and build date information during compilation. This fixes the issue where plugin binaries showed 'unspecified' for all version fields. The build/plugin target now includes the same version ldflags as the build/go target, ensuring consistency across all PipeCD binaries. Fixes #6305 Signed-off-by: GuruOrGoru --- Makefile | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/Makefile b/Makefile index db038e413e..9712e2fbb5 100644 --- a/Makefile +++ b/Makefile @@ -59,11 +59,15 @@ else endif .PHONY: build/plugin +build/plugin: BUILD_VERSION ?= $(shell git describe --tags --always --dirty --abbrev=7 --match 'v[0-9]*.*') +build/plugin: BUILD_COMMIT ?= $(shell git rev-parse HEAD) +build/plugin: BUILD_DATE ?= $(shell date -u '+%Y%m%d-%H%M%S') +build/plugin: BUILD_LDFLAGS_PREFIX := -X github.com/pipe-cd/pipecd/pkg/version build/plugin: PLUGINS_BIN_DIR ?= ~/.piped/plugins build/plugin: PLUGINS_SRC_DIR ?= ./pkg/app/pipedv1/plugin build/plugin: PLUGINS_OUT_DIR ?= ${PWD}/.artifacts/plugins build/plugin: PLUGINS ?= $(shell find $(PLUGINS_SRC_DIR) -mindepth 1 -maxdepth 1 -type d | while read -r dir; do basename "$$dir"; done | paste -sd, -) # comma separated list of plugins. eg: PLUGINS=kubernetes,ecs,lambda -build/plugin: BUILD_OPTS ?= -ldflags "-s -w" -trimpath +build/plugin: BUILD_OPTS ?= -ldflags "$(BUILD_LDFLAGS_PREFIX).version=$(BUILD_VERSION) $(BUILD_LDFLAGS_PREFIX).gitCommit=$(BUILD_COMMIT) $(BUILD_LDFLAGS_PREFIX).buildDate=$(BUILD_DATE) -s -w" -trimpath build/plugin: BUILD_OS ?= $(shell go version | cut -d ' ' -f4 | cut -d/ -f1) build/plugin: BUILD_ARCH ?= $(shell go version | cut -d ' ' -f4 | cut -d/ -f2) build/plugin: BUILD_ENV ?= GOOS=$(BUILD_OS) GOARCH=$(BUILD_ARCH) CGO_ENABLED=0 From 5c8b68c536c2c2ca6326e2396c62c25688ff0ebd Mon Sep 17 00:00:00 2001 From: GuruOrGoru Date: Fri, 10 Oct 2025 14:10:53 +0545 Subject: [PATCH 2/2] fix: ensure plugin version info is injected in workflow builds Update the plugin_release workflow to pass BUILD_VERSION, BUILD_COMMIT, and BUILD_DATE to the make build/plugin command for all platforms. This ensures that plugins built in CI also display correct version information instead of 'unspecified'. The Makefile already supports overriding these variables with ?= syntax, so both local and CI builds now work consistently. Signed-off-by: GuruOrGoru --- .github/workflows/plugin_release.yaml | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/.github/workflows/plugin_release.yaml b/.github/workflows/plugin_release.yaml index 81dc47d356..522b7030d8 100644 --- a/.github/workflows/plugin_release.yaml +++ b/.github/workflows/plugin_release.yaml @@ -31,10 +31,10 @@ jobs: run: echo "PLUGIN_NAME=$(basename ${{ inputs.path }})" >> $GITHUB_ENV - name: Build binary artifacts run: | - make build/plugin PLUGINS=$PLUGIN_NAME BUILD_OS=linux BUILD_ARCH=amd64 BIN_SUFFIX=_${{ inputs.version }}_linux_amd64 - make build/plugin PLUGINS=$PLUGIN_NAME BUILD_OS=linux BUILD_ARCH=arm64 BIN_SUFFIX=_${{ inputs.version }}_linux_arm64 - make build/plugin PLUGINS=$PLUGIN_NAME BUILD_OS=darwin BUILD_ARCH=amd64 BIN_SUFFIX=_${{ inputs.version }}_darwin_amd64 - make build/plugin PLUGINS=$PLUGIN_NAME BUILD_OS=darwin BUILD_ARCH=arm64 BIN_SUFFIX=_${{ inputs.version }}_darwin_arm64 + make build/plugin PLUGINS=$PLUGIN_NAME BUILD_OS=linux BUILD_ARCH=amd64 BIN_SUFFIX=_${{ inputs.version }}_linux_amd64 BUILD_VERSION=${{ inputs.version }} BUILD_COMMIT=${{ github.sha }} BUILD_DATE=$(date -u +%Y%m%d-%H%M%S) + make build/plugin PLUGINS=$PLUGIN_NAME BUILD_OS=linux BUILD_ARCH=arm64 BIN_SUFFIX=_${{ inputs.version }}_linux_arm64 BUILD_VERSION=${{ inputs.version }} BUILD_COMMIT=${{ github.sha }} BUILD_DATE=$(date -u +%Y%m%d-%H%M%S) + make build/plugin PLUGINS=$PLUGIN_NAME BUILD_OS=darwin BUILD_ARCH=amd64 BIN_SUFFIX=_${{ inputs.version }}_darwin_amd64 BUILD_VERSION=${{ inputs.version }} BUILD_COMMIT=${{ github.sha }} BUILD_DATE=$(date -u +%Y%m%d-%H%M%S) + make build/plugin PLUGINS=$PLUGIN_NAME BUILD_OS=darwin BUILD_ARCH=arm64 BIN_SUFFIX=_${{ inputs.version }}_darwin_arm64 BUILD_VERSION=${{ inputs.version }} BUILD_COMMIT=${{ github.sha }} BUILD_DATE=$(date -u +%Y%m%d-%H%M%S) - env: INPUT_VERSION: ${{ inputs.version }} INPUT_PATH: ${{ inputs.path }}