English · 简体中文
Three ways to run cws in a pipeline. All of them read .cws.json from the
repository root and take credentials from the environment.
name: release
on:
push:
tags: ['v*']
jobs:
publish:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- uses: actions/setup-node@v4
with:
node-version: 22 # the CLI needs Node ≥ 22
- run: npm ci # only if your build needs it
- run: npm run build # produce the zip first
- uses: XCreativeStudio/cws-release@v1
with:
command: release
zip: .output/*-chrome.zip
env:
CWS_SERVICE_ACCOUNT: $
The action installs the CLI into the runner, checks the Node version, and returns:
result — the { ok, command, data } envelope;code — error.code when the run failed.Use them to gate later steps:
- uses: XCreativeStudio/cws-release@v1
id: cws
with: { command: status }
env: { CWS_SERVICE_ACCOUNT: $ }
- if: steps.cws.outputs.result != ''
run: echo "published: $(echo '$' | jq -r '.data.publishedItemRevisionStatus.state')"
Credentials are deliberately not inputs: put them in the step’s env so
they never appear in the action’s resolved inputs in the job log.
- run: npx cws-release release
env:
CWS_SERVICE_ACCOUNT: $
CWS_ZIP: .output/*-chrome.zip
npx fetches the latest release when the package is not installed locally. To
pin a version in a repository that has it as a dev dependency:
- run: npm ci
- run: npx --no cws-release release # never fetches; fails if node_modules is missing
env:
CWS_SERVICE_ACCOUNT: $
--no is --no-install: it turns a missing install into a fast error instead
of a silent network fetch.
deploy:
image: node:22
script:
- npm ci
- npm run build
- npx cws-release release
variables:
CWS_ZIP: '.output/*-chrome.zip'
rules:
- if: $CI_COMMIT_TAG
Put CWS_SERVICE_ACCOUNT in Settings → CI/CD → Variables, masked and
protected.
A script that fails with the API’s own reason and hint:
set -o pipefail
if ! out=$(npx cws-release release --json 2>err.log); then
sed -n 's/^cws:json //p' err.log \
| jq -r '.error | "\(.code): \(.message) — \(.hint // "")"' >&2
exit 1
fi
echo "$out" | jq -r '.data.status.publishedItemRevisionStatus.state'
Code meanings and retry guidance: errors.md.
npx cws-release follows latest. For a reproducible pipeline, either keep the
package in devDependencies and use npm ci, or pin in the specifier:
npx cws-release@0.1.2 release
For the action, pin the major tag (@v1) for fixes, or an exact tag
(@v0.1.2) for full reproducibility.