Skip to content

release(@142vip/utils): publish v0.0.1-alpha.51 #1141

release(@142vip/utils): publish v0.0.1-alpha.51

release(@142vip/utils): publish v0.0.1-alpha.51 #1141

Workflow file for this run

#
# CD持续交付
# - 部署到Github Pages
# - 发布新的Github Release
# 参考
# - https://vitepress.dev/zh/guide/deploy#github-pages
#
name: CD
on:
push:
branches:
- next
- fix/cd
workflow_dispatch:
inputs:
package:
description: 要发布的 npm 包(手动触发时必选)
required: true
type: choice
options:
- '@142vip/axios'
- '@142vip/changelog'
- '@142vip/commit-linter'
- '@142vip/copyright'
- '@142vip/data-source'
- '@142vip/egg'
- '@142vip/egg-axios'
- '@142vip/egg-grpc-client'
- '@142vip/egg-grpc-server'
- '@142vip/egg-mysql'
- '@142vip/egg-redis'
- '@142vip/egg-sequelize'
- '@142vip/egg-swagger'
- '@142vip/egg-validate'
- '@142vip/eslint-config'
- '@142vip/fairy-cli'
- '@142vip/grpc'
- '@142vip/nest'
- '@142vip/nest-logger'
- '@142vip/nest-redis'
- '@142vip/nest-starter'
- '@142vip/nest-typeorm'
- '@142vip/oauth2.0'
- '@142vip/open-source'
- '@142vip/redis'
- '@142vip/release-version'
- '@142vip/typeorm'
- '@142vip/utils'
- '@142vip/vitepress'
- '@142vip/vuepress'
# 设置 GITHUB_TOKEN 的权限,以允许部署到 GitHub Pages
permissions:
contents: read
pages: write
id-token: write
jobs:
# 版本发布
github-release:
name: 创建Github发布
runs-on: ubuntu-latest
# 主库next且执行release更新时执行
if: github.event_name == 'push' && github.repository == '142vip/core-x' && startsWith(github.event.head_commit.message, 'chore(release):')
steps:
- name: Checkout Code
uses: actions/checkout@v4
with:
persist-credentials: false
fetch-depth: 0
# 安装PNPM
- name: PNPM Install
uses: pnpm/action-setup@v4
with:
version: 9.6.0
# 安装Node环境
- name: Install Node.js
uses: actions/setup-node@v4
with:
node-version: 20.12.2
# 缓存
cache: pnpm
# 基于国内镜像源下载依赖,并执行初始化脚本:钩子函数、思维导图构建
- name: Install Dependencies
run: |
./scripts/ci
# ci的hooks已经执行
# - name: Build All Packages
# run: |
# pnpm build:packages
# Github发布版本,并更新Release信息
- name: Release New Version
run: npx changelog
env:
GITHUB_TOKEN: ${{secrets.TOKEN}}
npm-release:
name: 创建npm发布
runs-on: ubuntu-latest
# push: release(@scope/pkg) 提交;workflow_dispatch: 手动选择包发版
if: |
(github.event_name == 'workflow_dispatch' && github.event.inputs.package != '') ||
(github.event_name == 'push' && startsWith(github.event.head_commit.message, 'release(@'))
steps:
- name: Checkout Code
uses: actions/checkout@v4
with:
persist-credentials: false
# “最近更新时间” 等 git 日志相关信息,需要拉取全部提交记录
fetch-depth: 0
# 安装PNPM
- name: PNPM Install
uses: pnpm/action-setup@v4
with:
version: 9.6.0
# 安装Node环境
- name: Install Node.js
uses: actions/setup-node@v4
with:
node-version: 20.12.2
# npm包上传地址,用于注册,参考:https://github.com/actions/setup-node
registry-url: 'https://registry.npmjs.org'
# 缓存
cache: pnpm
# 下载依赖,并执行初始化脚本:钩子函数、思维导图构建
- name: Install Dependencies
run: |
./scripts/ci
# ci的hooks已经执行
# - name: Build All Packages
# run: |
# pnpm build:packages
- name: Resolve Package Name
id: getPkgName
run: |
if [ "${{ github.event_name }}" = "workflow_dispatch" ]; then
echo "name=${{ github.event.inputs.package }}" >> "$GITHUB_OUTPUT"
else
SCOPE=$(echo "${{ github.event.head_commit.message }}" | grep -o '@[^):]*' | head -1)
echo "name=${SCOPE}" >> "$GITHUB_OUTPUT"
fi
- name: Use Package Name
run: |
echo "The pkgName is: ${{ steps.getPkgName.outputs.name }}"
- name: Upgrade npm for OIDC trusted publishing
run: npm i -g npm@^11.10
# OIDC 发布:须在 npm 各包上配置 Trusted Publisher(见 scripts/npm-trust)
- name: Publish New Npm Version
run: pnpm publish --filter "${{ steps.getPkgName.outputs.name }}"
# 构建并部署Dist
deploy-dist:
name: 部署到Github Pages
runs-on: ubuntu-latest
environment:
name: github-pages
url: ${{ steps.deployment.outputs.page_url }}
# 仅 push 到 next/fix/cd 时部署文档,手动发版 npm 不触发
if: github.event_name == 'push' && github.repository == '142vip/core-x'
steps:
# 拉取代码
- name: Checkout
uses: actions/checkout@v4
with:
fetch-depth: 0 # 如果未启用 lastUpdated,则不需要
# 安装pnpm
- name: PNPM Install
uses: pnpm/action-setup@v4
with:
version: 9.6.0
# 安装Node
- name: Setup Node
uses: actions/setup-node@v4
with:
node-version: 20.12.2
cache: pnpm
- name: Setup Pages
uses: actions/configure-pages@v5
- name: Install dependencies
run: |
./scripts/ci
# ci的hooks已经执行
# - name: Build All Packages
# run: |
# pnpm build:packages
# 编译 打包成dist,支持代理
- name: Build with VitePress
run: |
pnpm build:docs-proxy
# 编译,typedoc生成api文档
# - name: Build with Typedoc API
# run: |
# pnpm typedoc:api
# 上传dist文件
- name: Upload artifact
uses: actions/upload-pages-artifact@v3
with:
path: dist
# 部署
- name: Deploy to GitHub Pages
id: deployment
uses: actions/deploy-pages@v4
# 部署Wiki
deploy-wiki:
name: 部署到Github Wiki
runs-on: ubuntu-latest
# 主库next且执行release更新时执行
if: github.event_name == 'push' && github.repository == '142vip/core-x' && startsWith(github.event.head_commit.message, 'chore(release):')
steps:
- name: Checkout Code
uses: actions/checkout@v4
with:
persist-credentials: false
fetch-depth: 0
- name: Deploy Docs To Wiki
uses: SwiftDocOrg/github-wiki-publish-action@v1
with:
path: docs/wiki
env:
GH_PERSONAL_ACCESS_TOKEN: ${{secrets.TOKEN}}