Skip to content

Agent Mesh

release: npm dist-tag for prereleases and a manual SDK publish

Antonio Ojea33fc48824cdc
diff --git a/.github/workflows/release.yml b/.github/workflows/release.yml
index 42707613..165d9c47 100644
--- a/.github/workflows/release.yml
+++ b/.github/workflows/release.yml
@@ -5,12 +5,21 @@ on:
# run only against release tags
tags:
- "v*"
+ # Publish the SDKs of a tag whose release already exists (a failed
+ # publish-sdks run). goreleaser does not run again.
+ workflow_dispatch:
+ inputs:
+ tag:
+ description: "Existing release tag, e.g. v0.1.0-rc.4"
+ required: true
+ type: string
permissions:
contents: read
jobs:
goreleaser:
+ if: github.event_name == 'push'
runs-on: ubuntu-latest
permissions:
contents: write
@@ -39,15 +48,17 @@ jobs:
publish-sdks:
runs-on: ubuntu-latest
needs: goreleaser
+ if: always() && (github.event_name == 'workflow_dispatch' || needs.goreleaser.result == 'success')
permissions:
contents: read
id-token: write
env:
- SDK_VERSION: ${{ github.ref_name }}
+ SDK_VERSION: ${{ inputs.tag || github.ref_name }}
steps:
- name: Checkout
uses: actions/checkout@3d3c42e5aac5ba805825da76410c181273ba90b1 # v7.0.1
with:
+ ref: ${{ inputs.tag || github.ref }}
persist-credentials: false
- uses: actions/setup-node@2028fbc5c25fe9cf00d9f06a71cc4710d4507903 # v6.0.0
with:
@@ -62,12 +73,18 @@ jobs:
run: ./hack/sdk-version.sh "${SDK_VERSION#v}"
- name: Build and publish @sam-mesh/sdk
# npm's trusted publishing needs npm 11.5 or later; Node 22 ships 10.
+ # npm 11 refuses to publish a prerelease without an explicit dist-tag,
+ # and "latest" must stay on stable versions.
working-directory: sdk/js
run: |
npm install -g npm@latest
npm ci
npm run build
- npm publish --provenance --access public
+ case "${SDK_VERSION#v}" in
+ *-*) tag=next ;;
+ *) tag=latest ;;
+ esac
+ npm publish --provenance --access public --tag "$tag"
- name: Build sam-mesh
working-directory: sdk/python
run: |
diff --git a/sdk/README.md b/sdk/README.md
index 98791462..8125c136 100644
--- a/sdk/README.md
+++ b/sdk/README.md
@@ -410,9 +410,12 @@ holds against the control plane's records.
- Publishing: `.github/workflows/release.yml` stamps the release tag's
version on both packages (`hack/sdk-version.sh`) and publishes
`@sam-mesh/sdk` to npm and `sam-mesh` to PyPI through trusted
- publishing. The job runs only when the repository variable
- `PUBLISH_SDKS` is `true`, so a release before the registries are set up
- stays green. One-time setup by a package owner: on npmjs.com, create the
+ publishing. A prerelease tag (`v0.1.0-rc.4`) publishes under the npm
+ dist-tag `next`, a stable tag under `latest`; PyPI needs no tag, `pip`
+ skips prereleases on its own. When `publish-sdks` fails after the
+ GitHub release exists, run the workflow by hand from the Actions tab
+ with the tag as input; it checks out that tag and publishes only the
+ SDKs. One-time setup by a package owner: on npmjs.com, create the
`sam-mesh` organization, publish `@sam-mesh/sdk` 0.1.0 once by hand
(`cd sdk/js && npm publish --access public`; the trusted-publisher
settings live on the package page, which exists only after that), then
@@ -420,8 +423,7 @@ holds against the control plane's records.
Settings, Trusted publishing; on pypi.org, add a pending publisher for
project `sam-mesh` with the same repository and workflow (environment
left empty), which reserves the name and lets the first tag create the
- project. Then set `PUBLISH_SDKS`. No publishing token is stored in the
- repository.
+ project. No publishing token is stored in the repository.
- Docs: `site/content/docs/guides/native-sdks.md`.
- Tests. Unit: a fake control plane rotates its key and bans a peer; each
SDK learns both from a pull, refreshes under the new key and only under
diff --git a/sdk/js/package.json b/sdk/js/package.json
index 637a6c96..46d26a2c 100644
--- a/sdk/js/package.json
+++ b/sdk/js/package.json
@@ -5,7 +5,7 @@
"license": "Apache-2.0",
"repository": {
"type": "git",
- "url": "https://github.com/google/sam.git",
+ "url": "git+https://github.com/google/sam.git",
"directory": "sdk/js"
},
"type": "module",