|
| 1 | +name: Release |
| 2 | + |
| 3 | +# Publishes the `inkstudioai` package to npm, then its server.json to the |
| 4 | +# MCP Registry. Release: set the same version in package.json and in both |
| 5 | +# version fields of server.json, merge, then push a tag `v<version>`. |
| 6 | +# |
| 7 | +# npm: trusted publishing (OIDC), so there is no npm token. On npmjs.com, |
| 8 | +# package inkstudioai > Settings > Trusted Publisher > GitHub Actions: |
| 9 | +# user ciroartz, repository inkstudioai-cli, workflow release.yml. |
| 10 | +# From a public repository, npm adds provenance on its own. |
| 11 | +# |
| 12 | +# MCP Registry: GitHub OIDC login, which owns the io.github.ciroartz/ namespace. |
| 13 | + |
| 14 | +on: |
| 15 | + push: |
| 16 | + tags: ["v*"] |
| 17 | + |
| 18 | +concurrency: |
| 19 | + group: release |
| 20 | + cancel-in-progress: false |
| 21 | + |
| 22 | +permissions: |
| 23 | + contents: read |
| 24 | + id-token: write |
| 25 | + |
| 26 | +jobs: |
| 27 | + release: |
| 28 | + runs-on: ubuntu-latest |
| 29 | + steps: |
| 30 | + - uses: actions/checkout@v4 |
| 31 | + |
| 32 | + # Trusted publishing needs Node 22.14 or later and npm 11.5.1 or later. |
| 33 | + - uses: actions/setup-node@v4 |
| 34 | + with: |
| 35 | + node-version: "22" |
| 36 | + registry-url: https://registry.npmjs.org |
| 37 | + |
| 38 | + - name: Update npm |
| 39 | + run: npm install -g npm@11 |
| 40 | + |
| 41 | + - name: Run the tests |
| 42 | + run: node --test test/*.test.mjs |
| 43 | + |
| 44 | + - name: Check that the tag, package.json, and server.json agree |
| 45 | + run: | |
| 46 | + version=$(node -p "require('./package.json').version") |
| 47 | + server=$(node -p "const s = require('./server.json'); s.version + ' ' + s.packages[0].version") |
| 48 | + if [ "${GITHUB_REF_NAME}" != "v${version}" ] || [ "${server}" != "${version} ${version}" ]; then |
| 49 | + echo "Tag ${GITHUB_REF_NAME}, package.json ${version}, and server.json (${server}) must match." >&2 |
| 50 | + exit 1 |
| 51 | + fi |
| 52 | +
|
| 53 | + - name: Publish to npm |
| 54 | + run: npm publish --access public |
| 55 | + |
| 56 | + - name: Install mcp-publisher |
| 57 | + run: | |
| 58 | + curl -fsSL "https://github.com/modelcontextprotocol/registry/releases/latest/download/mcp-publisher_linux_amd64.tar.gz" | tar xz mcp-publisher |
| 59 | +
|
| 60 | + - name: Publish to the MCP Registry |
| 61 | + run: | |
| 62 | + ./mcp-publisher login github-oidc |
| 63 | + # The registry checks mcpName on npm, which can lag a few seconds behind the publish. |
| 64 | + for attempt in 1 2 3 4 5; do |
| 65 | + ./mcp-publisher publish && exit 0 |
| 66 | + sleep 20 |
| 67 | + done |
| 68 | + exit 1 |
0 commit comments