From 6df373ae4c22dcf6d3a7c33aac4c4f41c1a14f25 Mon Sep 17 00:00:00 2001 From: Joseph Doherty Date: Thu, 28 May 2026 17:07:25 -0400 Subject: [PATCH] client/go: release docs and tag-go-module.ps1 helper --- clients/go/README.md | 32 ++++++++++++++++++++ scripts/tag-go-module.ps1 | 62 +++++++++++++++++++++++++++++++++++++++ 2 files changed, 94 insertions(+) create mode 100644 scripts/tag-go-module.ps1 diff --git a/clients/go/README.md b/clients/go/README.md index 069a331..07beb00 100644 --- a/clients/go/README.md +++ b/clients/go/README.md @@ -275,6 +275,38 @@ $env:MXGATEWAY_TEST_ITEM = 'Area001.Tag.Value' go run ./cmd/mxgw-go smoke -endpoint $env:MXGATEWAY_ENDPOINT -plaintext -api-key-env MXGATEWAY_API_KEY -item $env:MXGATEWAY_TEST_ITEM -json ``` +## Installing the Go client + +The module is resolved directly from the git repo — no package registry: + +````bash +go get gitea.dohertylan.com/dohertj2/mxaccessgw/clients/go@v0.1.0 +```` + +Then import: + +````go +import "gitea.dohertylan.com/dohertj2/mxaccessgw/clients/go/mxgateway" +```` + +If your build environment cannot reach `gitea.dohertylan.com` directly, +configure `GOPROXY` to point at an internal proxy that fronts the Gitea +repo, or use `GONOSUMCHECK` + `GOPRIVATE` to bypass the checksum database +for the internal module path. + +## Releasing a new version + +Go modules in monorepo subdirectories use prefixed tags. To tag a release +from this repo: + +````bash +pwsh scripts/tag-go-module.ps1 -Version v0.1.1 -Push +```` + +The script validates semver, refuses to tag with uncommitted tracked +changes, creates an annotated tag `clients/go/v0.1.1`, and (with `-Push`) +pushes it to origin. + ## Related Documentation - [Client Packaging](../../docs/ClientPackaging.md) diff --git a/scripts/tag-go-module.ps1 b/scripts/tag-go-module.ps1 new file mode 100644 index 0000000..13b1ccd --- /dev/null +++ b/scripts/tag-go-module.ps1 @@ -0,0 +1,62 @@ +#Requires -Version 7 + +<# +.SYNOPSIS + Tags a release of the Go MxAccessGateway client module. + +.DESCRIPTION + Go modules in monorepo subdirectories use prefixed tags + ("clients/go/v0.1.0") so `go get @v0.1.0` resolves correctly. + This script validates the version, creates the prefixed tag at HEAD, + and (optionally) pushes it. + +.PARAMETER Version + Semver tag without the prefix, e.g. "v0.1.0". + +.PARAMETER Push + When set, pushes the tag to origin after creation. + +.EXAMPLE + pwsh scripts/tag-go-module.ps1 -Version v0.1.0 + pwsh scripts/tag-go-module.ps1 -Version v0.1.1 -Push +#> + +[CmdletBinding()] +param( + [Parameter(Mandatory = $true)] + [string]$Version, + + [switch]$Push +) + +Set-StrictMode -Version Latest +$ErrorActionPreference = 'Stop' + +if ($Version -notmatch '^v\d+\.\d+\.\d+(-[A-Za-z0-9.-]+)?$') { + throw "Version '$Version' must match semver vX.Y.Z (optionally with -prerelease suffix)." +} + +$tag = "clients/go/$Version" +Write-Host "Creating Go-module tag: $tag" -ForegroundColor Cyan + +# Verify we're on a clean checkout — refuse to tag with uncommitted changes. +$status = (git status --porcelain) -join "`n" +if ($status -and -not ($status -match '^\?\?')) { + throw "Working tree has tracked changes. Commit or stash before tagging." +} + +# Verify the tag doesn't already exist. +$existing = git tag --list $tag +if ($existing) { + throw "Tag '$tag' already exists. Use a new version." +} + +git tag -a $tag -m "Go client release $Version" +Write-Host "Created tag: $tag" -ForegroundColor Green + +if ($Push) { + git push origin $tag + Write-Host "Pushed tag to origin." -ForegroundColor Green +} else { + Write-Host "Tag not pushed. To publish, run: git push origin $tag" -ForegroundColor Yellow +}