77 - opened
88 - reopened
99 - synchronize
10+ workflow_dispatch :
11+ inputs :
12+ package :
13+ description : ' Package to release'
14+ required : true
15+ type : choice
16+ options :
17+ - js-sdk
18+ - python-sdk
19+ - cli
20+ tag :
21+ description : ' Dist-tag (e.g. rc, beta, snapshot)'
22+ required : true
23+ type : string
24+ preid :
25+ description : ' Prerelease identifier (defaults to branch name if empty)'
26+ required : false
27+ default : ' '
28+ type : string
1029
1130permissions :
1231 contents : write
@@ -16,11 +35,26 @@ jobs:
1635 name : Release Candidate
1736 runs-on : ubuntu-latest
1837
38+ env :
39+ IS_JS : ${{ contains(github.event.pull_request.labels.*.name, 'js-rc') || (github.event_name == 'workflow_dispatch' && github.event.inputs.package == 'js-sdk') }}
40+ IS_CLI : ${{ contains(github.event.pull_request.labels.*.name, 'cli-rc') || (github.event_name == 'workflow_dispatch' && github.event.inputs.package == 'cli') }}
41+ IS_PYTHON : ${{ contains(github.event.pull_request.labels.*.name, 'python-rc') || (github.event_name == 'workflow_dispatch' && github.event.inputs.package == 'python-sdk') }}
42+ PUBLISH_TAG : ${{ github.event.inputs.tag || 'rc' }}
43+ PREID : ${{ github.event.inputs.preid || github.head_ref || github.ref_name }}
44+
1945 steps :
46+ - name : Block production tags
47+ if : ${{ github.event_name == 'workflow_dispatch' }}
48+ run : |
49+ if [ "${{ github.event.inputs.tag }}" = "latest" ]; then
50+ echo "::error::Publishing with the 'latest' tag is not allowed from this workflow. Use the Release workflow instead."
51+ exit 1
52+ fi
53+
2054 - name : Checkout Repo
2155 uses : actions/checkout@v4
2256 with :
23- ref : ${{ github.head_ref }}
57+ ref : ${{ github.head_ref || github.ref }}
2458
2559 - name : Parse .tool-versions
2660 uses : wistia/parse-tool-versions@v2.1.1
@@ -30,41 +64,41 @@ jobs:
3064 prefix : ' tool_version_'
3165
3266 - 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') }}
67+ if : ${{ env.IS_JS == 'true' || env.IS_CLI == 'true' }}
3468 with :
3569 version : ' ${{ env.TOOL_VERSION_PNPM }}'
3670
3771 - name : Setup Node.js
3872 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') }}
73+ if : ${{ env.IS_JS == 'true' || env.IS_CLI == 'true' || env.IS_PYTHON == 'true' }}
4074 with :
4175 node-version : ' ${{ env.TOOL_VERSION_NODEJS }}'
4276 registry-url : https://registry.npmjs.org
4377 cache : pnpm
4478
4579 - name : Configure pnpm
46- if : ${{ contains( github.event.pull_request.labels.*.name, 'js-rc') || contains( github.event.pull_request.labels.*.name, 'cli-rc') }}
80+ if : ${{ env.IS_JS == 'true' || env.IS_CLI == 'true' }}
4781 run : |
4882 pnpm config set auto-install-peers true
4983 pnpm config set exclude-links-from-lockfile true
5084
5185 - name : Set up Python
5286 uses : actions/setup-python@v4
53- if : ${{ contains( github.event.pull_request.labels.*.name, 'python-rc') }}
87+ if : ${{ env.IS_PYTHON == 'true' }}
5488 with :
5589 python-version : ' ${{ env.TOOL_VERSION_PYTHON }}'
5690
5791 - name : Install and configure Poetry
5892 uses : snok/install-poetry@v1
59- if : ${{ contains( github.event.pull_request.labels.*.name, 'python-rc') }}
93+ if : ${{ env.IS_PYTHON == 'true' }}
6094 with :
6195 version : ' ${{ env.TOOL_VERSION_POETRY }}'
6296 virtualenvs-create : true
6397 virtualenvs-in-project : true
6498 installer-parallel : true
6599
66100 - name : Test Python SDK
67- if : ${{ contains( github.event.pull_request.labels.*.name, 'python-rc') }}
101+ if : ${{ env.IS_PYTHON == 'true' }}
68102 working-directory : packages/python-sdk
69103 run : |
70104 poetry install
73107 E2B_API_KEY : ${{ secrets.E2B_API_KEY }}
74108
75109 - name : Release Candidate
76- if : ${{ contains( github.event.pull_request.labels.*.name, 'python-rc') }}
110+ if : ${{ env.IS_PYTHON == 'true' }}
77111 working-directory : packages/python-sdk
78112 run : |
79113 poetry version prerelease
@@ -83,43 +117,43 @@ jobs:
83117 PYPI_TOKEN : ${{ secrets.PYPI_TOKEN }}
84118
85119 - name : Install JS dependencies
86- if : ${{ contains( github.event.pull_request.labels.*.name, 'js-rc') || contains( github.event.pull_request.labels.*.name, 'cli-rc') }}
120+ if : ${{ env.IS_JS == 'true' || env.IS_CLI == 'true' }}
87121 run : |
88122 pnpm install --frozen-lockfile
89123
90124 - name : Test JS SDK
91125 working-directory : packages/js-sdk
92- if : ${{ contains( github.event.pull_request.labels.*.name, 'js-rc') }}
126+ if : ${{ env.IS_JS == 'true' }}
93127 run : |
94128 pnpm run test
95129 env :
96130 E2B_API_KEY : ${{ secrets.E2B_API_KEY }}
97131
98132 - name : Release JS Candidate
99133 working-directory : packages/js-sdk
100- if : ${{ contains( github.event.pull_request.labels.*.name, 'js-rc') }}
134+ if : ${{ env.IS_JS == 'true' }}
101135 run : |
102- npm version prerelease --preid=${{ github.head_ref }}
103- npm publish --tag rc
136+ npm version prerelease --preid=${{ env.PREID }}
137+ npm publish --tag ${{ env.PUBLISH_TAG }}
104138 env :
105139 NODE_AUTH_TOKEN : ${{ secrets.NPM_TOKEN }}
106140
107141 - name : Install dependencies
108- if : ${{ contains( github.event.pull_request.labels.*.name, 'js-rc') || contains( github.event.pull_request.labels.*.name, 'cli-rc') }}
142+ if : ${{ env.IS_JS == 'true' || env.IS_CLI == 'true' }}
109143 run : |
110144 pnpm install --frozen-lockfile
111145
112146 - name : Release CLI Candidate
113147 working-directory : packages/cli
114- if : ${{ contains( github.event.pull_request.labels.*.name, 'cli-rc') }}
148+ if : ${{ env.IS_CLI == 'true' }}
115149 run : |
116- npm version prerelease --preid=${{ github.head_ref }}
117- npm publish --tag rc
150+ npm version prerelease --preid=${{ env.PREID }}
151+ npm publish --tag ${{ env.PUBLISH_TAG }}
118152 env :
119153 NODE_AUTH_TOKEN : ${{ secrets.NPM_TOKEN }}
120154
121155 - 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') }}
156+ if : ${{ env.IS_JS == 'true' || env.IS_CLI == 'true' || env.IS_PYTHON == 'true' }}
123157 run : |
124158 git config user.name "github-actions[bot]"
125159 git config user.email "github-actions[bot]@users.noreply.github.com"
0 commit comments