Skip to content

v0.2.0

v0.2.0 #1

Workflow file for this run

# Publishes the @modelcontextprotocol/ext-tasks package to npm when a GitHub
# Release is published. Versioning is manual: bump packages/ext-tasks/package.json
# in the release commit, then cut the GitHub Release from that tag — this workflow
# picks it up from there.
name: Publish to npm
on:
release:
types: [published]
concurrency:
group: ${{ github.workflow }}-${{ github.ref }}
cancel-in-progress: true
permissions:
contents: read
jobs:
validate:
name: Validate before publishing
runs-on: ubuntu-latest
permissions:
contents: read
steps:
- name: Checkout
uses: actions/checkout@v4
- name: Setup Node
uses: actions/setup-node@v4
with:
node-version: "24"
cache: npm
- name: Install dependencies
run: npm ci
# Full gate: schema provenance, format, lint, typecheck, tests, build, and
# the packed-consumer check. Runs again here rather than trusting CI, so a
# publish can never proceed from a commit CI hasn't fully validated.
- name: Check schemas, package, and packed consumers
run: npm run check
- name: Build documentation
run: npm run docs:build
publish:
name: Publish
needs: validate
runs-on: ubuntu-latest
environment: release
permissions:
contents: read
id-token: write
steps:
- name: Checkout
uses: actions/checkout@v4
- name: Setup Node
uses: actions/setup-node@v4
with:
node-version: "24"
cache: npm
registry-url: "https://registry.npmjs.org"
- name: Install dependencies
run: npm ci
# Node 24's bundled npm satisfies the >= 11.5.1 OIDC requirement only from
# ~24.6 onward; pin explicitly so the publish never depends on which Node
# patch the runner resolves.
- name: Ensure npm CLI supports OIDC trusted publishing
run: npm install -g npm@11.5.1
# The tag is compared to the manifest before anything reaches npm, because
# a release cut from the wrong commit (or tagged with the wrong version)
# would otherwise publish a version that does not match its tag.
- name: Validate release tag against package.json
env:
# Passed through env rather than interpolated into the script,
# so a tag name can never be evaluated as shell syntax.
RELEASE_TAG: ${{ github.event.release.tag_name }}
run: |
VERSION=$(node -p "require('./packages/ext-tasks/package.json').version")
if [[ "${RELEASE_TAG#v}" != "$VERSION" ]]; then
echo "Release tag ${RELEASE_TAG} does not match package.json version ${VERSION}."
exit 1
fi
- name: Determine npm dist-tag
id: npm-tag
env:
# Passed through env rather than interpolated into the script,
# so a branch name can never be evaluated as shell syntax.
RELEASE_TARGET: ${{ github.event.release.target_commitish }}
run: |
VERSION=$(node -p "require('./packages/ext-tasks/package.json').version")
# Pre-release versions publish under the beta dist-tag.
if [[ "$VERSION" == *"-"* ]]; then
echo "tag=--tag beta" >> "$GITHUB_OUTPUT"
# Releases cut from a non-main branch (patch/maintenance lines) publish
# under release-X.Y so they never displace latest.
elif [[ "$RELEASE_TARGET" != "main" ]]; then
MAJOR_MINOR=$(echo "$VERSION" | cut -d. -f1,2)
echo "tag=--tag release-${MAJOR_MINOR}" >> "$GITHUB_OUTPUT"
else
echo "tag=" >> "$GITHUB_OUTPUT"
fi
- name: Publish to npm
run: npm publish --provenance --access public ${{ steps.npm-tag.outputs.tag }}
working-directory: packages/ext-tasks
env:
NPM_CONFIG_PROVENANCE: "true"
verify:
name: Verify published package
needs: publish
runs-on: ubuntu-latest
permissions:
contents: read
steps:
- name: Checkout
uses: actions/checkout@v4
- name: Setup Node
uses: actions/setup-node@v4
with:
node-version: "24"
cache: npm
- name: Wait for npm to serve the version
run: |
VERSION=$(node -p "require('./packages/ext-tasks/package.json').version")
for i in $(seq 1 30); do
if npm view "@modelcontextprotocol/ext-tasks@${VERSION}" version >/dev/null 2>&1; then
echo "npm is serving ${VERSION}."
exit 0
fi
echo "Not visible yet (attempt ${i}/30); waiting 10s..."
sleep 10
done
echo "npm never served ${VERSION} within 5 minutes of publishing."
exit 1