|
9 | 9 | tags: |
10 | 10 | - 'v*' |
11 | 11 |
|
12 | | -permissions: |
13 | | - contents: write |
14 | | - id-token: write |
15 | | - |
16 | 12 | # 定义工作流中的作业 |
17 | 13 | jobs: |
18 | 14 | build: |
19 | 15 | # 指定运行环境为最新版本的ubuntu |
20 | 16 | runs-on: ubuntu-latest |
| 17 | + permissions: |
| 18 | + contents: read |
| 19 | + outputs: |
| 20 | + dist_tag: ${{ steps.parse_tag.outputs.dist_tag }} |
21 | 21 | steps: |
22 | 22 | # 步骤1: 检出代码 |
23 | 23 | - name: CheckOut Code |
@@ -91,36 +91,104 @@ jobs: |
91 | 91 | exit 1 |
92 | 92 | fi |
93 | 93 |
|
94 | | - # 步骤8: 发布组件到NPM |
| 94 | + # 步骤8: 构建文档 |
| 95 | + - name: Build VitePress |
| 96 | + run: pnpm build:docs --nocomponents |
| 97 | + env: |
| 98 | + VITEPRESS_BASE: /tiny-robot/${{ steps.parse_tag.outputs.dist_tag }}/ |
| 99 | + PLAYGROUND_BASE: /tiny-robot/${{ steps.parse_tag.outputs.dist_tag }}/playground |
| 100 | + |
| 101 | + - name: Verify build output |
| 102 | + run: ls -la ./docs/dist |
| 103 | + |
| 104 | + - name: Upload package artifacts |
| 105 | + uses: actions/upload-artifact@v6 |
| 106 | + with: |
| 107 | + name: package-dist |
| 108 | + path: | |
| 109 | + packages/components/dist |
| 110 | + packages/kit/dist |
| 111 | + packages/svgs/dist |
| 112 | + if-no-files-found: error |
| 113 | + retention-days: 1 |
| 114 | + |
| 115 | + - name: Upload docs artifacts |
| 116 | + uses: actions/upload-artifact@v6 |
| 117 | + with: |
| 118 | + name: docs-dist |
| 119 | + path: docs/dist |
| 120 | + if-no-files-found: error |
| 121 | + retention-days: 1 |
| 122 | + |
| 123 | + publish: |
| 124 | + needs: build |
| 125 | + runs-on: ubuntu-latest |
| 126 | + permissions: |
| 127 | + contents: read |
| 128 | + id-token: write |
| 129 | + steps: |
| 130 | + - name: CheckOut Code |
| 131 | + uses: actions/checkout@v5 |
| 132 | + with: |
| 133 | + ref: ${{ github.ref_name }} |
| 134 | + |
| 135 | + - name: Setup pnpm |
| 136 | + uses: pnpm/action-setup@v5 |
| 137 | + |
| 138 | + - name: Setup Node |
| 139 | + uses: actions/setup-node@v5 |
| 140 | + with: |
| 141 | + node-version: 24 |
| 142 | + package-manager-cache: false |
| 143 | + registry-url: 'https://registry.npmjs.org' |
| 144 | + |
| 145 | + - name: Install publish dependencies |
| 146 | + run: pnpm i --no-frozen-lockfile --ignore-scripts |
| 147 | + |
| 148 | + - name: Download package artifacts |
| 149 | + uses: actions/download-artifact@v7 |
| 150 | + with: |
| 151 | + name: package-dist |
| 152 | + path: ./packages |
| 153 | + |
| 154 | + # 步骤9: 发布组件到NPM |
95 | 155 | - name: Publish components |
96 | | - run: pnpm lerna publish from-package --pre-dist-tag ${{ steps.parse_tag.outputs.dist_tag }} --yes |
| 156 | + run: pnpm lerna publish from-package --pre-dist-tag ${{ needs.build.outputs.dist_tag }} --yes |
97 | 157 |
|
98 | | - # 步骤9: 发布组件到GitHub Release |
| 158 | + release: |
| 159 | + needs: [build, publish] |
| 160 | + if: ${{ needs.build.outputs.dist_tag == 'latest' }} |
| 161 | + runs-on: ubuntu-latest |
| 162 | + permissions: |
| 163 | + contents: read |
| 164 | + steps: |
| 165 | + # 步骤10: 发布组件到GitHub Release |
99 | 166 | - name: Release |
100 | | - if: ${{ steps.parse_tag.outputs.dist_tag == 'latest' }} |
101 | 167 | uses: softprops/action-gh-release@v1 |
102 | 168 | with: |
103 | 169 | tag_name: ${{ github.ref_name }} |
104 | 170 | generate_release_notes: true |
105 | 171 | env: |
106 | 172 | GITHUB_TOKEN: ${{ secrets.RELEASE_TOKEN }} |
107 | 173 |
|
108 | | - # 步骤10: 构建文档 |
109 | | - - name: Build VitePress |
110 | | - run: pnpm build:docs --nocomponents |
111 | | - env: |
112 | | - VITEPRESS_BASE: /tiny-robot/${{steps.parse_tag.outputs.dist_tag}}/ |
113 | | - PLAYGROUND_BASE: /tiny-robot/${{steps.parse_tag.outputs.dist_tag}}/playground |
114 | | - |
115 | | - - name: Verify build output |
116 | | - run: ls -la ./docs/dist |
| 174 | + deploy-docs: |
| 175 | + needs: [build, publish] |
| 176 | + runs-on: ubuntu-latest |
| 177 | + permissions: |
| 178 | + contents: write |
| 179 | + steps: |
| 180 | + - name: Download docs artifacts |
| 181 | + uses: actions/download-artifact@v7 |
| 182 | + with: |
| 183 | + name: docs-dist |
| 184 | + path: ./docs/dist |
117 | 185 |
|
118 | 186 | - name: Deploy docs |
119 | 187 | uses: peaceiris/actions-gh-pages@v3 |
120 | 188 | with: |
121 | 189 | github_token: ${{ secrets.GITHUB_TOKEN }} |
122 | 190 | publish_dir: ./docs/dist |
123 | | - destination_dir: ./${{steps.parse_tag.outputs.dist_tag}}/ |
| 191 | + destination_dir: ./${{ needs.build.outputs.dist_tag }}/ |
124 | 192 | keep_files: true |
125 | 193 | force_orphan: false |
126 | 194 | user_name: 'github-actions[bot]' |
|
0 commit comments