|
| 1 | +# Publishes the npm and PyPI wrapper packages on a version tag, using OIDC |
| 2 | +# trusted publishing. No NPM_TOKEN or PYPI_TOKEN is stored anywhere: GitHub |
| 3 | +# mints a short-lived OIDC token per run, and npmjs.org / pypi.org accept it |
| 4 | +# because this repo + workflow are configured as trusted publishers. |
| 5 | +# |
| 6 | +# One-time setup, done once per package on the registries (not in this repo): |
| 7 | +# npmjs.org -> package settings -> Trusted Publisher -> GitHub Actions, |
| 8 | +# repo HasData/google-search-mcp, workflow publish.yml |
| 9 | +# pypi.org -> the hasdata org -> Publishing -> add a trusted publisher |
| 10 | +# (pending publisher works before the first release), |
| 11 | +# repo HasData/google-search-mcp, workflow publish.yml |
| 12 | +# |
| 13 | +# The MCP registry entry (com.hasdata/google-search) is NOT published here. It uses |
| 14 | +# domain auth, which would need the namespace-wide Ed25519 key as a secret in |
| 15 | +# every repo. That key stays off CI; the registry entry is published by hand |
| 16 | +# when server.json changes, after the package versions below are live. |
| 17 | +# |
| 18 | +# Release: bump nothing by hand. Tag the commit `vX.Y.Z` and push the tag; the |
| 19 | +# tag is the single source of the version and is written into both manifests. |
| 20 | + |
| 21 | +name: publish |
| 22 | + |
| 23 | +on: |
| 24 | + push: |
| 25 | + tags: ['v*.*.*'] |
| 26 | + |
| 27 | +permissions: |
| 28 | + contents: read |
| 29 | + id-token: write |
| 30 | + |
| 31 | +jobs: |
| 32 | + npm: |
| 33 | + runs-on: ubuntu-latest |
| 34 | + steps: |
| 35 | + - uses: actions/checkout@v4 |
| 36 | + - uses: actions/setup-node@v4 |
| 37 | + with: |
| 38 | + node-version: '22' |
| 39 | + registry-url: 'https://registry.npmjs.org' |
| 40 | + - name: Set version from the tag |
| 41 | + run: npm version "${GITHUB_REF_NAME#v}" --no-git-tag-version --allow-same-version |
| 42 | + - name: Publish to npm (OIDC, no token) |
| 43 | + run: npm publish --access public |
| 44 | + |
| 45 | + pypi: |
| 46 | + runs-on: ubuntu-latest |
| 47 | + steps: |
| 48 | + - uses: actions/checkout@v4 |
| 49 | + - uses: actions/setup-python@v5 |
| 50 | + with: |
| 51 | + python-version: '3.12' |
| 52 | + - name: Set version from the tag |
| 53 | + run: | |
| 54 | + python - "${GITHUB_REF_NAME#v}" <<'PY' |
| 55 | + import re, sys |
| 56 | + v = sys.argv[1] |
| 57 | + p = "pyproject.toml" |
| 58 | + t = open(p, encoding="utf-8").read() |
| 59 | + t = re.sub(r'(?m)^version = ".*"$', f'version = "{v}"', t, count=1) |
| 60 | + open(p, "w", encoding="utf-8", newline="\n").write(t) |
| 61 | + PY |
| 62 | + - name: Build the wheel and sdist |
| 63 | + run: pipx run build |
| 64 | + - name: Publish to PyPI (OIDC, no token) |
| 65 | + uses: pypa/gh-action-pypi-publish@release/v1 |
0 commit comments