ci: add GitHub Action to publish create-antd-admin to npm

Made-with: Cursor
This commit is contained in:
zuiidea
2026-04-15 11:15:12 +08:00
parent 70ee2eaa41
commit 73e53ea3ba
3 changed files with 107 additions and 18 deletions
@@ -0,0 +1,69 @@
# Publish npm package `create-antd-admin` from packages/create
#
# Setup (one-time):
# 1. npmjs.com → Access Tokens → Granular or Automation token with publish rights
# 2. Repo → Settings → Secrets and variables → Actions → New repository secret
# Name: NPM_TOKEN Value: <token>
#
# Release:
# A) Manual: Actions → "Publish create-antd-admin" → Run workflow
# B) Tag: git tag create-antd-admin-v1.0.0 && git push origin create-antd-admin-v1.0.0
# (tag suffix must match packages/create/package.json "version")
name: Publish create-antd-admin
on:
workflow_dispatch:
push:
tags:
- "create-antd-admin-v*"
permissions:
contents: read
id-token: write
concurrency:
group: publish-create-antd-admin
cancel-in-progress: true
jobs:
publish:
runs-on: ubuntu-latest
defaults:
run:
shell: bash
steps:
- name: Checkout
uses: actions/checkout@v4
- name: Setup pnpm
uses: pnpm/action-setup@v4
with:
version: 8.15.6
- name: Setup Node.js
uses: actions/setup-node@v4
with:
node-version: "20"
registry-url: "https://registry.npmjs.org"
cache: "pnpm"
cache-dependency-path: pnpm-lock.yaml
- name: Install dependencies
run: pnpm install --frozen-lockfile
- name: Test create-antd-admin
run: pnpm test
working-directory: packages/create
- name: Build create-antd-admin
run: pnpm run build
working-directory: packages/create
- name: Publish to npm
# provenance: see packages/create/package.json publishConfig (requires id-token: write)
run: npm publish --access public
working-directory: packages/create
env:
NODE_AUTH_TOKEN: ${{ secrets.NPM_TOKEN }}
+33 -17
View File
@@ -24,30 +24,34 @@ pnpm dlx create-antd-admin@latest my-app --example basic --skip-install
### CLI options
| Option | Description |
|--------|-------------|
| `[project-directory]` | Target folder (relative path or `.`; empty dirs only) |
| `-e, --example <name\|url>` | Example id from the built-in list, or a template URL |
| `--example-path <path>` | Extra path inside the repo when using a URL |
| `-m, --package-manager` | `npm` \| `yarn` \| `pnpm` \| `bun` |
| `--skip-install` | Do not run install after scaffold |
| `--skip-transforms` | Skip rewrites (e.g. `package.json` name) |
| `--no-git` | Do not run `git init` |
| `-v, --version` | Print CLI version |
| `-h, --help` | Print help |
| Option | Description |
| -------------------------- | ----------------------------------------------------- |
| `[project-directory]` | Target folder (relative path or `.`; empty dirs only) |
| `-e, --example <name|url>` | Example id from the built-in list, or a template URL |
| `--example-path <path>` | Extra path inside the repo when using a URL |
| `-m, --package-manager` | `npm` | `yarn` | `pnpm` | `bun` |
| `--skip-install` | Do not run install after scaffold |
| `--skip-transforms` | Skip rewrites (e.g. `package.json` name) |
| `--no-git` | Do not run `git init` |
| `-v, --version` | Print CLI version |
| `-h, --help` | Print help |
Run `create-antd-admin --help` for the full help text.
## Environment
| Variable | Purpose |
|----------|---------|
| `CREATE_ANTD_ADMIN_REPO` | Override `owner/name` (default: `zuiidea/antd-admin`) |
| `CREATE_ANTD_ADMIN_REF` | Override Git ref (branch, tag, or SHA). Default is `v<cliVersion>` from this package’s `package.json`; falls back to `main` if the version file cannot be read. |
| Variable | Purpose |
| ------------------------ | --------------------------------------------------------------------------------------------------------------------------------------------------------------- |
| `CREATE_ANTD_ADMIN_REPO` | Override `owner/name` (default: `zuiidea/antd-admin`) |
| `CREATE_ANTD_ADMIN_REF` | Override Git ref (branch, tag, or SHA). Default is `v<cliVersion>` from this package’s `package.json`; falls back to `main` if the version file cannot be read. |
## Built-in examples
At **publish** time, `apps/*` is scanned (excluding `apps/docs`) and written to `dist/examples.json`. Short names passed to `--example` must appear in that list.
At **publish** time, `apps/`* is scanned (excluding `apps/docs`) and written to `dist/examples.json`. Short names passed to `--example` must appear in that list.
## Develop in this monorepo
@@ -63,6 +67,18 @@ node dist/cli.js --help
Design and implementation notes live under `docs/specs/` in the monorepo (e.g. `2026-04-14-create-antd-admin-design.md`).
## Publish (maintainers)
CI workflow: `.github/workflows/publish-create-antd-admin.yml` in the monorepo (open on GitHub from the default branch).
1. Add repository secret **`NPM_TOKEN`** (npm automation or granular token with publish permission for `create-antd-admin`).
2. Bump **`version`** in this directory’s `package.json`, commit, then either:
- **Actions → “Publish create-antd-admin” → Run workflow**, or
- Push tag **`create-antd-admin-v<version>`** (e.g. `create-antd-admin-v1.0.0` must match `package.json` version `1.0.0`).
3. Push a matching **`v<version>`** tag on the monorepo (e.g. `v1.0.0`) if users rely on the default template ref `v${version}` from the CLI.
If **provenance** publish fails, remove `"provenance": true` from `publishConfig` in `package.json` or adjust token / org policy per [npm provenance docs](https://docs.npmjs.com/generating-provenance-statements).
## License
MIT (same as the parent repository).
MIT (same as the parent repository).
+5 -1
View File
@@ -1,6 +1,6 @@
{
"name": "create-antd-admin",
"version": "6.0.0",
"version": "1.0.0",
"description": "Create an Antd Admin app from official examples",
"license": "MIT",
"type": "module",
@@ -18,6 +18,10 @@
"test": "vitest run",
"test:watch": "vitest"
},
"publishConfig": {
"access": "public",
"provenance": true
},
"engines": {
"node": ">=20"
},