From d67cb8b6a083d77cb5dc22f1e636be3c0d6cb554 Mon Sep 17 00:00:00 2001 From: yinxue <2643126914@qq.com> Date: Sat, 6 Dec 2025 10:50:01 +0800 Subject: [PATCH] =?UTF-8?q?=E4=BF=AE=E6=94=B9=E5=B7=A5=E4=BD=9C=E6=B5=81?= =?UTF-8?q?=E6=8B=89=E5=8F=96=E4=BB=A3=E7=A0=81=E9=83=A8=E5=88=86=E5=B9=B6?= =?UTF-8?q?=E6=B7=BB=E5=8A=A0=E8=87=AA=E5=8A=A8=E9=80=92=E5=A2=9E=E7=89=88?= =?UTF-8?q?=E6=9C=AC=E5=8F=B7?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .gitea/workflows/devstar-vscode-release.yaml | 46 +++++++++++++++++++- 1 file changed, 44 insertions(+), 2 deletions(-) diff --git a/.gitea/workflows/devstar-vscode-release.yaml b/.gitea/workflows/devstar-vscode-release.yaml index 9ea29b8..ce4f729 100644 --- a/.gitea/workflows/devstar-vscode-release.yaml +++ b/.gitea/workflows/devstar-vscode-release.yaml @@ -7,17 +7,59 @@ on: branches: - main +permissions: + contents: write + jobs: build: runs-on: ubuntu-latest container: image: node:20-alpine steps: + - name: 安装 Git + run: | + apk add --no-cache git + - name: 拉取代码 - uses: https://devstar.cn/actions/checkout@v4 + uses: actions/checkout@v4 with: + token: ${{ secrets.GITHUB_TOKEN }} fetch-depth: 0 + - name: 配置 Git + run: | + # 添加工作目录为安全目录 + git config --global --add safe.directory "$GITHUB_WORKSPACE" + git config --global --add safe.directory /github/workspace + + # 配置用户信息 + git config --global user.name "github-actions[bot]" + git config --global user.email "github-actions[bot]@users.noreply.github.com" + + - name: 自动递增版本号 + if: github.event_name == 'push' && github.ref == 'refs/heads/main' + run: | + apk add --no-cache jq + CURRENT_VERSION=$(jq -r '.version' package.json) + echo "当前版本: $CURRENT_VERSION" + + # 分解版本号 + IFS='.' read -r MAJOR MINOR PATCH <<< "$CURRENT_VERSION" + + # 递增补丁版本号 + NEW_PATCH=$((PATCH + 1)) + NEW_VERSION="$MAJOR.$MINOR.$NEW_PATCH" + echo "新版本: $NEW_VERSION" + + # 更新 package.json + jq --arg version "$NEW_VERSION" '.version = $version' package.json > package.json.tmp + mv package.json.tmp package.json + + # 提交版本变更 + git add package.json + git commit -m "chore: bump version to $NEW_VERSION [skip ci]" + git push + - name: 安装依赖 run: | npm install @@ -27,7 +69,7 @@ jobs: npm run package - name: 发布插件 - if: gitea.event_name == 'push' && gitea.ref == 'refs/heads/main' + if: github.event_name == 'push' && github.ref == 'refs/heads/main' run: | npm run publish env: