Merge pull request #38 from TrueNine/dev #32
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 CLI | |
| concurrency: | |
| group: ${{ github.workflow }}-${{ github.ref }} | |
| cancel-in-progress: false | |
| on: | |
| push: | |
| branches: | |
| - main | |
| workflow_dispatch: | |
| permissions: | |
| contents: write | |
| jobs: | |
| # 1. 版本检查(快速,决定是否继续) | |
| check-version: | |
| runs-on: ubuntu-24.04 | |
| outputs: | |
| publish: ${{ steps.check.outputs.publish }} | |
| version: ${{ steps.check.outputs.version }} | |
| steps: | |
| - uses: actions/checkout@v4 | |
| - name: Check if should publish | |
| id: check | |
| run: | | |
| version=$(jq -r '.version' cli/package.json) | |
| name=$(jq -r '.name' cli/package.json) | |
| npm_version=$(npm view "$name" version --registry https://registry.npmjs.org/ 2>/dev/null || echo "") | |
| if [[ "$version" != "$npm_version" ]]; then | |
| echo "Version $version not published to npm, will publish" | |
| echo "publish=true" >> "$GITHUB_OUTPUT" | |
| echo "version=$version" >> "$GITHUB_OUTPUT" | |
| else | |
| echo "Version $version already published to npm, skipping" | |
| echo "publish=false" >> "$GITHUB_OUTPUT" | |
| fi | |
| # 2. 先发布架构包(用户安装主包时 optionalDependencies 已就绪) | |
| release-cli-napi: | |
| needs: check-version | |
| if: needs.check-version.outputs.publish == 'true' | |
| uses: ./.github/workflows/release-cli-napi.yml | |
| with: | |
| version: ${{ needs.check-version.outputs.version }} | |
| secrets: inherit | |
| # 3. 架构包就绪后,发布主包到 npm | |
| publish-cli: | |
| needs: [check-version, release-cli-napi] | |
| if: needs.check-version.outputs.publish == 'true' | |
| runs-on: ubuntu-24.04 | |
| steps: | |
| - uses: actions/checkout@v4 | |
| with: | |
| token: ${{ secrets.GH_PAT }} | |
| - name: Setup pnpm | |
| uses: pnpm/action-setup@v4 | |
| - name: Setup Node | |
| uses: actions/setup-node@v4 | |
| with: | |
| node-version: 25 | |
| registry-url: https://registry.npmjs.org/ | |
| cache: 'pnpm' | |
| - name: Get pnpm store directory | |
| id: pnpm-cache | |
| run: echo "STORE_PATH=$(pnpm store path)" >> $GITHUB_OUTPUT | |
| - uses: actions/cache@v4 | |
| name: Setup pnpm store cache | |
| with: | |
| path: ${{ steps.pnpm-cache.outputs.STORE_PATH }} | |
| key: ${{ runner.os }}-pnpm-store-${{ hashFiles('**/pnpm-lock.yaml') }} | |
| restore-keys: | | |
| ${{ runner.os }}-pnpm-store- | |
| - name: Install & Build | |
| run: | | |
| pnpm install --frozen-lockfile --ignore-scripts | |
| pnpm exec turbo run build --filter=@truenine/memory-sync-cli... | |
| - name: Publish to npm | |
| working-directory: ./cli | |
| run: pnpm publish --access public --no-git-checks | |
| env: | |
| NODE_AUTH_TOKEN: ${{ secrets.NPM_TOKEN }} | |
| # 4. 构建 CLI 独立二进制(仅 artifact,不发 Release) | |
| release-cli-binary: | |
| needs: [check-version, release-cli-napi] | |
| if: needs.check-version.outputs.publish == 'true' | |
| uses: ./.github/workflows/release-cli-binary.yml | |
| with: | |
| version: ${{ needs.check-version.outputs.version }} | |
| secrets: inherit | |
| # 5. 构建 GUI 并创建 GitHub Release | |
| release-gui: | |
| needs: check-version | |
| if: needs.check-version.outputs.publish == 'true' | |
| uses: ./.github/workflows/release-gui.yml | |
| with: | |
| version: ${{ needs.check-version.outputs.version }} | |
| secrets: inherit |