Skip to content

fix(ci): tag the version bump, survive push races, release on dispatch #926

fix(ci): tag the version bump, survive push races, release on dispatch

fix(ci): tag the version bump, survive push races, release on dispatch #926

name: Release Candidates
on:
pull_request:
permissions:
contents: write
jobs:
release:
name: Release Candidate
runs-on: ubuntu-latest
steps:
- name: Checkout Repo
uses: actions/checkout@11d5960a326750d5838078e36cf38b85af677262 # v4.4.0
with:
ref: ${{ github.head_ref }}
- name: Parse .tool-versions
uses: wistia/parse-tool-versions@32f568a4ffd4bfa7720ebf93f171597d1ebc979a # v2.1.1
with:
filename: '.tool-versions'
uppercase: 'true'
prefix: 'tool_version_'
- uses: pnpm/action-setup@b906affcce14559ad1aafd4ab0e942779e9f58b1 # v4.3.0
if: ${{ contains( github.event.pull_request.labels.*.name, 'js-rc') }}
with:
version: ${{ env.TOOL_VERSION_PNPM }}
- name: Setup Node.js 20
uses: actions/setup-node@49933ea5288caeca8642d1e84afbd3f7d6820020 # v4.4.0
if: ${{ contains( github.event.pull_request.labels.*.name, 'js-rc') }}
with:
node-version: '${{ env.TOOL_VERSION_NODE }}'
registry-url: https://registry.npmjs.org
cache: pnpm
- name: Configure pnpm
if: ${{ contains( github.event.pull_request.labels.*.name, 'js-rc') }}
run: |
pnpm config set auto-install-peers true
pnpm config set exclude-links-from-lockfile true
- name: Install dependencies
if: ${{ contains( github.event.pull_request.labels.*.name, 'js-rc') }}
run: pnpm install --frozen-lockfile
- name: Test JS SDK
working-directory: js
if: ${{ contains( github.event.pull_request.labels.*.name, 'js-rc') }}
run: |
pnpm run test
env:
E2B_API_KEY: ${{ secrets.E2B_API_KEY }}
- name: Release JS Candidate
working-directory: js
if: ${{ contains( github.event.pull_request.labels.*.name, 'js-rc') }}
run: |
npm version prerelease --preid=${{ github.head_ref }}
npm publish --tag rc || true
env:
NODE_AUTH_TOKEN: ${{ secrets.NPM_TOKEN }}
- name: Set up Python
uses: actions/setup-python@ece7cb06caefa5fff74198d8649806c4678c61a1 # v6.3.0
if: ${{ contains( github.event.pull_request.labels.*.name, 'python-rc') }}
with:
python-version: '${{ env.TOOL_VERSION_PYTHON }}'
- name: Install and configure Poetry
uses: snok/install-poetry@a783c322200f0519c7926aa6faa857c4e23e9263 # v1.4.2
if: ${{ contains( github.event.pull_request.labels.*.name, 'python-rc') }}
with:
version: '${{ env.TOOL_VERSION_POETRY }}'
virtualenvs-create: true
virtualenvs-in-project: true
installer-parallel: true
- name: Test Python SDK
if: ${{ contains( github.event.pull_request.labels.*.name, 'python-rc') }}
working-directory: python
run: |
poetry install
poetry run pytest -n 4 --verbose -x
env:
E2B_API_KEY: ${{ secrets.E2B_API_KEY }}
- name: Release Candidate
if: ${{ contains( github.event.pull_request.labels.*.name, 'python-rc') }}
working-directory: python
run: |
poetry version prerelease
poetry build
poetry config pypi-token.pypi ${PYPI_TOKEN} && poetry publish --skip-existing
env:
PYPI_TOKEN: ${{ secrets.PYPI_TOKEN }}
- name: Commit new versions
if: ${{ contains( github.event.pull_request.labels.*.name, 'js-rc') || contains( github.event.pull_request.labels.*.name, 'python-rc') }}
run: |
git config user.name "github-actions[bot]"
git config user.email "github-actions[bot]@users.noreply.github.com"
git commit -am "[skip ci] Release new versions" || exit 0
git push
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}