chore(release): v1.1.4 #16
Workflow file for this run
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
name: 发布 npm | |
on: | |
push: | |
tags: | |
- "v*.*.*" # 匹配像 v1.0.0-beta.0 这样的版本标签 | |
permissions: | |
contents: write | |
discussions: write | |
jobs: | |
release: | |
runs-on: ubuntu-latest | |
steps: | |
- name: Checkout code | |
uses: actions/checkout@v3 | |
- name: Parse tag and set version | |
id: parse_tag | |
run: | | |
# 从 GitHub 的 tag 中提取版本信息 | |
tag_name="${GITHUB_REF#refs/tags/}" | |
version="${tag_name#v}" | |
if [[ "$tag_name" == *"-alpha"* ]]; then | |
prerelease=true | |
tag="alpha" | |
elif [[ "$tag_name" == *"-beta"* ]]; then | |
prerelease=true | |
tag="beta" | |
elif [[ "$tag_name" == *"-rc"* ]]; then | |
prerelease=true | |
tag="rc" | |
else | |
prerelease=false | |
tag="latest" | |
fi | |
echo "Tag: $tag_name" | |
echo "Version: $version" | |
echo "Is prerelease: $prerelease" | |
echo "::set-output name=prerelease::$prerelease" | |
echo "::set-output name=version::$version" | |
echo "::set-output name=tag::$tag" | |
- uses: oven-sh/setup-bun@v1 | |
- name: Install dependencies | |
run: | | |
bun i | |
bun run build | |
bun run scripts/ver.ts | |
# - name: Update package versions with changesets | |
# run: | | |
# npx changeset version # 更新版本号 | |
- uses: actions/setup-node@v3 | |
with: | |
node-version: 22 | |
registry-url: https://registry.npmjs.org/ | |
- name: Publish to npm | |
run: | | |
# 遍历 packages 目录下的每个子目录 | |
for dir in packages/*; do | |
# 确保该项是一个目录 | |
if [ -d "$dir" ]; then | |
echo "Publishing package in $dir" | |
# 切换到该目录并执行 npm publish | |
(cd "$dir" && npm publish) | |
fi | |
done | |
env: | |
NODE_AUTH_TOKEN: ${{ secrets.NPM_ACCESS_TOKEN }} | |
- name: Create GitHub release | |
uses: softprops/action-gh-release@v1 | |
with: | |
prerelease: ${{ steps.parse_tag.outputs.prerelease }} | |
tag_name: ${{ steps.parse_tag.outputs.version }} |