Package Extension Only #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: "Package Extension Only" | |
| on: | |
| workflow_dispatch: | |
| push: | |
| tags: | |
| - 'package-*' # 当推送以 package- 开头的标签时自动触发 | |
| jobs: | |
| package: | |
| runs-on: ubuntu-latest | |
| permissions: | |
| contents: read | |
| packages: write | |
| steps: | |
| - uses: actions/checkout@v4 | |
| - name: Cache pnpm modules | |
| uses: actions/cache@v3 | |
| with: | |
| path: ~/.pnpm-store | |
| key: ${{ runner.os }}-${{ hashFiles('**/pnpm-lock.yaml') }} | |
| restore-keys: | | |
| ${{ runner.os }}- | |
| - uses: pnpm/action-setup@v4 | |
| with: | |
| version: 8 | |
| run_install: true | |
| - name: Use Node.js 18.x | |
| uses: actions/setup-node@v4 | |
| with: | |
| node-version: 18.x | |
| cache: "pnpm" | |
| - name: Build the extension | |
| run: pnpm build | |
| env: | |
| # AI 配置环境变量(可选) | |
| AI_HOST: ${{ secrets.AI_HOST }} | |
| AI_MODEL: ${{ secrets.AI_MODEL }} | |
| AI_TOKEN: ${{ secrets.AI_TOKEN }} | |
| - name: Package the extension | |
| run: pnpm package | |
| - name: Upload package artifacts | |
| uses: actions/upload-artifact@v4 | |
| with: | |
| name: extension-package | |
| path: build/ | |
| retention-days: 30 | |
| - name: Publish to GitHub Packages | |
| run: | | |
| echo "@aipexstudio:registry=https://npm.pkg.github.com" >> ~/.npmrc | |
| echo "//npm.pkg.github.com/:_authToken=${{ secrets.GITHUB_TOKEN }}" >> ~/.npmrc | |
| pnpm publish:github | |
| env: | |
| NODE_AUTH_TOKEN: ${{ secrets.GITHUB_TOKEN }} |