77 - opened
88 - reopened
99 - synchronize
10+ workflow_dispatch :
11+ inputs :
12+ js-sdk :
13+ description : ' Release JS SDK'
14+ required : false
15+ default : false
16+ type : boolean
17+ python-sdk :
18+ description : ' Release Python SDK'
19+ required : false
20+ default : false
21+ type : boolean
22+ cli :
23+ description : ' Release CLI'
24+ required : false
25+ default : false
26+ type : boolean
27+ tag :
28+ description : ' Dist-tag (e.g. rc, beta, snapshot)'
29+ required : true
30+ type : string
31+ preid :
32+ description : ' Prerelease identifier (defaults to branch name if empty)'
33+ required : false
34+ default : ' '
35+ type : string
1036
1137permissions :
1238 contents : write
@@ -16,11 +42,30 @@ jobs:
1642 name : Release Candidate
1743 runs-on : ubuntu-latest
1844
45+ env :
46+ IS_JS : ${{ contains(github.event.pull_request.labels.*.name, 'js-rc') || (github.event_name == 'workflow_dispatch' && github.event.inputs.js-sdk == 'true') }}
47+ IS_CLI : ${{ contains(github.event.pull_request.labels.*.name, 'cli-rc') || (github.event_name == 'workflow_dispatch' && github.event.inputs.cli == 'true') }}
48+ IS_PYTHON : ${{ contains(github.event.pull_request.labels.*.name, 'python-rc') || (github.event_name == 'workflow_dispatch' && github.event.inputs.python-sdk == 'true') }}
49+ PUBLISH_TAG : ${{ github.event.inputs.tag || 'rc' }}
50+
1951 steps :
52+ - name : Sanitize preid
53+ run : |
54+ RAW_PREID="${{ github.event.inputs.preid || github.head_ref || github.ref_name }}"
55+ echo "PREID=$(echo "$RAW_PREID" | sed 's/[^0-9A-Za-z-]/-/g')" >> "$GITHUB_ENV"
56+
57+ - name : Block production tags
58+ if : ${{ github.event_name == 'workflow_dispatch' }}
59+ run : |
60+ if [ "${{ github.event.inputs.tag }}" = "latest" ]; then
61+ echo "::error::Publishing with the 'latest' tag is not allowed from this workflow. Use the Release workflow instead."
62+ exit 1
63+ fi
64+
2065 - name : Checkout Repo
2166 uses : actions/checkout@v4
2267 with :
23- ref : ${{ github.head_ref }}
68+ ref : ${{ github.head_ref || github.ref }}
2469
2570 - name : Parse .tool-versions
2671 uses : wistia/parse-tool-versions@v2.1.1
@@ -30,41 +75,41 @@ jobs:
3075 prefix : ' tool_version_'
3176
3277 - uses : pnpm/action-setup@v4
33- if : ${{ contains( github.event.pull_request.labels.*.name, 'js-rc') || contains( github.event.pull_request.labels.*.name, 'cli-rc') }}
78+ if : ${{ env.IS_JS == 'true' || env.IS_CLI == 'true' }}
3479 with :
3580 version : ' ${{ env.TOOL_VERSION_PNPM }}'
3681
3782 - name : Setup Node.js
3883 uses : actions/setup-node@v4
39- if : ${{ contains( github.event.pull_request.labels.*.name, 'js-rc') || contains( github.event.pull_request.labels.*.name, 'cli-rc') || contains( github.event.pull_request.labels.*.name, 'python-rc') }}
84+ if : ${{ env.IS_JS == 'true' || env.IS_CLI == 'true' || env.IS_PYTHON == 'true' }}
4085 with :
4186 node-version : ' ${{ env.TOOL_VERSION_NODEJS }}'
4287 registry-url : https://registry.npmjs.org
4388 cache : pnpm
4489
4590 - name : Configure pnpm
46- if : ${{ contains( github.event.pull_request.labels.*.name, 'js-rc') || contains( github.event.pull_request.labels.*.name, 'cli-rc') }}
91+ if : ${{ env.IS_JS == 'true' || env.IS_CLI == 'true' }}
4792 run : |
4893 pnpm config set auto-install-peers true
4994 pnpm config set exclude-links-from-lockfile true
5095
5196 - name : Set up Python
5297 uses : actions/setup-python@v4
53- if : ${{ contains( github.event.pull_request.labels.*.name, 'python-rc') }}
98+ if : ${{ env.IS_PYTHON == 'true' }}
5499 with :
55100 python-version : ' ${{ env.TOOL_VERSION_PYTHON }}'
56101
57102 - name : Install and configure Poetry
58103 uses : snok/install-poetry@v1
59- if : ${{ contains( github.event.pull_request.labels.*.name, 'python-rc') }}
104+ if : ${{ env.IS_PYTHON == 'true' }}
60105 with :
61106 version : ' ${{ env.TOOL_VERSION_POETRY }}'
62107 virtualenvs-create : true
63108 virtualenvs-in-project : true
64109 installer-parallel : true
65110
66111 - name : Test Python SDK
67- if : ${{ contains( github.event.pull_request.labels.*.name, 'python-rc') }}
112+ if : ${{ env.IS_PYTHON == 'true' }}
68113 working-directory : packages/python-sdk
69114 run : |
70115 poetry install
73118 E2B_API_KEY : ${{ secrets.E2B_API_KEY }}
74119
75120 - name : Release Candidate
76- if : ${{ contains( github.event.pull_request.labels.*.name, 'python-rc') }}
121+ if : ${{ env.IS_PYTHON == 'true' }}
77122 working-directory : packages/python-sdk
78123 run : |
79124 poetry version prerelease
@@ -83,43 +128,43 @@ jobs:
83128 PYPI_TOKEN : ${{ secrets.PYPI_TOKEN }}
84129
85130 - name : Install JS dependencies
86- if : ${{ contains( github.event.pull_request.labels.*.name, 'js-rc') || contains( github.event.pull_request.labels.*.name, 'cli-rc') }}
131+ if : ${{ env.IS_JS == 'true' || env.IS_CLI == 'true' }}
87132 run : |
88133 pnpm install --frozen-lockfile
89134
90135 - name : Test JS SDK
91136 working-directory : packages/js-sdk
92- if : ${{ contains( github.event.pull_request.labels.*.name, 'js-rc') }}
137+ if : ${{ env.IS_JS == 'true' }}
93138 run : |
94139 pnpm run test
95140 env :
96141 E2B_API_KEY : ${{ secrets.E2B_API_KEY }}
97142
98143 - name : Release JS Candidate
99144 working-directory : packages/js-sdk
100- if : ${{ contains( github.event.pull_request.labels.*.name, 'js-rc') }}
145+ if : ${{ env.IS_JS == 'true' }}
101146 run : |
102- npm version prerelease --preid=${{ github.head_ref }}
103- npm publish --tag rc
147+ npm version prerelease --preid=${{ env.PREID }}
148+ npm publish --tag ${{ env.PUBLISH_TAG }}
104149 env :
105150 NODE_AUTH_TOKEN : ${{ secrets.NPM_TOKEN }}
106151
107152 - name : Install dependencies
108- if : ${{ contains( github.event.pull_request.labels.*.name, 'js-rc') || contains( github.event.pull_request.labels.*.name, 'cli-rc') }}
153+ if : ${{ env.IS_JS == 'true' || env.IS_CLI == 'true' }}
109154 run : |
110155 pnpm install --frozen-lockfile
111156
112157 - name : Release CLI Candidate
113158 working-directory : packages/cli
114- if : ${{ contains( github.event.pull_request.labels.*.name, 'cli-rc') }}
159+ if : ${{ env.IS_CLI == 'true' }}
115160 run : |
116- npm version prerelease --preid=${{ github.head_ref }}
117- npm publish --tag rc
161+ npm version prerelease --preid=${{ env.PREID }}
162+ npm publish --tag ${{ env.PUBLISH_TAG }}
118163 env :
119164 NODE_AUTH_TOKEN : ${{ secrets.NPM_TOKEN }}
120165
121166 - name : Commit new versions
122- if : ${{ contains( github.event.pull_request.labels.*.name, 'js-rc') || contains( github.event.pull_request.labels.*.name, 'cli-rc') || contains( github.event.pull_request.labels.*.name, 'python-rc') }}
167+ if : ${{ env.IS_JS == 'true' || env.IS_CLI == 'true' || env.IS_PYTHON == 'true' }}
123168 run : |
124169 git config user.name "github-actions[bot]"
125170 git config user.email "github-actions[bot]@users.noreply.github.com"
0 commit comments