|
1 | | -name: Pre-release CI |
| 1 | +name: Release CI |
2 | 2 |
|
3 | 3 | on: |
4 | 4 | push: |
|
9 | 9 |
|
10 | 10 | jobs: |
11 | 11 | build: |
12 | | - runs-on: macOS-13 # 如果用了electron,记得改成 macOS-latest |
13 | | - |
| 12 | + runs-on: macos-latest # 如果用了electron,记得改成 macOS-latest |
14 | 13 | permissions: |
15 | 14 | contents: write |
| 15 | + pull-requests: write |
| 16 | + id-token: write |
16 | 17 |
|
17 | 18 | strategy: |
18 | 19 | matrix: |
19 | | - node-version: [18.x] |
| 20 | + node-version: [20.x] |
20 | 21 | # See supported Node.js release schedule at https://nodejs.org/en/about/releases/ |
21 | 22 |
|
22 | 23 | steps: |
23 | 24 | - uses: actions/checkout@v3 |
| 25 | + - run: | |
| 26 | + git config user.name ${{ github.actor }} |
| 27 | + git config user.email ${{ github.actor }}@users.noreply.github.com |
| 28 | +
|
24 | 29 | - name: Use Node.js ${{ matrix.node-version }} |
25 | | - uses: actions/setup-node@v3 |
| 30 | + uses: actions/setup-node@v4 |
26 | 31 | with: |
27 | 32 | node-version: ${{ matrix.node-version }} |
28 | 33 | cache: 'npm' |
29 | 34 | cache-dependency-path: './common/config/rush/pnpm-lock.yaml' |
| 35 | + registry-url: 'https://registry.npmjs.org' |
| 36 | + |
| 37 | + - name: Ensure npm >= 11.5.1 (conditional) |
| 38 | + run: | |
| 39 | + set -e |
| 40 | + NPMV=$(npm -v) |
| 41 | + echo "Current npm version: $NPMV" |
| 42 | + REQ_MAJOR=11 |
| 43 | + REQ_MINOR=5 |
| 44 | + REQ_PATCH=1 |
| 45 | + MAJOR=${NPMV%%.*} |
| 46 | + REST=${NPMV#*.} |
| 47 | + MINOR=${REST%%.*} |
| 48 | + PATCH=${REST#*.} |
| 49 | + needs_upgrade=false |
| 50 | + if [ "$MAJOR" -lt "$REQ_MAJOR" ]; then |
| 51 | + needs_upgrade=true |
| 52 | + elif [ "$MAJOR" -eq "$REQ_MAJOR" ]; then |
| 53 | + if [ "$MINOR" -lt "$REQ_MINOR" ]; then |
| 54 | + needs_upgrade=true |
| 55 | + elif [ "$MINOR" -eq "$REQ_MINOR" ] && [ "$PATCH" -lt "$REQ_PATCH" ]; then |
| 56 | + needs_upgrade=true |
| 57 | + fi |
| 58 | + fi |
| 59 | + if [ "$needs_upgrade" = true ]; then |
| 60 | + echo "npm < 11.5.1 detected, installing pinned npm@11.5.1 for Trusted Publishing" |
| 61 | + npm install -g npm@11.5.1 |
| 62 | + echo "npm upgraded to: $(npm -v)" |
| 63 | + else |
| 64 | + echo "npm version satisfies requirement (>= 11.5.1)" |
| 65 | + fi |
| 66 | +
|
| 67 | + - name: Print All Github Environment Variables |
| 68 | + run: env |
30 | 69 |
|
31 | | - # Install rush |
| 70 | + # Install rush |
| 71 | + - name: Install native deps for node-canvas (macOS) |
| 72 | + if: runner.os == 'macOS' |
| 73 | + run: | |
| 74 | + brew update |
| 75 | + brew install pkg-config cairo pango libpng jpeg giflib librsvg |
| 76 | + - name: Install native deps for node-canvas (Linux) |
| 77 | + if: runner.os == 'Linux' |
| 78 | + run: | |
| 79 | + sudo apt-get update |
| 80 | + sudo apt-get install -y build-essential pkg-config libcairo2-dev libpango1.0-dev libpng-dev libjpeg-dev libgif-dev librsvg2-dev |
32 | 81 | - name: Install rush |
33 | 82 | run: node common/scripts/install-run-rush.js install --bypass-policy |
34 | 83 |
|
35 | | - - name: Parse semver version from branch name |
36 | | - id: semver_parser |
| 84 | + - name: Parse semver for release |
| 85 | + if: startsWith(github.ref_name, 'release/') |
| 86 | + id: semver_release |
| 87 | + uses: xile611/read-package-version-action@main |
| 88 | + with: |
| 89 | + path: packages/vrender |
| 90 | + semver_string: ${{ github.ref_name }} |
| 91 | + semver_pattern: '^release/(.*)$' |
| 92 | + |
| 93 | + - name: Parse semver for hotfix |
| 94 | + if: startsWith(github.ref_name, 'hotfix/') |
| 95 | + id: semver_hotfix |
| 96 | + uses: xile611/read-package-version-action@main |
| 97 | + with: |
| 98 | + path: packages/vrender |
| 99 | + semver_string: ${{ github.ref_name }} |
| 100 | + semver_pattern: '^hotfix/(.*)$' |
| 101 | + |
| 102 | + - name: Parse semver for pre-release |
| 103 | + if: startsWith(github.ref_name, 'pre-release/') |
| 104 | + id: semver_prerelease |
37 | 105 | uses: xile611/read-package-version-action@main |
38 | 106 | with: |
39 | 107 | path: packages/vrender |
40 | 108 | semver_string: ${{ github.ref_name }} |
41 | | - semver_pattern: '^pre-release/(.*)$' # ^v?(.*)$ by default |
| 109 | + semver_pattern: '^pre-release/(.*)$' |
| 110 | + |
| 111 | + - name: update nextBump of version policies (release) |
| 112 | + if: startsWith(github.ref_name, 'release/') |
| 113 | + uses: xile611/set-next-bump-of-rush@main |
| 114 | + with: |
| 115 | + release_version: ${{ steps.semver_release.outputs.full }} |
| 116 | + write_next_bump: true |
| 117 | + |
| 118 | + - name: update nextBump of version policies (hotfix) |
| 119 | + if: startsWith(github.ref_name, 'hotfix/') |
| 120 | + uses: xile611/set-next-bump-of-rush@main |
| 121 | + with: |
| 122 | + release_version: ${{ steps.semver_hotfix.outputs.full }} |
| 123 | + write_next_bump: true |
| 124 | + |
| 125 | + - name: Update version |
| 126 | + if: startsWith(github.ref_name, 'release/') || startsWith(github.ref_name, 'hotfix/') |
| 127 | + run: node common/scripts/install-run-rush.js version --bump |
| 128 | + |
| 129 | + - name: Build vrender-core |
| 130 | + if: startsWith(github.ref_name, 'release/') || startsWith(github.ref_name, 'hotfix/') |
| 131 | + run: node common/scripts/install-run-rush.js build --only @visactor/vrender-core |
| 132 | + |
| 133 | + - name: Build vrender-kits |
| 134 | + if: startsWith(github.ref_name, 'release/') || startsWith(github.ref_name, 'hotfix/') |
| 135 | + run: node common/scripts/install-run-rush.js build --only @visactor/vrender-kits |
| 136 | + |
| 137 | + - name: Build vrender-animate |
| 138 | + if: startsWith(github.ref_name, 'release/') || startsWith(github.ref_name, 'hotfix/') |
| 139 | + run: node common/scripts/install-run-rush.js build --only @visactor/vrender-animate |
| 140 | + |
| 141 | + - name: Build vrender-components |
| 142 | + if: startsWith(github.ref_name, 'release/') || startsWith(github.ref_name, 'hotfix/') |
| 143 | + run: node common/scripts/install-run-rush.js build --only @visactor/vrender-components |
| 144 | + |
| 145 | + - name: Build vrender |
| 146 | + if: startsWith(github.ref_name, 'release/') || startsWith(github.ref_name, 'hotfix/') |
| 147 | + run: node common/scripts/install-run-rush.js build --only @visactor/vrender |
| 148 | + |
| 149 | + - name: Build bugserver |
| 150 | + if: startsWith(github.ref_name, 'release/') || startsWith(github.ref_name, 'hotfix/') |
| 151 | + run: node common/scripts/install-run-rush.js build --only @internal/bugserver-trigger |
| 152 | + |
| 153 | + # - name: Run CI |
| 154 | + # working-directory: ./tools/bugserver-trigger |
| 155 | + # env: |
| 156 | + # BUG_SERVER_TOKEN: ${{ secrets.BUG_SERVER_TOKEN }} |
| 157 | + # run: node ../../common/scripts/install-run-rushx.js ci -t @internal/bugserver-trigger |
| 158 | + |
| 159 | + - name: Build react-vrender |
| 160 | + if: startsWith(github.ref_name, 'release/') || startsWith(github.ref_name, 'hotfix/') |
| 161 | + run: node common/scripts/install-run-rush.js build --only @visactor/react-vrender |
| 162 | + |
| 163 | + - name: Build react-vrender-utils |
| 164 | + if: startsWith(github.ref_name, 'release/') || startsWith(github.ref_name, 'hotfix/') |
| 165 | + run: node common/scripts/install-run-rush.js build --only @visactor/react-vrender-utils |
42 | 166 |
|
43 | 167 | - name: Apply prereleaseName |
44 | | - run: node common/scripts/apply-prerelease-version.js ${{ steps.semver_parser.outputs.pre_release_name }} ${{ steps.semver_parser.outputs.main }} |
| 168 | + if: startsWith(github.ref_name, 'pre-release/') |
| 169 | + run: node common/scripts/apply-prerelease-version.js ${{ steps.semver_prerelease.outputs.pre_release_name }} ${{ steps.semver_prerelease.outputs.main }} |
45 | 170 |
|
46 | | - - name: Build packages |
| 171 | + - name: Build packages (pre-release) |
| 172 | + if: startsWith(github.ref_name, 'pre-release/') |
47 | 173 | run: node common/scripts/install-run-rush.js build --only tag:package |
48 | 174 |
|
49 | | - - name: Publish to npm |
50 | | - env: |
51 | | - NODE_AUTH_TOKEN: ${{secrets.NPM_TOKEN}} |
52 | | - NPM_AUTH_TOKEN: ${{secrets.NPM_TOKEN}} |
53 | | - run: node common/scripts/install-run-rush.js publish --publish --include-all --tag ${{ steps.semver_parser.outputs.pre_release_type }} |
| 175 | + - name: Publish to npm (release) |
| 176 | + if: startsWith(github.ref_name, 'release/') |
| 177 | + run: node common/scripts/install-run-rush.js publish --publish --include-all --tag latest |
| 178 | + |
| 179 | + - name: Publish to npm (hotfix) |
| 180 | + if: startsWith(github.ref_name, 'hotfix/') |
| 181 | + run: node common/scripts/install-run-rush.js publish --publish --include-all --tag hotfix |
| 182 | + |
| 183 | + - name: Publish to npm (pre-release) |
| 184 | + if: startsWith(github.ref_name, 'pre-release/') |
| 185 | + run: node common/scripts/install-run-rush.js publish --publish --include-all --tag ${{ steps.semver_prerelease.outputs.pre_release_type }} |
54 | 186 |
|
55 | 187 | - name: Update shrinkwrap |
56 | 188 | run: node common/scripts/install-run-rush.js update |
57 | 189 |
|
58 | | - - name: Get npm version |
| 190 | + - name: Get npm version (release/hotfix) |
| 191 | + if: startsWith(github.ref_name, 'release/') || startsWith(github.ref_name, 'hotfix/') |
59 | 192 | id: package-version |
| 193 | + uses: xile611/read-package-version-action@v2.1 |
| 194 | + with: |
| 195 | + path: packages/vrender |
| 196 | + |
| 197 | + - name: Get npm version (pre-release) |
| 198 | + if: startsWith(github.ref_name, 'pre-release/') |
| 199 | + id: package-version-pre |
60 | 200 | uses: xile611/read-package-version-action@main |
61 | 201 | with: |
62 | 202 | path: packages/vrender |
63 | 203 |
|
64 | | - - name: Commit & Push changes |
| 204 | + - name: Disable git hooks for CI (release/hotfix) |
| 205 | + if: startsWith(github.ref_name, 'release/') || startsWith(github.ref_name, 'hotfix/') |
| 206 | + run: git config core.hooksPath /dev/null |
| 207 | + - name: Commit & Push changes (release/hotfix) |
| 208 | + if: startsWith(github.ref_name, 'release/') || startsWith(github.ref_name, 'hotfix/') |
65 | 209 | uses: actions-js/push@master |
| 210 | + env: |
| 211 | + HUSKY: 0 |
66 | 212 | with: |
67 | 213 | github_token: ${{ secrets.GITHUB_TOKEN }} |
68 | 214 | message: 'build: prelease version ${{ steps.package-version.outputs.current_version }}' |
69 | 215 | branch: ${{ github.ref_name }} |
| 216 | + |
| 217 | + - name: Disable git hooks for CI (pre-release) |
| 218 | + if: startsWith(github.ref_name, 'pre-release/') |
| 219 | + run: git config core.hooksPath /dev/null |
| 220 | + - name: Commit & Push changes (pre-release) |
| 221 | + if: startsWith(github.ref_name, 'pre-release/') |
| 222 | + uses: actions-js/push@master |
| 223 | + env: |
| 224 | + HUSKY: 0 |
| 225 | + with: |
| 226 | + github_token: ${{ secrets.GITHUB_TOKEN }} |
| 227 | + message: 'build: prelease version ${{ steps.package-version-pre.outputs.current_version }}' |
| 228 | + branch: ${{ github.ref_name }} |
70 | 229 | author_name: ${{ github.actor }} |
| 230 | + |
| 231 | + - name: Collect changelog of rush |
| 232 | + if: startsWith(github.ref_name, 'release/') || startsWith(github.ref_name, 'hotfix/') |
| 233 | + uses: xile611/collect-rush-changlog@main |
| 234 | + id: changelog |
| 235 | + with: |
| 236 | + version: ${{ steps.package-version.outputs.current_version }} |
| 237 | + |
| 238 | + - name: Create Release for Tag (release) |
| 239 | + if: startsWith(github.ref_name, 'release/') |
| 240 | + id: release_tag |
| 241 | + uses: ncipollo/release-action@v1.12.0 |
| 242 | + env: |
| 243 | + GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} |
| 244 | + with: |
| 245 | + tag: v${{ steps.package-version.outputs.current_version }} |
| 246 | + commit: main |
| 247 | + prerelease: false |
| 248 | + body: | |
| 249 | + ${{ steps.changelog.outputs.markdown }} |
| 250 | + draft: true |
| 251 | + |
| 252 | + - name: Create Release for Tag (hotfix) |
| 253 | + if: startsWith(github.ref_name, 'hotfix/') |
| 254 | + id: release_tag_hotfix |
| 255 | + uses: ncipollo/release-action@v1.12.0 |
| 256 | + env: |
| 257 | + GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} |
| 258 | + with: |
| 259 | + tag: v${{ steps.package-version.outputs.current_version }} |
| 260 | + commit: ${{ github.ref_name }} |
| 261 | + prerelease: false |
| 262 | + body: | |
| 263 | + ${{ steps.changelog.outputs.markdown }} |
| 264 | + draft: true |
| 265 | + |
| 266 | + - name: Create Pull Request |
| 267 | + if: startsWith(github.ref_name, 'release/') |
| 268 | + uses: dustinirving/create-pr@v1.0.2 |
| 269 | + with: |
| 270 | + token: ${{ secrets.GITHUB_TOKEN }} |
| 271 | + title: '[Auto release] release ${{ steps.package-version.outputs.current_version }}' |
| 272 | + base: main |
| 273 | + head: ${{ github.ref_name }} |
| 274 | + labels: release |
| 275 | + reviewers: xile611 |
| 276 | + body: | |
| 277 | + ${{ steps.changelog.outputs.markdown }} |
0 commit comments