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: