1.0.1 #51
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: Publish Package | |
on: | |
push: | |
branches: | |
- main | |
jobs: | |
publish: | |
runs-on: ubuntu-latest | |
environment: Release | |
steps: | |
- name: 检出代码 | |
uses: actions/checkout@v4 | |
- name: 安装Pnpm | |
uses: pnpm/action-setup@v2 | |
with: | |
version: 8 | |
- name: 安装依赖 | |
run: pnpm i --no-frozen-lockfile --shamefully-hoist | |
- name: 设置Node的版本 | |
uses: actions/setup-node@v4 | |
with: | |
node-version: 18 | |
registry-url: 'https://registry.npmjs.org/' | |
cache: 'pnpm' | |
- name: 构建代码 | |
run: pnpm build:npm | |
- name: 发布版本 | |
run: pnpm pub | |
env: | |
NODE_AUTH_TOKEN: '${{secrets.NPM_AUTH_TOKEN}}' | |
- name: 获取当前的版本号 | |
run: | | |
echo "version=$(grep -o '"version": *"[^"]*"' package.json | awk -F'"' '{print $4}')" >> "$GITHUB_ENV" | |
- name: 是否是预发布 | |
run: | | |
echo "prerelease=$([[ ${{ env.version }} == *-* ]] && echo 'true' || echo 'false')" >> "$GITHUB_ENV" | |
- name: 打印信息 | |
run: | | |
echo "version: ${{ env.version }}" | |
echo "prerelease: ${{ env.prerelease }}" | |
- name: 打个标签 | |
uses: ncipollo/release-action@v1 | |
with: | |
tag: "v${{ env.version }}" | |
draft: false | |
prerelease: ${{ env.prerelease }} | |
allowUpdates: true | |
generateReleaseNotes: true | |
body: "Please refer to [CHANGELOG.md](https://github.com/${{ github.repository }}/blob/v${{ env.version }}/CHANGELOG.md) for details." | |
token: ${{ secrets.TOKEN }} |