From 3b916fdf8f07ce4fcf6330062aac78970a5c9e24 Mon Sep 17 00:00:00 2001 From: Haroon Chaudhry Date: Sun, 15 Mar 2026 15:19:00 -0400 Subject: [PATCH 1/2] fix: ensure same version is reported by extension and MCP sever --- .github/workflows/nightly-release.yml | 10 +++++++--- .github/workflows/release.yml | 14 +++++++++++--- VERSION | 1 + build.sh | 8 ++++++-- devops-mcp-server/server.go | 3 +-- devops-mcp-server/version.txt | 1 - gemini-extension.json | 2 +- 7 files changed, 27 insertions(+), 12 deletions(-) create mode 100644 VERSION delete mode 100644 devops-mcp-server/version.txt diff --git a/.github/workflows/nightly-release.yml b/.github/workflows/nightly-release.yml index 7a09448..72e8a9d 100644 --- a/.github/workflows/nightly-release.yml +++ b/.github/workflows/nightly-release.yml @@ -78,14 +78,18 @@ jobs: run: | mkdir -p "${RELEASE_DIR}" + # Read base version from VERSION file at the root + BASE_VERSION=$(cat ../VERSION) + # Generate version suffix TIMESTAMP=$(date +'%Y%m%d-%H%M') SHORT_SHA=$(git rev-parse --short HEAD) - VERSION_SUFFIX="-${TIMESTAMP}-${SHORT_SHA}" + FULL_VERSION="${BASE_VERSION}-${TIMESTAMP}-${SHORT_SHA}" + echo "FULL_VERSION=${FULL_VERSION}" >> $GITHUB_ENV command_exp='.mcpServers."devops-mcp".command = "${extensionPath}${/}' command_exp="${command_exp}${BIN_FILE}\"" - command_exp="${command_exp} | .version += \"${VERSION_SUFFIX}\"" + command_exp="${command_exp} | .version = \"${FULL_VERSION}\"" jq "${command_exp}" < ../gemini-extension.json >"${RELEASE_DIR}/gemini-extension.json" cp ../README.md "${RELEASE_DIR}/" @@ -107,7 +111,7 @@ jobs: export GOARCH=${{ matrix.platform.goarch }} output_path="${RELEASE_DIR}/${{ matrix.platform.bin_file }}" - go build -o "${output_path}" + go build -ldflags "-X main.version=${{ env.FULL_VERSION }}" -o "${output_path}" - name: Create release assets id: archive diff --git a/.github/workflows/release.yml b/.github/workflows/release.yml index 07fbbad..e48843d 100644 --- a/.github/workflows/release.yml +++ b/.github/workflows/release.yml @@ -79,8 +79,16 @@ jobs: run: | mkdir -p "${RELEASE_DIR}" - # Extract version from tag (v1.2.3 -> 1.2.3) - VERSION="${TAG_NAME#v}" + # Prioritize TAG based versioning if it matches v[0-9].[0-9].[0-9] + if [[ "${TAG_NAME}" =~ ^v[0-9]+\.[0-9]+\.[0-9]+$ ]]; then + VERSION="${TAG_NAME#v}" + echo "Using version from tag: ${VERSION}" + else + VERSION=$(cat ../VERSION) + echo "Using version from VERSION file: ${VERSION}" + fi + + echo "VERSION=${VERSION}" >> $GITHUB_ENV command_exp='.mcpServers."devops-mcp".command = "${extensionPath}${/}' command_exp="${command_exp}${BIN_FILE}\"" @@ -107,7 +115,7 @@ jobs: export GOARCH=${{ matrix.platform.goarch }} output_path="${RELEASE_DIR}/${{ matrix.platform.bin_file }}" - go build -o "${output_path}" + go build -ldflags "-X main.version=${{ env.VERSION }}" -o "${output_path}" - name: Create release assets id: archive diff --git a/VERSION b/VERSION new file mode 100644 index 0000000..17e51c3 --- /dev/null +++ b/VERSION @@ -0,0 +1 @@ +0.1.1 diff --git a/build.sh b/build.sh index 313264f..b5c141c 100755 --- a/build.sh +++ b/build.sh @@ -66,11 +66,15 @@ build_mcp() { err "Error: MCP serverdirectory '${MCP_SERVER_DIR}' not found." return 1 fi + + # Read version from root VERSION file + VERSION=$(cat VERSION) + ( cd ${MCP_SERVER_DIR} go mod tidy - go build -o "../${BINARY_NAME}" - echo "Successfully built '${BINARY_NAME}' Please move it to `.gemini/extensions/devops/bin/devops-mcp-server`" + go build -ldflags "-X main.version=${VERSION}" -o "../${BINARY_NAME}" + echo "Successfully built '${BINARY_NAME}' version ${VERSION}. Please move it to `.gemini/extensions/devops/bin/devops-mcp-server`" ) } diff --git a/devops-mcp-server/server.go b/devops-mcp-server/server.go index 5da2399..cccb764 100644 --- a/devops-mcp-server/server.go +++ b/devops-mcp-server/server.go @@ -46,8 +46,7 @@ import ( "github.com/modelcontextprotocol/go-sdk/mcp" ) -//go:embed version.txt -var version string +var version = "0.1.0-dev" func createServer() *mcp.Server { opts := &mcp.ServerOptions{ diff --git a/devops-mcp-server/version.txt b/devops-mcp-server/version.txt deleted file mode 100644 index 6da28dd..0000000 --- a/devops-mcp-server/version.txt +++ /dev/null @@ -1 +0,0 @@ -0.1.1 \ No newline at end of file diff --git a/gemini-extension.json b/gemini-extension.json index cd26031..86af6d2 100644 --- a/gemini-extension.json +++ b/gemini-extension.json @@ -1,6 +1,6 @@ { "name": "devops", - "version": "0.1.1", + "version": "0.1.0-dev", "description": "The DevOps extension provides Gemini powered AI assisted CI/CD. It supports deployment to Cloud Run and Cloud Storage as well as creation of a robust CI/CD pipeline.", "mcpServers": { "devops-mcp": { From 44e0f01160c8b343b7ab56596aca6746b6c2ddde Mon Sep 17 00:00:00 2001 From: Haroon Chaudhry Date: Sun, 15 Mar 2026 15:33:41 -0400 Subject: [PATCH 2/2] trim white spaces and error on empty version Co-authored-by: gemini-code-assist[bot] <176961590+gemini-code-assist[bot]@users.noreply.github.com> --- build.sh | 9 ++++++--- 1 file changed, 6 insertions(+), 3 deletions(-) diff --git a/build.sh b/build.sh index b5c141c..addedb2 100755 --- a/build.sh +++ b/build.sh @@ -67,9 +67,12 @@ build_mcp() { return 1 fi - # Read version from root VERSION file - VERSION=$(cat VERSION) - + # Read version from root VERSION file and validate it + VERSION=$(cat VERSION | xargs) + if [[ -z "${VERSION}" ]]; then + err "Error: VERSION file is empty or contains only whitespace." + return 1 + fi ( cd ${MCP_SERVER_DIR} go mod tidy