Files
AvDict/.github/workflows/release.yml
T

46 lines
1.3 KiB
YAML
Raw Blame History

This file contains ambiguous Unicode characters
This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.
name: Release
# 只有推送 v 开头的 tag 时才触发(例如 v1.2.3)
on:
push:
tags:
- 'v*'
jobs:
release:
runs-on: ubuntu-latest
permissions:
contents: write # 必须,用于创建 Release
steps:
- name: Checkout code
uses: actions/checkout@v4
with:
fetch-depth: 0 # 获取完整历史,方便生成 release notes
# 1. 设置 Node.js + npm 发布配置
- name: Setup Node.js
uses: actions/setup-node@v4
with:
node-version: 20
registry-url: 'https://registry.npmjs.org'
cache: 'npm'
# 2. 安装依赖
- name: Install dependencies
run: npm ci
# 3. 自动创建 GitHub Release(带自动生成的 Release Notes)
- name: Create GitHub Release
uses: ncipollo/release-action@v1
with:
tag: ${{ github.ref_name }}
name: ${{ github.ref_name }}
generateReleaseNotes: true
prerelease: ${{ contains(github.ref_name, '-') }} # 带 -beta / -rc 的自动设为预发布
# 4. 发布到 npm(只在正式 tag 时执行)
- name: Publish to npm
run: npm publish --access public
env:
NODE_AUTH_TOKEN: ${{ secrets.NPM_TOKEN }}