一键导入
publish
// Publish wechatbot packages to npm and PyPI. Use when the user wants to release, publish, or deploy a new version of the Node.js or Python SDK package.
// Publish wechatbot packages to npm and PyPI. Use when the user wants to release, publish, or deploy a new version of the Node.js or Python SDK package.
| name | publish |
| description | Publish wechatbot packages to npm and PyPI. Use when the user wants to release, publish, or deploy a new version of the Node.js or Python SDK package. |
This project has two publishable packages with separate GitHub Actions workflows:
| Package | Registry | Directory | Workflow | Tag pattern |
|---|---|---|---|---|
@wechatbot/wechatbot | npm | nodejs/ | .github/workflows/publish-npm.yml | node-v* |
@wechatbot/pi-agent | npm | pi-agent/ | .github/workflows/publish-pi-agent.yml | pi-agent-v* |
wechatbot-sdk | PyPI | python/ | .github/workflows/publish-pypi.yml | py-v* |
Before publishing, verify the following:
nodejs/package.json → "version" fieldpython/pyproject.toml → [project] version fieldcd nodejs && npm testcd python && pytestcd nodejs && npm run buildcd python && python -m buildCreate and push a tag to trigger the GitHub Actions workflow:
# 1. Bump version in nodejs/package.json
# 2. Commit the change
git add nodejs/package.json
git commit -m "chore: bump node package to vX.Y.Z"
git push
# 3. Tag and push
git tag node-vX.Y.Z
git push origin node-vX.Y.Z
# 1. Bump version in python/pyproject.toml
# 2. Commit the change
git add python/pyproject.toml
git commit -m "chore: bump python package to vX.Y.Z"
git push
# 3. Tag and push
git tag py-vX.Y.Z
git push origin py-vX.Y.Z
Both workflows support manual triggering from GitHub Actions UI with a dry run option:
npm publish --dry-runOIDC Trusted Publishing cannot be used for the very first publish of a package — the package must already exist on the registry. Follow these steps for initial setup:
npm logincd nodejs
npm publish --access public
Option A — Pending trusted publisher (recommended, no token needed):
wechatbot-sdk), owner (corespeed-io), repo (wechatbot), workflow (publish-pypi.yml), environment (pypi)Option B — Manual publish:
cd python
python -m build
twine upload dist/*
Both npm and PyPI use OIDC Trusted Publishing — GitHub Actions exchanges a short-lived OIDC token with the registry, so no long-lived secrets are needed.
@wechatbot/wechatbot)corespeed-iowechatbotpublish-npm.ymlpermissions: id-token: write must be set in the workflowNODE_AUTH_TOKEN env var — it overrides OIDCpackage.json must have a repository field matching the GitHub repowechatbot-sdk) → Publishingcorespeed-iowechatbotpublish-pypi.ymlpypipypi (and optionally testpypi)To release both packages simultaneously:
# Bump both versions, commit, then tag both
git tag node-vX.Y.Z
git tag py-vX.Y.Z
git push origin node-vX.Y.Z py-vX.Y.Z
Go modules don't use a central registry with upload — they are published by pushing a git tag. The Go module proxy (proxy.golang.org) automatically fetches from GitHub.
go.mod exists in the module directory with the correct module path (e.g. module github.com/corespeed-io/wechatbot/go)# If the module is in repo root:
git tag vX.Y.Z
# If the module is in a subdirectory (e.g. go/):
git tag go/vX.Y.Z
git push origin go/vX.Y.Zgo list -m github.com/corespeed-io/wechatbot/go@vX.Y.ZFor major versions v2+, the module path must include the major version suffix (e.g.
module github.com/corespeed-io/wechatbot/go/v2).
Rust crates are published to crates.io. Unlike npm/PyPI, crates.io does not support OIDC Trusted Publishing — a token is required.
cargo login <token>cd rust
cargo publish
CARGO_REGISTRY_TOKEN in GitHub repo → Settings → Secrets- name: Publish to crates.io
run: cargo publish
env:
CARGO_REGISTRY_TOKEN: ${{ secrets.CARGO_REGISTRY_TOKEN }}
Note:
cargo publishdoes a full build and runs tests before uploading. EnsureCargo.tomlhasversion,license,description, andrepositoryfields — crates.io requires them.
| Issue | Solution |
|---|---|
| npm 403 Forbidden | Verify trusted publisher is configured on npmjs.com with correct repo/workflow |
| npm ENEEDAUTH / 404 | Ensure NODE_AUTH_TOKEN is NOT set (it overrides OIDC); ensure npm >= 11.5.1 |
| npm provenance error | Ensure id-token: write permission is set and repository field exists in package.json |
| PyPI auth failure | Verify trusted publisher is configured with correct workflow name and environment |
| TestPyPI upload fails | Create testpypi environment in GitHub; configure trusted publisher on test.pypi.org |
| Version conflict | The version already exists on the registry; bump the version number |