Skip to content

Commit 295f3bd

Browse files
committed
chore: allow canary releases
1 parent 59057f5 commit 295f3bd

File tree

1 file changed

+59
-18
lines changed

1 file changed

+59
-18
lines changed

.github/workflows/release_candidates.yml

Lines changed: 59 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,32 @@ on:
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

1137
permissions:
1238
contents: write
@@ -16,11 +42,26 @@ 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+
PREID: ${{ github.event.inputs.preid || github.head_ref || github.ref_name }}
51+
1952
steps:
53+
- name: Block production tags
54+
if: ${{ github.event_name == 'workflow_dispatch' }}
55+
run: |
56+
if [ "${{ github.event.inputs.tag }}" = "latest" ]; then
57+
echo "::error::Publishing with the 'latest' tag is not allowed from this workflow. Use the Release workflow instead."
58+
exit 1
59+
fi
60+
2061
- name: Checkout Repo
2162
uses: actions/checkout@v4
2263
with:
23-
ref: ${{ github.head_ref }}
64+
ref: ${{ github.head_ref || github.ref }}
2465

2566
- name: Parse .tool-versions
2667
uses: wistia/parse-tool-versions@v2.1.1
@@ -30,41 +71,41 @@ jobs:
3071
prefix: 'tool_version_'
3172

3273
- 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') }}
74+
if: ${{ env.IS_JS == 'true' || env.IS_CLI == 'true' }}
3475
with:
3576
version: '${{ env.TOOL_VERSION_PNPM }}'
3677

3778
- name: Setup Node.js
3879
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') }}
80+
if: ${{ env.IS_JS == 'true' || env.IS_CLI == 'true' || env.IS_PYTHON == 'true' }}
4081
with:
4182
node-version: '${{ env.TOOL_VERSION_NODEJS }}'
4283
registry-url: https://registry.npmjs.org
4384
cache: pnpm
4485

4586
- name: Configure pnpm
46-
if: ${{ contains( github.event.pull_request.labels.*.name, 'js-rc') || contains( github.event.pull_request.labels.*.name, 'cli-rc') }}
87+
if: ${{ env.IS_JS == 'true' || env.IS_CLI == 'true' }}
4788
run: |
4889
pnpm config set auto-install-peers true
4990
pnpm config set exclude-links-from-lockfile true
5091
5192
- name: Set up Python
5293
uses: actions/setup-python@v4
53-
if: ${{ contains( github.event.pull_request.labels.*.name, 'python-rc') }}
94+
if: ${{ env.IS_PYTHON == 'true' }}
5495
with:
5596
python-version: '${{ env.TOOL_VERSION_PYTHON }}'
5697

5798
- name: Install and configure Poetry
5899
uses: snok/install-poetry@v1
59-
if: ${{ contains( github.event.pull_request.labels.*.name, 'python-rc') }}
100+
if: ${{ env.IS_PYTHON == 'true' }}
60101
with:
61102
version: '${{ env.TOOL_VERSION_POETRY }}'
62103
virtualenvs-create: true
63104
virtualenvs-in-project: true
64105
installer-parallel: true
65106

66107
- name: Test Python SDK
67-
if: ${{ contains( github.event.pull_request.labels.*.name, 'python-rc') }}
108+
if: ${{ env.IS_PYTHON == 'true' }}
68109
working-directory: packages/python-sdk
69110
run: |
70111
poetry install
@@ -73,7 +114,7 @@ jobs:
73114
E2B_API_KEY: ${{ secrets.E2B_API_KEY }}
74115

75116
- name: Release Candidate
76-
if: ${{ contains( github.event.pull_request.labels.*.name, 'python-rc') }}
117+
if: ${{ env.IS_PYTHON == 'true' }}
77118
working-directory: packages/python-sdk
78119
run: |
79120
poetry version prerelease
@@ -83,43 +124,43 @@ jobs:
83124
PYPI_TOKEN: ${{ secrets.PYPI_TOKEN }}
84125

85126
- name: Install JS dependencies
86-
if: ${{ contains( github.event.pull_request.labels.*.name, 'js-rc') || contains( github.event.pull_request.labels.*.name, 'cli-rc') }}
127+
if: ${{ env.IS_JS == 'true' || env.IS_CLI == 'true' }}
87128
run: |
88129
pnpm install --frozen-lockfile
89130
90131
- name: Test JS SDK
91132
working-directory: packages/js-sdk
92-
if: ${{ contains( github.event.pull_request.labels.*.name, 'js-rc') }}
133+
if: ${{ env.IS_JS == 'true' }}
93134
run: |
94135
pnpm run test
95136
env:
96137
E2B_API_KEY: ${{ secrets.E2B_API_KEY }}
97138

98139
- name: Release JS Candidate
99140
working-directory: packages/js-sdk
100-
if: ${{ contains( github.event.pull_request.labels.*.name, 'js-rc') }}
141+
if: ${{ env.IS_JS == 'true' }}
101142
run: |
102-
npm version prerelease --preid=${{ github.head_ref }}
103-
npm publish --tag rc
143+
npm version prerelease --preid=${{ env.PREID }}
144+
npm publish --tag ${{ env.PUBLISH_TAG }}
104145
env:
105146
NODE_AUTH_TOKEN: ${{ secrets.NPM_TOKEN }}
106147

107148
- name: Install dependencies
108-
if: ${{ contains( github.event.pull_request.labels.*.name, 'js-rc') || contains( github.event.pull_request.labels.*.name, 'cli-rc') }}
149+
if: ${{ env.IS_JS == 'true' || env.IS_CLI == 'true' }}
109150
run: |
110151
pnpm install --frozen-lockfile
111152
112153
- name: Release CLI Candidate
113154
working-directory: packages/cli
114-
if: ${{ contains( github.event.pull_request.labels.*.name, 'cli-rc') }}
155+
if: ${{ env.IS_CLI == 'true' }}
115156
run: |
116-
npm version prerelease --preid=${{ github.head_ref }}
117-
npm publish --tag rc
157+
npm version prerelease --preid=${{ env.PREID }}
158+
npm publish --tag ${{ env.PUBLISH_TAG }}
118159
env:
119160
NODE_AUTH_TOKEN: ${{ secrets.NPM_TOKEN }}
120161

121162
- 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') }}
163+
if: ${{ env.IS_JS == 'true' || env.IS_CLI == 'true' || env.IS_PYTHON == 'true' }}
123164
run: |
124165
git config user.name "github-actions[bot]"
125166
git config user.email "github-actions[bot]@users.noreply.github.com"

0 commit comments

Comments
 (0)