chore: 升级 n8n-nodes-mineru 版本至 0.1.9,并确保 GitHub Actions 使用最新的 npm 以满足… #4
This file contains hidden or 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 n8n-nodes-mineru to npm (on main) | |
| on: | |
| push: | |
| branches: [ main ] | |
| paths: | |
| - 'n8n-nodes-mineru/**' | |
| - '.github/workflows/publish-n8n-nodes-mineru.yml' | |
| permissions: | |
| contents: read | |
| id-token: write # OIDC for npm --provenance | |
| concurrency: | |
| group: publish-n8n-nodes-mineru-${{ github.ref }} | |
| cancel-in-progress: true | |
| jobs: | |
| release: | |
| runs-on: ubuntu-latest | |
| timeout-minutes: 20 | |
| defaults: | |
| run: | |
| working-directory: n8n-nodes-mineru | |
| steps: | |
| - name: Checkout | |
| uses: actions/checkout@v4 | |
| - name: Setup Node & Corepack | |
| uses: actions/setup-node@v4 | |
| with: | |
| node-version: 20 | |
| registry-url: 'https://registry.npmjs.org' | |
| - run: corepack enable | |
| # ⬇️ 新增:升级 npm 到最新(满足 Trusted Publishing 的最新要求) | |
| - name: Ensure latest npm (for trusted publishing) | |
| run: npm i -g npm@latest | |
| - name: Setup pnpm | |
| uses: pnpm/action-setup@v4 | |
| with: | |
| version: 9 | |
| # 缓存 pnpm store(基于子包 lockfile) | |
| - name: Cache pnpm store | |
| uses: actions/cache@v4 | |
| with: | |
| path: ~/.pnpm-store | |
| key: ${{ runner.os }}-pnpm-${{ hashFiles('n8n-nodes-mineru/pnpm-lock.yaml') }} | |
| restore-keys: | | |
| ${{ runner.os }}-pnpm- | |
| # 如果有 pnpm-lock.yaml,用严格模式;否则首次允许生成锁文件 | |
| - name: Install deps (pnpm) | |
| run: | | |
| if [ -f pnpm-lock.yaml ]; then | |
| pnpm install --frozen-lockfile | |
| else | |
| echo "No pnpm-lock.yaml found, installing without frozen lockfile..." | |
| pnpm install --no-frozen-lockfile | |
| fi | |
| - name: Build (sanity) | |
| run: pnpm run build --if-present | |
| # 可选:提前暴露打包/忽略问题(不真正发布) | |
| - name: Dry-run pack | |
| run: | | |
| pnpm pack --dry-run || true | |
| npm publish --dry-run || true | |
| - name: Check if publish needed | |
| id: need | |
| run: | | |
| PKG_NAME=$(node -p "require('./package.json').name") | |
| PKG_VER=$(node -p "require('./package.json').version") | |
| echo "package=$PKG_NAME version=$PKG_VER" | |
| PUBLISHED_VER=$(npm view "$PKG_NAME@latest" version || true) | |
| echo "published=$PUBLISHED_VER" | |
| if [ "$PKG_VER" = "$PUBLISHED_VER" ]; then | |
| echo "should_publish=false" >> $GITHUB_OUTPUT | |
| else | |
| echo "should_publish=true" >> $GITHUB_OUTPUT | |
| fi | |
| # 用 npm 发布以启用 provenance(与 pnpm 安装不冲突) | |
| - name: Publish with provenance (OIDC) | |
| if: steps.need.outputs.should_publish == 'true' | |
| env: | |
| NPM_CONFIG_PROVENANCE: true | |
| NPM_CONFIG_LOGLEVEL: verbose | |
| run: npm publish --provenance --access public | |
| - name: Skip (version unchanged) | |
| if: steps.need.outputs.should_publish != 'true' | |
| run: echo "Version already on npm, skip." |