fix: upgrade Node.js to 22.21.0 and pnpm to 10.19.0 for lockfile comp… #3
Workflow file for this run
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: Release Extension | |
| on: | |
| push: | |
| tags: | |
| - 'v*.*.*' # 触发条件:推送版本标签,如 v1.0.0 | |
| workflow_dispatch: # 允许手动触发 | |
| # 显式设置权限,遵循最小权限原则 | |
| permissions: | |
| contents: write # 需要写入权限以创建 Release | |
| actions: read # 只需读取权限 | |
| checks: read # 只需读取权限 | |
| jobs: | |
| build-and-release: | |
| runs-on: ubuntu-latest | |
| steps: | |
| - name: Checkout code | |
| uses: actions/checkout@v4 | |
| - name: Setup pnpm | |
| uses: pnpm/action-setup@v2 | |
| with: | |
| version: 10.19.0 | |
| - name: Setup Node.js | |
| uses: actions/setup-node@v4 | |
| with: | |
| node-version: '22.21.0' | |
| cache: 'pnpm' | |
| - name: Install dependencies | |
| run: pnpm install --frozen-lockfile | |
| - name: Build Chrome Extension | |
| run: pnpm build:chrome | |
| - name: Build Firefox Extension | |
| run: pnpm build:firefox | |
| - name: Build Edge Extension | |
| run: pnpm build:edge | |
| - name: Create distribution packages | |
| run: | | |
| # 进入构建目录 | |
| cd build | |
| # 打包 Chrome 版本 | |
| cd chrome-mv3-prod | |
| zip -r ../../88code-cost-chrome-${{ github.ref_name }}.zip . | |
| cd .. | |
| # 打包 Firefox 版本 | |
| cd firefox-mv2-prod | |
| zip -r ../../88code-cost-firefox-${{ github.ref_name }}.zip . | |
| cd .. | |
| # 打包 Edge 版本 | |
| cd edge-mv3-prod | |
| zip -r ../../88code-cost-edge-${{ github.ref_name }}.zip . | |
| cd .. | |
| - name: Extract version from package.json | |
| id: package_version | |
| run: echo "version=$(node -p "require('./package.json').version")" >> $GITHUB_OUTPUT | |
| - name: Create Release | |
| uses: softprops/action-gh-release@v1 | |
| with: | |
| name: Release ${{ github.ref_name }} | |
| generate_release_notes: true | |
| files: | | |
| 88code-cost-chrome-${{ github.ref_name }}.zip | |
| 88code-cost-firefox-${{ github.ref_name }}.zip | |
| 88code-cost-edge-${{ github.ref_name }}.zip | |
| draft: false | |
| prerelease: false | |
| env: | |
| GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} | |
| - name: Upload Chrome artifact | |
| uses: actions/upload-artifact@v4 | |
| with: | |
| name: chrome-extension | |
| path: 88code-cost-chrome-${{ github.ref_name }}.zip | |
| retention-days: 90 | |
| - name: Upload Firefox artifact | |
| uses: actions/upload-artifact@v4 | |
| with: | |
| name: firefox-extension | |
| path: 88code-cost-firefox-${{ github.ref_name }}.zip | |
| retention-days: 90 | |
| - name: Upload Edge artifact | |
| uses: actions/upload-artifact@v4 | |
| with: | |
| name: edge-extension | |
| path: 88code-cost-edge-${{ github.ref_name }}.zip | |
| retention-days: 90 |