|
6 | 6 | - "v*" |
7 | 7 |
|
8 | 8 | workflow_dispatch: |
| 9 | + inputs: |
| 10 | + version: |
| 11 | + description: 输入您将要发布的版本号(默认使用 packages/fluent-editor/package.json 中的版本号),例如:`0.1.0`。 |
| 12 | + required: false |
| 13 | + type: string |
9 | 14 |
|
10 | 15 | jobs: |
11 | 16 | build: |
12 | 17 | runs-on: ubuntu-latest |
| 18 | + outputs: |
| 19 | + version: ${{ steps.ver.outputs.value }} |
13 | 20 | steps: |
14 | 21 | - name: CheckOut Code |
15 | 22 | uses: actions/checkout@master |
@@ -39,31 +46,72 @@ jobs: |
39 | 46 | ${{ runner.os }}-pnpm-store- |
40 | 47 | - name: Install dependencies |
41 | 48 | run: pnpm i --no-frozen-lockfile |
| 49 | + - name: Get version |
| 50 | + id: ver |
| 51 | + run: | |
| 52 | + # 优先用手动输入的版本号 |
| 53 | + if [ -n "${{ inputs.version }}" ]; then |
| 54 | + VERSION="${{ inputs.version }}" |
| 55 | + else |
| 56 | + VERSION="$(node -p "require('./packages/fluent-editor/package.json').version")" |
| 57 | + fi |
| 58 | + echo "version: $VERSION" |
| 59 | + echo "value=$VERSION" >> $GITHUB_OUTPUT |
42 | 60 |
|
43 | | - - name: Run Build search-box |
44 | | - run: pnpm build:lib |
| 61 | + - name: Build lib |
| 62 | + run: | |
| 63 | + pnpm build:lib |
| 64 | + cd packages/fluent-editor |
| 65 | + echo "version: ${{ steps.ver.outputs.value }}" |
| 66 | + pnpm pre-release -v ${{ steps.ver.outputs.value }} |
| 67 | + - name: Upload build artifact |
| 68 | + uses: actions/upload-artifact@v4 |
| 69 | + with: |
| 70 | + name: dist-artifact |
| 71 | + path: packages/fluent-editor/dist/ |
| 72 | + # Publish job |
| 73 | + publish: |
| 74 | + needs: build |
| 75 | + runs-on: ubuntu-latest |
| 76 | + steps: |
| 77 | + - name: Download build artifact |
| 78 | + uses: actions/download-artifact@v4 |
| 79 | + with: |
| 80 | + name: dist-artifact |
| 81 | + path: packages/fluent-editor/dist/ |
45 | 82 |
|
46 | | - - name: Parse Publish tag |
47 | | - id: parse_tag |
| 83 | + - name: Parse Publish version |
| 84 | + id: parse_version |
48 | 85 | run: | |
49 | | - tag_name="${GITHUB_REF#refs/tags/}" |
50 | | - if [[ "$tag_name" == *alpha* ]]; then |
| 86 | + version_name="${{ needs.build.outputs.version }}" |
| 87 | + if [[ "$version_name" == *alpha* ]]; then |
51 | 88 | echo "dist_tag=alpha" >> "$GITHUB_OUTPUT" |
52 | | - elif [[ "$tag_name" == *beta* ]]; then |
| 89 | + elif [[ "$version_name" == *beta* ]]; then |
53 | 90 | echo "dist_tag=beta" >> "$GITHUB_OUTPUT" |
54 | | - elif [[ "$tag_name" == *rc* ]]; then |
| 91 | + elif [[ "$version_name" == *rc* ]]; then |
55 | 92 | echo "dist_tag=rc" >> "$GITHUB_OUTPUT" |
56 | 93 | else |
57 | 94 | echo "dist_tag=latest" >> "$GITHUB_OUTPUT" |
58 | 95 | fi |
59 | | -
|
| 96 | + - name: Show tag |
| 97 | + run: | |
| 98 | + echo "publish tag: ${{ steps.parse_version.outputs.dist_tag }}" |
60 | 99 | - name: Publish @opentiny/fluent-editor |
61 | | - run: pnpm pub |
| 100 | + run: | |
| 101 | + echo "ls" |
| 102 | + ls |
| 103 | + cd packages/fluent-editor/dist |
| 104 | + ls |
| 105 | + if [ ${{ steps.parse_version.outputs.dist_tag }} == 'latest' ]; then |
| 106 | + npm publish |
| 107 | + else |
| 108 | + npm publish --tag ${{ steps.parse_version.outputs.dist_tag }} |
| 109 | + fi |
62 | 110 | env: |
63 | 111 | NODE_AUTH_TOKEN: ${{ secrets.NPM_TOKEN }} |
64 | 112 |
|
65 | 113 | - name: Release |
66 | | - if: ${{ steps.parse_tag.outputs.dist_tag == 'latest' }} |
| 114 | + if: ${{ steps.parse_version.outputs.dist_tag == 'latest' }} |
67 | 115 | uses: softprops/action-gh-release@v1 |
68 | 116 | with: |
69 | 117 | tag_name: ${{ github.ref_name }} |
|
0 commit comments