|
1 | 1 | name: Release |
2 | 2 |
|
3 | | -on: [workflow_dispatch] |
| 3 | +on: |
| 4 | + workflow_dispatch: |
| 5 | + inputs: |
| 6 | + release_type: |
| 7 | + description: "Select the release type" |
| 8 | + required: true |
| 9 | + default: "production" |
| 10 | + type: choice |
| 11 | + options: |
| 12 | + - production |
| 13 | + - alpha |
| 14 | + package_dir: |
| 15 | + description: "Select the package directory (only for alpha releases)" |
| 16 | + required: false |
| 17 | + default: "packages/visual-service" |
| 18 | + type: choice |
| 19 | + options: |
| 20 | + - packages/ocr-service |
| 21 | + - packages/visual-reporter |
| 22 | + - packages/visual-service |
| 23 | + - packages/webdriver-image-comparison |
4 | 24 |
|
5 | 25 | concurrency: ${{ github.workflow }}-${{ github.ref }} |
6 | 26 |
|
7 | 27 | env: |
8 | 28 | GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} |
9 | | - NPM_TOKEN: ${{ secrets.NPM_TOKEN }} |
10 | 29 | NPM_CONFIG_PROVENANCE: true |
11 | 30 |
|
12 | 31 | jobs: |
13 | 32 | release: |
14 | | - name: Release |
| 33 | + name: ${{ github.event.inputs.release_type == 'alpha' && 'Alpha Release' || 'Production Release' }} |
15 | 34 | runs-on: ubuntu-latest |
16 | 35 | permissions: |
17 | 36 | contents: write |
18 | 37 | packages: write |
19 | 38 | id-token: write |
20 | 39 | pull-requests: write |
21 | 40 |
|
22 | | - strategy: |
23 | | - matrix: |
24 | | - node-version: [20.x] |
25 | | - |
26 | 41 | steps: |
27 | 42 | - name: ⬇️ Checkout Repository |
28 | | - uses: actions/checkout@v4 |
| 43 | + uses: actions/checkout@8e8c483db84b4bee98b60c0593521ed34d9990e8 # v6.0.1 |
| 44 | + with: |
| 45 | + fetch-depth: 0 |
29 | 46 |
|
30 | 47 | - name: 🔧 Setup Git |
31 | 48 | run: | |
32 | 49 | git config --global user.email "[email protected]" |
33 | 50 | git config --global user.name "WebdriverIO Release Bot" |
34 | 51 |
|
35 | 52 | - name: 🔧 Setup pnpm |
36 | | - uses: pnpm/action-setup@v4 |
| 53 | + uses: pnpm/action-setup@41ff72655975bd51cab0327fa583b6e92b6d3061 # v4.2.0 |
37 | 54 |
|
38 | | - - name: 🔧 Setup NPM |
39 | | - run: | |
40 | | - npm set registry "https://registry.npmjs.org/" |
41 | | - npm set //registry.npmjs.org/:_authToken $NPM_TOKEN |
42 | | - npm whoami |
43 | | -
|
44 | | - - name: 🔧 Setup Node.js ${{ matrix.node-version }} |
45 | | - uses: actions/setup-node@v4 |
| 55 | + - name: 🔧 Setup Node.js |
| 56 | + uses: actions/setup-node@395ad3262231945c25e8478fd5baf05154b1d79f # v6.1.0 |
46 | 57 | with: |
47 | | - node-version: ${{ matrix.node-version }} |
| 58 | + node-version-file: ".nvmrc" |
48 | 59 | cache: pnpm |
49 | 60 |
|
50 | 61 | - name: 🧩 Install Dependencies |
51 | 62 | run: pnpm pnpm.install.workaround |
52 | 63 |
|
53 | | - - name: 🏗️ Build |
| 64 | + # ======================================== |
| 65 | + # Alpha Release Steps |
| 66 | + # ======================================== |
| 67 | + - name: 🔄 Validate Package Directory |
| 68 | + if: github.event.inputs.release_type == 'alpha' |
| 69 | + run: | |
| 70 | + if [[ ! "${{ github.event.inputs.package_dir }}" =~ ^packages/[a-zA-Z0-9_-]+$ ]]; then |
| 71 | + echo "Invalid package directory: ${{ github.event.inputs.package_dir }}" |
| 72 | + exit 1 |
| 73 | + fi |
| 74 | + if [[ ! -d "${{ github.event.inputs.package_dir }}" ]]; then |
| 75 | + echo "Package directory does not exist: ${{ github.event.inputs.package_dir }}" |
| 76 | + exit 1 |
| 77 | + fi |
| 78 | +
|
| 79 | + - name: 🏗️ Build the Package (Alpha) |
| 80 | + if: github.event.inputs.release_type == 'alpha' |
| 81 | + run: | |
| 82 | + cd ${{ github.event.inputs.package_dir }} |
| 83 | + pnpm build |
| 84 | +
|
| 85 | + - name: 🔢 Bump Version for Alpha Release |
| 86 | + if: github.event.inputs.release_type == 'alpha' |
| 87 | + run: | |
| 88 | + cd ${{ github.event.inputs.package_dir }} |
| 89 | + npm version prerelease --preid=alpha |
| 90 | +
|
| 91 | + - name: 📦 Commit and Push Version Changes (Alpha) |
| 92 | + if: github.event.inputs.release_type == 'alpha' |
| 93 | + working-directory: ${{ github.event.inputs.package_dir }} |
| 94 | + run: | |
| 95 | + git add package.json |
| 96 | + git commit -m "chore: bump version for alpha release [skip ci]" |
| 97 | + git push origin HEAD |
| 98 | +
|
| 99 | + - name: 🚀 Publish to npm with Alpha Tag |
| 100 | + if: github.event.inputs.release_type == 'alpha' |
| 101 | + run: | |
| 102 | + cd ${{ github.event.inputs.package_dir }} |
| 103 | + npm publish --tag alpha |
| 104 | +
|
| 105 | + - name: 📦 Push Tags to GitHub (Alpha) |
| 106 | + if: github.event.inputs.release_type == 'alpha' |
| 107 | + run: | |
| 108 | + cd ${{ github.event.inputs.package_dir }} |
| 109 | + git push --follow-tags |
| 110 | +
|
| 111 | + # ======================================== |
| 112 | + # Production Release Steps |
| 113 | + # ======================================== |
| 114 | + - name: 🏗️ Build (Production) |
| 115 | + if: github.event.inputs.release_type == 'production' |
54 | 116 | id: build-the-mono-repo |
55 | 117 | run: | |
56 | 118 | pnpm build |
57 | 119 |
|
58 | 120 | - name: 📣 Create Release Pull Request or Publish to npm |
| 121 | + if: github.event.inputs.release_type == 'production' |
59 | 122 | id: changesets |
60 | | - uses: changesets/action@v1 |
| 123 | + uses: changesets/action@e0145edc7d9d8679003495b11f87bd8ef63c0cba # v1.5.3 |
61 | 124 | with: |
62 | 125 | # This expects you to have a script called release which does a build for your packages and calls changeset publish |
63 | 126 | publish: pnpm release |
|
0 commit comments