Skip to content

Commit 23276e0

Browse files
committed
publish release candidates through release
1 parent 9f7d56c commit 23276e0

3 files changed

Lines changed: 226 additions & 236 deletions

File tree

Lines changed: 114 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,114 @@
1+
name: Publish Candidates
2+
3+
on:
4+
workflow_call:
5+
inputs:
6+
js-sdk:
7+
required: false
8+
type: boolean
9+
default: false
10+
python-sdk:
11+
required: false
12+
type: boolean
13+
default: false
14+
cli:
15+
required: false
16+
type: boolean
17+
default: false
18+
tag:
19+
required: true
20+
type: string
21+
preid:
22+
required: true
23+
type: string
24+
25+
permissions:
26+
contents: read
27+
id-token: write
28+
29+
jobs:
30+
publish:
31+
name: Publish Release Candidates
32+
runs-on: ubuntu-latest
33+
steps:
34+
- name: Checkout Repo
35+
uses: actions/checkout@v4
36+
37+
- name: Parse .tool-versions
38+
uses: wistia/parse-tool-versions@v2.1.1
39+
with:
40+
filename: '.tool-versions'
41+
uppercase: 'true'
42+
prefix: 'tool_version_'
43+
44+
- uses: pnpm/action-setup@v4
45+
if: ${{ inputs.js-sdk || inputs.cli }}
46+
with:
47+
version: '${{ env.TOOL_VERSION_PNPM }}'
48+
49+
- name: Setup Node.js
50+
uses: actions/setup-node@v6
51+
if: ${{ inputs.js-sdk || inputs.cli }}
52+
with:
53+
node-version: '${{ env.TOOL_VERSION_NODEJS }}'
54+
registry-url: https://registry.npmjs.org
55+
cache: pnpm
56+
57+
- name: Configure pnpm
58+
if: ${{ inputs.js-sdk || inputs.cli }}
59+
run: |
60+
pnpm config set auto-install-peers true
61+
pnpm config set exclude-links-from-lockfile true
62+
63+
- name: Update npm
64+
if: ${{ inputs.js-sdk || inputs.cli }}
65+
run: |
66+
npm install -g npm@^11.6
67+
npm --version
68+
69+
- name: Set up Python
70+
uses: actions/setup-python@v4
71+
if: ${{ inputs.python-sdk }}
72+
with:
73+
python-version: '${{ env.TOOL_VERSION_PYTHON }}'
74+
75+
- name: Install and configure Poetry
76+
uses: snok/install-poetry@v1
77+
if: ${{ inputs.python-sdk }}
78+
with:
79+
version: '${{ env.TOOL_VERSION_POETRY }}'
80+
virtualenvs-create: true
81+
virtualenvs-in-project: true
82+
installer-parallel: true
83+
84+
- name: Publish Python RC
85+
if: ${{ inputs.python-sdk }}
86+
working-directory: packages/python-sdk
87+
run: |
88+
poetry version prerelease
89+
poetry build
90+
poetry config pypi-token.pypi ${PYPI_TOKEN} && poetry publish --skip-existing
91+
env:
92+
PYPI_TOKEN: ${{ secrets.PYPI_TOKEN }}
93+
94+
- name: Install JS dependencies
95+
if: ${{ inputs.js-sdk || inputs.cli }}
96+
run: pnpm install --frozen-lockfile
97+
98+
- name: Publish JS RC
99+
if: ${{ inputs.js-sdk }}
100+
working-directory: packages/js-sdk
101+
run: |
102+
npm version prerelease --preid=${{ inputs.preid }}
103+
npm publish --tag ${{ inputs.tag }} --provenance
104+
105+
- name: Reinstall dependencies
106+
if: ${{ inputs.js-sdk || inputs.cli }}
107+
run: pnpm install --frozen-lockfile
108+
109+
- name: Publish CLI RC
110+
if: ${{ inputs.cli }}
111+
working-directory: packages/cli
112+
run: |
113+
npm version prerelease --preid=${{ inputs.preid }}
114+
npm publish --tag ${{ inputs.tag }} --provenance

.github/workflows/release.yml

Lines changed: 112 additions & 53 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,44 @@ name: Release
22

33
on:
44
workflow_dispatch:
5+
inputs:
6+
mode:
7+
description: 'Release mode'
8+
type: choice
9+
options:
10+
- release
11+
- candidate
12+
default: release
13+
js-sdk:
14+
description: 'Release JS SDK (candidate only)'
15+
required: false
16+
default: false
17+
type: boolean
18+
python-sdk:
19+
description: 'Release Python SDK (candidate only)'
20+
required: false
21+
default: false
22+
type: boolean
23+
cli:
24+
description: 'Release CLI (candidate only)'
25+
required: false
26+
default: false
27+
type: boolean
28+
tag:
29+
description: 'Dist-tag for candidate (e.g. rc, beta, snapshot)'
30+
required: false
31+
default: 'rc'
32+
type: string
33+
preid:
34+
description: 'Prerelease identifier (defaults to branch name, candidate only)'
35+
required: false
36+
default: ''
37+
type: string
38+
skip-tests:
39+
description: 'Skip tests (candidate only)'
40+
required: false
41+
default: false
42+
type: boolean
543

644
concurrency: ${{ github.workflow }}-${{ github.ref }}
745

@@ -10,11 +48,16 @@ permissions:
1048
contents: write
1149

1250
jobs:
13-
is_release:
14-
name: Is release?
51+
# ── Production release ───────────────────────────────────
52+
preflight:
53+
name: Release preflight
54+
if: github.event.inputs.mode != 'candidate'
1555
runs-on: ubuntu-latest
1656
outputs:
1757
release: ${{ steps.version.outputs.release }}
58+
js-sdk: ${{ steps.js.outputs.release }}
59+
python-sdk: ${{ steps.python.outputs.release }}
60+
cli: ${{ steps.cli.outputs.release }}
1861
steps:
1962
- name: Checkout Repo
2063
uses: actions/checkout@v3
@@ -54,91 +97,52 @@ jobs:
5497
IS_RELEASE=$(./.github/scripts/is_release.sh)
5598
echo "release=$IS_RELEASE" >> "$GITHUB_OUTPUT"
5699
57-
changes:
58-
name: Repository changes
59-
needs: [is_release]
60-
if: needs.is_release.outputs.release == 'true'
61-
runs-on: ubuntu-latest
62-
outputs:
63-
js-sdk: ${{ steps.js.outputs.release }}
64-
python-sdk: ${{ steps.python.outputs.release }}
65-
cli: ${{ steps.cli.outputs.release }}
66-
steps:
67-
- name: Checkout Repo
68-
uses: actions/checkout@v3
69-
70-
- name: Parse .tool-versions
71-
uses: wistia/parse-tool-versions@v2.1.1
72-
with:
73-
filename: '.tool-versions'
74-
uppercase: 'true'
75-
prefix: 'tool_version_'
76-
77-
- name: Install pnpm
78-
uses: pnpm/action-setup@v4
79-
id: pnpm-install
80-
with:
81-
version: '${{ env.TOOL_VERSION_PNPM }}'
82-
83-
- name: Setup Node
84-
uses: actions/setup-node@v6
85-
with:
86-
node-version: '${{ env.TOOL_VERSION_NODEJS }}'
87-
registry-url: 'https://registry.npmjs.org'
88-
cache: pnpm
89-
cache-dependency-path: pnpm-lock.yaml
90-
91-
- name: Configure pnpm
92-
run: |
93-
pnpm config set auto-install-peers true
94-
pnpm config set exclude-links-from-lockfile true
95-
96-
- name: Install dependencies
97-
run: pnpm install --frozen-lockfile
98-
99-
- name: Check JavasScript SDK Release
100+
- name: Check JavaScript SDK Release
100101
id: js
102+
if: steps.version.outputs.release == 'true'
101103
run: |
102104
IS_RELEASE=$(./.github/scripts/is_release_for_package.sh "e2b")
103105
echo "release=$IS_RELEASE" >> "$GITHUB_OUTPUT"
104106
105107
- name: Check Python SDK Release
106108
id: python
109+
if: steps.version.outputs.release == 'true'
107110
run: |
108111
IS_RELEASE=$(./.github/scripts/is_release_for_package.sh "@e2b/python-sdk")
109112
echo "release=$IS_RELEASE" >> "$GITHUB_OUTPUT"
110113
111114
- name: Check CLI Release
112115
id: cli
116+
if: steps.version.outputs.release == 'true'
113117
run: |
114118
IS_RELEASE=$(./.github/scripts/is_release_for_package.sh "@e2b/cli")
115119
echo "release=$IS_RELEASE" >> "$GITHUB_OUTPUT"
116120
117121
python-tests:
118122
name: Python SDK Tests
119-
needs: [changes]
120-
if: needs.changes.outputs.python-sdk == 'true'
123+
needs: [preflight]
124+
if: needs.preflight.outputs.python-sdk == 'true'
121125
uses: ./.github/workflows/python_sdk_tests.yml
122126
secrets: inherit
123127

124128
js-tests:
125129
name: JS SDK Tests
126-
needs: [changes]
127-
if: needs.changes.outputs.js-sdk == 'true'
130+
needs: [preflight]
131+
if: needs.preflight.outputs.js-sdk == 'true'
128132
uses: ./.github/workflows/js_sdk_tests.yml
129133
secrets: inherit
130134

131135
cli-tests:
132136
name: CLI Tests
133-
needs: [changes]
134-
if: needs.changes.outputs.cli == 'true'
137+
needs: [preflight]
138+
if: needs.preflight.outputs.cli == 'true'
135139
uses: ./.github/workflows/cli_tests.yml
136140
secrets: inherit
137141

138142
publish:
139143
name: Publish
140-
needs: [is_release, python-tests, js-tests, cli-tests]
141-
if: (!cancelled()) && !contains(needs.*.result, 'failure') && needs.is_release.outputs.release == 'true'
144+
needs: [preflight, python-tests, js-tests, cli-tests]
145+
if: (!cancelled()) && !contains(needs.*.result, 'failure') && needs.preflight.outputs.release == 'true'
142146
uses: ./.github/workflows/publish_packages.yml
143147
secrets: inherit
144148

@@ -156,3 +160,58 @@ jobs:
156160
SLACK_TITLE: Release Failed
157161
SLACK_WEBHOOK: ${{ secrets.SLACK_WEBHOOK }}
158162
SLACK_CHANNEL: 'monitoring-releases'
163+
164+
# ── Release candidate ────────────────────────────────────
165+
rc-validate:
166+
name: Validate RC inputs
167+
if: github.event.inputs.mode == 'candidate'
168+
runs-on: ubuntu-latest
169+
outputs:
170+
preid: ${{ steps.preid.outputs.preid }}
171+
steps:
172+
- name: Block production tags
173+
run: |
174+
if [ "${{ github.event.inputs.tag }}" = "latest" ]; then
175+
echo "::error::Publishing with the 'latest' tag is not allowed for candidates. Use 'release' mode instead."
176+
exit 1
177+
fi
178+
179+
- name: Sanitize preid
180+
id: preid
181+
run: |
182+
RAW_PREID="${{ github.event.inputs.preid || github.ref_name }}"
183+
echo "preid=$(echo "$RAW_PREID" | sed 's/[^0-9A-Za-z-]/-/g')" >> "$GITHUB_OUTPUT"
184+
185+
rc-python-tests:
186+
name: RC Python Tests
187+
needs: [rc-validate]
188+
if: github.event.inputs.python-sdk == 'true' && github.event.inputs.skip-tests != 'true'
189+
uses: ./.github/workflows/python_sdk_tests.yml
190+
secrets: inherit
191+
192+
rc-js-tests:
193+
name: RC JS Tests
194+
needs: [rc-validate]
195+
if: github.event.inputs.js-sdk == 'true' && github.event.inputs.skip-tests != 'true'
196+
uses: ./.github/workflows/js_sdk_tests.yml
197+
secrets: inherit
198+
199+
rc-cli-tests:
200+
name: RC CLI Tests
201+
needs: [rc-validate]
202+
if: github.event.inputs.cli == 'true' && github.event.inputs.skip-tests != 'true'
203+
uses: ./.github/workflows/cli_tests.yml
204+
secrets: inherit
205+
206+
rc-publish:
207+
name: Publish RC
208+
needs: [rc-validate, rc-python-tests, rc-js-tests, rc-cli-tests]
209+
if: (!cancelled()) && !contains(needs.*.result, 'failure')
210+
uses: ./.github/workflows/publish_candidates.yml
211+
with:
212+
js-sdk: ${{ github.event.inputs.js-sdk == 'true' }}
213+
python-sdk: ${{ github.event.inputs.python-sdk == 'true' }}
214+
cli: ${{ github.event.inputs.cli == 'true' }}
215+
tag: ${{ github.event.inputs.tag }}
216+
preid: ${{ needs.rc-validate.outputs.preid }}
217+
secrets: inherit

0 commit comments

Comments
 (0)