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