-
Notifications
You must be signed in to change notification settings - Fork 892
chore: allow releases from PRs #1142
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Merged
+383
−227
Merged
Changes from 6 commits
Commits
Show all changes
7 commits
Select commit
Hold shift + click to select a range
e90d199
allow skipping tests for release candidates
dobrac 99d8dcc
support new npm publishing
dobrac 9f7d56c
Add CI workflow to build and publish package artifacts on PRs
dobrac 23276e0
publish release candidates through release
dobrac edc01f5
address PR bots comments
dobrac a5d53d0
ci: add pagination when fetching PR comments
dobrac 2e9acc7
ci: sanitize RC tag input in release workflow
dobrac File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,148 @@ | ||
| name: Package Artifacts | ||
|
|
||
| on: | ||
| pull_request: | ||
| types: [opened, synchronize, reopened] | ||
|
|
||
| permissions: | ||
| contents: read | ||
| pull-requests: write | ||
|
|
||
| jobs: | ||
| build: | ||
| name: Build Packages | ||
| runs-on: ubuntu-latest | ||
|
|
||
| steps: | ||
| - name: Checkout | ||
| uses: actions/checkout@v4 | ||
|
|
||
| - name: Parse .tool-versions | ||
| uses: wistia/parse-tool-versions@v2.1.1 | ||
| with: | ||
| filename: '.tool-versions' | ||
| uppercase: 'true' | ||
| prefix: 'tool_version_' | ||
|
|
||
| - uses: pnpm/action-setup@v4 | ||
| with: | ||
| version: '${{ env.TOOL_VERSION_PNPM }}' | ||
|
|
||
| - name: Setup Node.js | ||
| uses: actions/setup-node@v6 | ||
| with: | ||
| node-version: '${{ env.TOOL_VERSION_NODEJS }}' | ||
| cache: pnpm | ||
|
|
||
| - name: Configure pnpm | ||
| run: | | ||
| pnpm config set auto-install-peers true | ||
| pnpm config set exclude-links-from-lockfile true | ||
|
|
||
| - name: Sanitize branch name | ||
| env: | ||
| BRANCH: ${{ github.head_ref }} | ||
| run: | | ||
| echo "BRANCH_ID=$(echo "$BRANCH" | sed 's/[^0-9A-Za-z-]/-/g')" >> "$GITHUB_ENV" | ||
|
|
||
| - name: Install dependencies | ||
| run: pnpm install --frozen-lockfile | ||
|
|
||
| - name: Build JS SDK | ||
| working-directory: packages/js-sdk | ||
| run: pnpm run build | ||
|
|
||
| - name: Pack JS SDK | ||
| working-directory: packages/js-sdk | ||
| run: | | ||
| npm version prerelease --preid=${{ env.BRANCH_ID }} --no-git-tag-version | ||
| npm pack | ||
|
|
||
| - name: Upload JS SDK artifact | ||
| uses: actions/upload-artifact@v4 | ||
| with: | ||
| name: e2b-js-sdk | ||
| path: packages/js-sdk/*.tgz | ||
|
|
||
| - name: Build CLI | ||
| working-directory: packages/cli | ||
| run: pnpm run build | ||
|
|
||
| - name: Pack CLI | ||
| working-directory: packages/cli | ||
| run: | | ||
| npm version prerelease --preid=${{ env.BRANCH_ID }} --no-git-tag-version | ||
| npm pack | ||
|
|
||
| - name: Upload CLI artifact | ||
| uses: actions/upload-artifact@v4 | ||
| with: | ||
| name: e2b-cli | ||
| path: packages/cli/*.tgz | ||
|
|
||
| - name: Set up Python | ||
| uses: actions/setup-python@v4 | ||
| with: | ||
| python-version: '${{ env.TOOL_VERSION_PYTHON }}' | ||
|
|
||
| - name: Install and configure Poetry | ||
| uses: snok/install-poetry@v1 | ||
| with: | ||
| version: '${{ env.TOOL_VERSION_POETRY }}' | ||
| virtualenvs-create: true | ||
| virtualenvs-in-project: true | ||
| installer-parallel: true | ||
|
|
||
| - name: Build Python SDK | ||
| working-directory: packages/python-sdk | ||
| run: | | ||
| BASE_VERSION=$(poetry version -s) | ||
| poetry version "${BASE_VERSION}+${BRANCH_ID}" | ||
| poetry build | ||
|
|
||
| - name: Upload Python SDK artifact | ||
| uses: actions/upload-artifact@v4 | ||
| with: | ||
| name: e2b-python-sdk | ||
| path: packages/python-sdk/dist/* | ||
|
|
||
| - name: Comment on PR | ||
| env: | ||
| GH_TOKEN: ${{ secrets.GITHUB_TOKEN }} | ||
| PR_NUMBER: ${{ github.event.pull_request.number }} | ||
| RUN_URL: ${{ github.server_url }}/${{ github.repository }}/actions/runs/${{ github.run_id }} | ||
| run: | | ||
| JS_VERSION=$(node -p "require('./packages/js-sdk/package.json').version") | ||
| CLI_VERSION=$(node -p "require('./packages/cli/package.json').version") | ||
| JS_TGZ=$(ls packages/js-sdk/*.tgz | xargs -n1 basename) | ||
| CLI_TGZ=$(ls packages/cli/*.tgz | xargs -n1 basename) | ||
| PY_VERSION=$(grep '^version' packages/python-sdk/pyproject.toml | head -1 | sed 's/.*"\(.*\)"/\1/') | ||
| PY_WHL=$(ls packages/python-sdk/dist/*.whl | xargs -n1 basename) | ||
|
|
||
| BODY="<!-- e2b-pkg-artifacts -->"$'\n' | ||
| BODY+="### Package Artifacts"$'\n\n' | ||
| BODY+="Built from ${GITHUB_SHA::7}. Download artifacts from [this workflow run](${RUN_URL})."$'\n\n' | ||
| BODY+="**JS SDK** (\`e2b@${JS_VERSION}\`):"$'\n' | ||
| BODY+='```sh'$'\n' | ||
| BODY+="npm install ./${JS_TGZ}"$'\n' | ||
| BODY+='```'$'\n\n' | ||
| BODY+="**CLI** (\`@e2b/cli@${CLI_VERSION}\`):"$'\n' | ||
| BODY+='```sh'$'\n' | ||
| BODY+="npm install ./${CLI_TGZ}"$'\n' | ||
| BODY+='```'$'\n\n' | ||
| BODY+="**Python SDK** (\`e2b==${PY_VERSION}\`):"$'\n' | ||
| BODY+='```sh'$'\n' | ||
| BODY+="pip install ./${PY_WHL}"$'\n' | ||
| BODY+='```'$'\n' | ||
|
|
||
| COMMENT_ID=$(gh api "repos/${{ github.repository }}/issues/${PR_NUMBER}/comments" \ | ||
| --paginate \ | ||
| --jq '.[] | select(.body | contains("<!-- e2b-pkg-artifacts -->")) | .id' \ | ||
| | tail -1) | ||
|
|
||
| if [ -n "$COMMENT_ID" ]; then | ||
| gh api "repos/${{ github.repository }}/issues/comments/${COMMENT_ID}" \ | ||
| -X PATCH -f body="$BODY" | ||
| else | ||
| gh pr comment "$PR_NUMBER" --body "$BODY" | ||
| fi | ||
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,115 @@ | ||
| name: Publish Candidates | ||
|
|
||
| on: | ||
| workflow_call: | ||
| inputs: | ||
| js-sdk: | ||
| required: false | ||
| type: boolean | ||
| default: false | ||
| python-sdk: | ||
| required: false | ||
| type: boolean | ||
| default: false | ||
| cli: | ||
| required: false | ||
| type: boolean | ||
| default: false | ||
| tag: | ||
| required: true | ||
| type: string | ||
| preid: | ||
| required: true | ||
| type: string | ||
|
|
||
| permissions: | ||
| contents: read | ||
| id-token: write | ||
|
|
||
| jobs: | ||
| publish: | ||
| name: Publish Release Candidates | ||
| runs-on: ubuntu-latest | ||
| steps: | ||
| - name: Checkout Repo | ||
| uses: actions/checkout@v4 | ||
|
|
||
| - name: Parse .tool-versions | ||
| uses: wistia/parse-tool-versions@v2.1.1 | ||
| with: | ||
| filename: '.tool-versions' | ||
| uppercase: 'true' | ||
| prefix: 'tool_version_' | ||
|
|
||
| - uses: pnpm/action-setup@v4 | ||
| if: ${{ inputs.js-sdk || inputs.cli }} | ||
| with: | ||
| version: '${{ env.TOOL_VERSION_PNPM }}' | ||
|
|
||
| - name: Setup Node.js | ||
| uses: actions/setup-node@v6 | ||
| if: ${{ inputs.js-sdk || inputs.cli }} | ||
| with: | ||
| node-version: '${{ env.TOOL_VERSION_NODEJS }}' | ||
| registry-url: https://registry.npmjs.org | ||
| cache: pnpm | ||
|
|
||
| - name: Configure pnpm | ||
| if: ${{ inputs.js-sdk || inputs.cli }} | ||
| run: | | ||
| pnpm config set auto-install-peers true | ||
| pnpm config set exclude-links-from-lockfile true | ||
|
|
||
| - name: Update npm | ||
| if: ${{ inputs.js-sdk || inputs.cli }} | ||
| run: | | ||
| npm install -g npm@^11.6 | ||
| npm --version | ||
|
|
||
| - name: Set up Python | ||
| uses: actions/setup-python@v4 | ||
| if: ${{ inputs.python-sdk }} | ||
| with: | ||
| python-version: '${{ env.TOOL_VERSION_PYTHON }}' | ||
|
|
||
| - name: Install and configure Poetry | ||
| uses: snok/install-poetry@v1 | ||
| if: ${{ inputs.python-sdk }} | ||
| with: | ||
| version: '${{ env.TOOL_VERSION_POETRY }}' | ||
| virtualenvs-create: true | ||
| virtualenvs-in-project: true | ||
| installer-parallel: true | ||
|
|
||
| - name: Publish Python RC | ||
| if: ${{ inputs.python-sdk }} | ||
| working-directory: packages/python-sdk | ||
| run: | | ||
| BASE_VERSION=$(poetry version -s) | ||
| poetry version "${BASE_VERSION}rc${{ github.run_number }}" | ||
| poetry build | ||
| poetry config pypi-token.pypi ${PYPI_TOKEN} && poetry publish --skip-existing | ||
| env: | ||
| PYPI_TOKEN: ${{ secrets.PYPI_TOKEN }} | ||
|
|
||
| - name: Install JS dependencies | ||
| if: ${{ inputs.js-sdk || inputs.cli }} | ||
| run: pnpm install --frozen-lockfile | ||
|
|
||
| - name: Publish JS RC | ||
| if: ${{ inputs.js-sdk }} | ||
| working-directory: packages/js-sdk | ||
| run: | | ||
| npm version prerelease --preid=${{ inputs.preid }}.${{ github.run_number }} --no-git-tag-version | ||
| npm publish --tag ${{ inputs.tag }} --provenance | ||
|
dobrac marked this conversation as resolved.
dobrac marked this conversation as resolved.
|
||
|
|
||
| - name: Reinstall dependencies | ||
| if: ${{ inputs.js-sdk || inputs.cli }} | ||
| run: pnpm install --frozen-lockfile | ||
|
|
||
| - name: Publish CLI RC | ||
| if: ${{ inputs.cli }} | ||
| working-directory: packages/cli | ||
| run: | | ||
| npm version prerelease --preid=${{ inputs.preid }}.${{ github.run_number }} --no-git-tag-version | ||
| npm publish --tag ${{ inputs.tag }} --provenance | ||
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.