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..addedb2 100755 --- a/build.sh +++ b/build.sh @@ -66,11 +66,18 @@ build_mcp() { err "Error: MCP serverdirectory '${MCP_SERVER_DIR}' not found." return 1 fi + + # 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 - 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": {