Skip to content

refactor: 类型修改 #3

refactor: 类型修改

refactor: 类型修改 #3

# 当任意分支push时,检测package.json中有没有匹配的release,如果没有则创建一个release
name: Create release if no matching release exists
on:
push:
branches:
- '**' # 对任意分支进行监听
jobs:
build:
runs-on: ubuntu-latest
steps:
- name: Checkout
uses: actions/checkout@v4
- name: Setup Pnpm
uses: pnpm/action-setup@v3
with:
version: latest
- name: Set up Node.js
uses: actions/setup-node@v4
with:
node-version: 20
registry-url: https://registry.npmjs.org/
cache: 'pnpm'
- name: Install dependencies
run: pnpm install
- name: Check for release in package.json
id: check
run: |
VERSION=$(node -p "require('./package.json').version")
echo "VERSION=$VERSION" >> $GITHUB_ENV
RELEASES=$(gh release list --json version -q ".[] | select(.version == env.VERSION)")
if [[ -z "$RELEASES" ]]; then
echo "RELEASE_EXISTS=false" >> $GITHUB_ENV
else
echo "RELEASE_EXISTS=true" >> $GITHUB_ENV
- name: Create a new release
if: env.RELEASE_EXISTS == 'false'
run: gh release create $VERSION
# 否则输出RELEASE_EXISTS=true,不执行创建release的操作