11name : Release
22
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
424
525concurrency : ${{ github.workflow }}-${{ github.ref }}
626
1030
1131jobs :
1232 release :
13- name : Release
33+ name : ${{ github.event.inputs.release_type == 'alpha' && 'Alpha Release' || 'Production Release' }}
1434 runs-on : ubuntu-latest
1535 permissions :
1636 contents : write
2141 steps :
2242 - name : ⬇️ Checkout Repository
2343 uses : actions/checkout@8e8c483db84b4bee98b60c0593521ed34d9990e8 # v6.0.1
44+ with :
45+ fetch-depth : 0
2446
2547 - name : 🔧 Setup Git
2648 run : |
@@ -39,12 +61,64 @@ jobs:
3961 - name : 🧩 Install Dependencies
4062 run : pnpm pnpm.install.workaround
4163
42- - 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'
43116 id : build-the-mono-repo
44117 run : |
45118 pnpm build
46119
47120 - name : 📣 Create Release Pull Request or Publish to npm
121+ if : github.event.inputs.release_type == 'production'
48122 id : changesets
49123 uses : changesets/action@e0145edc7d9d8679003495b11f87bd8ef63c0cba # v1.5.3
50124 with :
0 commit comments