59 lines
1.6 KiB
YAML
59 lines
1.6 KiB
YAML
name: publish
|
|
on:
|
|
push:
|
|
tags: ["v*"]
|
|
|
|
jobs:
|
|
npm:
|
|
runs-on: ubuntu-latest
|
|
steps:
|
|
- name: checkout from in-cluster gitea
|
|
run: |
|
|
set -e
|
|
git clone --depth=1 --branch "${GITHUB_REF_NAME}" \
|
|
"http://gitea_admin:${{ secrets.ADMIN_PW }}@gitea-http.gitea.svc.cluster.local:3000/gitea_admin/a2a-mcp.git" .
|
|
git log -1 --oneline
|
|
|
|
- name: setup node
|
|
run: |
|
|
set -e
|
|
apt-get update
|
|
apt-get install -y --no-install-recommends ca-certificates curl
|
|
curl -fsSL https://deb.nodesource.com/setup_20.x | bash -
|
|
apt-get install -y --no-install-recommends nodejs
|
|
node --version
|
|
npm --version
|
|
|
|
- name: install dependencies
|
|
run: npm ci
|
|
|
|
- name: assert tag matches package version
|
|
run: |
|
|
PKG_VER=$(node -p "require('./package.json').version")
|
|
TAG_VER="${GITHUB_REF_NAME#v}"
|
|
echo "tag=$TAG_VER package=$PKG_VER"
|
|
if [ "$TAG_VER" != "$PKG_VER" ]; then
|
|
echo "tag $TAG_VER does not match package.json version $PKG_VER" >&2
|
|
exit 1
|
|
fi
|
|
|
|
- name: test
|
|
run: npm test
|
|
|
|
- name: build
|
|
run: npm run build
|
|
|
|
- name: verify package contents
|
|
run: npm pack --dry-run
|
|
|
|
- name: publish to npm
|
|
env:
|
|
NODE_AUTH_TOKEN: ${{ secrets.NPM_TOKEN }}
|
|
run: |
|
|
if [ -z "$NODE_AUTH_TOKEN" ]; then
|
|
echo "NPM_TOKEN not set on this repo." >&2
|
|
exit 1
|
|
fi
|
|
printf '//registry.npmjs.org/:_authToken=%s\n' "$NODE_AUTH_TOKEN" > ~/.npmrc
|
|
npm publish --access public
|