Unverified Commit f715bba5 authored by Sebastian "Sebbie" Silbermann's avatar Sebastian "Sebbie" Silbermann Committed by GitHub

[lts-active][cd] Gate release bot credentials behind GitHub environments (#100123)

Co-authored-by: 's avatarClaude Code <noreply@anthropic.com>
parent c864c78f
...@@ -670,6 +670,10 @@ jobs: ...@@ -670,6 +670,10 @@ jobs:
merge-multiple: true merge-multiple: true
path: crates/wasm path: crates/wasm
# Un-drafting the GitHub release must stay authenticated as the bot:
# events caused by GITHUB_TOKEN (github-actions[bot]) do not trigger
# workflow runs, and release-published automations depend on the event.
# The key comes from this job's release-* environment secret.
- name: Create GitHub App token - name: Create GitHub App token
id: release-app-token id: release-app-token
uses: actions/create-github-app-token@bcd2ba49218906704ab6c1aa796996da409d3eb1 # v3.2.0 uses: actions/create-github-app-token@bcd2ba49218906704ab6c1aa796996da409d3eb1 # v3.2.0
......
on:
workflow_dispatch:
inputs:
branchName:
description: name of branch to create (next-15-4)
required: true
type: string
tagName:
description: Tag to start the branch from (v15.4.1)
type: string
required: true
name: Create Release Branch
env:
NAPI_CLI_VERSION: 3.7.2
TURBO_VERSION: 2.9.4
NODE_LTS_VERSION: 20
jobs:
start:
if: github.repository_owner == 'vercel'
runs-on: ubuntu-latest
env:
NEXT_TELEMETRY_DISABLED: 1
steps:
- name: Setup node
uses: actions/setup-node@48b55a011bda9f5d6aeb4c2d9c7362e8dae4041e # v6.4.0
with:
node-version: ${{ env.NODE_LTS_VERSION }}
check-latest: true
package-manager-cache: false
- name: Create GitHub App token
id: release-app-token
uses: actions/create-github-app-token@bcd2ba49218906704ab6c1aa796996da409d3eb1 # v3.2.0
with:
client-id: ${{ vars.RELEASE_GITHUB_APP_CLIENT_ID }}
private-key: ${{ secrets.RELEASE_GITHUB_APP_PRIVATE_KEY }}
owner: ${{ github.repository_owner }}
repositories: next.js
permission-contents: write
permission-workflows: write
- name: Get GitHub App user ID
id: release-app-user
run: |
user_id="$(gh api "/users/${{ steps.release-app-token.outputs.app-slug }}[bot]" --jq .id)"
echo "user-id=$user_id" >> "$GITHUB_OUTPUT"
env:
GH_TOKEN: ${{ steps.release-app-token.outputs.token }}
- name: Clone Next.js repository
run: git clone https://github.com/vercel/next.js.git --depth=25 --single-branch --branch ${GITHUB_REF_NAME:-canary} .
- name: Check token
run: gh auth status
env:
GH_TOKEN: ${{ steps.release-app-token.outputs.token }}
# https://github.com/actions/virtual-environments/issues/1187
- name: tune linux network
run: sudo ethtool -K eth0 tx off rx off
- name: Setup corepack
run: |
npm i -g corepack@0.31
corepack enable
pnpm --version
- id: get-store-path
run: echo STORE_PATH=$(pnpm store path) >> $GITHUB_OUTPUT
- uses: actions/cache@27d5ce7f107fe9357f9df03efb73ab90386fccae # v5.0.5
timeout-minutes: 5
id: cache-pnpm-store
with:
path: ${{ steps.get-store-path.outputs.STORE_PATH }}
key: pnpm-store-root-v1-${{ hashFiles('pnpm-lock.yaml') }}
# Do not use restore-keys since it leads to indefinite growth of the cache.
- run: pnpm install
- run: node ./scripts/create-release-branch.js --branch-name "${INPUT_BRANCHNAME}" --tag-name "${INPUT_TAGNAME}"
env:
RELEASE_GITHUB_TOKEN: ${{ steps.release-app-token.outputs.token }}
RELEASE_GITHUB_APP_SLUG: ${{ steps.release-app-token.outputs.app-slug }}
RELEASE_GITHUB_APP_USER_ID: ${{ steps.release-app-user.outputs.user-id }}
INPUT_BRANCHNAME: ${{ github.event.inputs.branchName }}
INPUT_TAGNAME: ${{ github.event.inputs.tagName }}
...@@ -10,8 +10,8 @@ on: ...@@ -10,8 +10,8 @@ on:
jobs: jobs:
update_dev_manifest: update_dev_manifest:
name: Update and upload Rspack development test manifest name: Update and upload Rspack development test manifest
if: github.repository_owner == 'vercel'
runs-on: ubuntu-latest runs-on: ubuntu-latest
environment: bot-autonomous
steps: steps:
- name: Create GitHub App token - name: Create GitHub App token
id: release-app-token id: release-app-token
...@@ -73,8 +73,8 @@ jobs: ...@@ -73,8 +73,8 @@ jobs:
PR_BODY: This auto-generated PR updates the development integration test manifest used when testing Rspack. PR_BODY: This auto-generated PR updates the development integration test manifest used when testing Rspack.
update_build_manifest: update_build_manifest:
name: Update and upload Rspack production test manifest name: Update and upload Rspack production test manifest
if: github.repository_owner == 'vercel'
runs-on: ubuntu-latest runs-on: ubuntu-latest
environment: bot-autonomous
steps: steps:
- name: Create GitHub App token - name: Create GitHub App token
id: release-app-token id: release-app-token
......
...@@ -28,8 +28,9 @@ concurrency: ...@@ -28,8 +28,9 @@ concurrency:
jobs: jobs:
evaluate: evaluate:
if: ${{ github.repository_owner == 'vercel' && (github.event_name == 'workflow_dispatch' || (github.event.workflow_run.event == 'push' && github.event.workflow_run.conclusion == 'success' && github.event.workflow_run.head_branch != 'canary')) }} if: ${{ github.event_name == 'workflow_dispatch' || (github.event.workflow_run.event == 'push' && github.event.workflow_run.conclusion == 'success' && github.event.workflow_run.head_branch != 'canary') }}
runs-on: ubuntu-latest runs-on: ubuntu-latest
environment: bot-autonomous
permissions: permissions:
contents: read contents: read
outputs: outputs:
......
...@@ -29,6 +29,11 @@ on: ...@@ -29,6 +29,11 @@ on:
default: false default: false
type: boolean type: boolean
dryRun:
description: pass --dry-run to start-release.js (no tag, no release)
default: false
type: boolean
name: Trigger Release name: Trigger Release
env: env:
...@@ -40,8 +45,11 @@ permissions: {} ...@@ -40,8 +45,11 @@ permissions: {}
jobs: jobs:
start: start:
if: github.repository_owner == 'vercel'
runs-on: ubuntu-latest runs-on: ubuntu-latest
# Prerelease channels (and the scheduled nightly, where inputs are empty)
# run autonomously; only stable requires approval before the tag exists.
# Prerelease publishes are still gated by their release-* environments.
environment: ${{ (github.event_name == 'schedule' || inputs.releaseType != 'stable') && 'bot-autonomous' || 'bot-approved' }}
env: env:
NEXT_TELEMETRY_DISABLED: 1 NEXT_TELEMETRY_DISABLED: 1
...@@ -137,7 +145,7 @@ jobs: ...@@ -137,7 +145,7 @@ jobs:
run: pnpm install run: pnpm install
- if: steps.new-commits.outputs.has_new_commits == 'true' - if: steps.new-commits.outputs.has_new_commits == 'true'
run: node ./scripts/start-release.js --release-type "${INPUT_RELEASETYPE}" --semver-type "${INPUT_SEMVERTYPE}" run: node ./scripts/start-release.js --release-type "${INPUT_RELEASETYPE}" --semver-type "${INPUT_SEMVERTYPE}"${{ inputs.dryRun && ' --dry-run' || '' }}
env: env:
RELEASE_GITHUB_TOKEN: ${{ steps.release-app-token.outputs.token }} RELEASE_GITHUB_TOKEN: ${{ steps.release-app-token.outputs.token }}
RELEASE_GITHUB_APP_SLUG: ${{ steps.release-app-token.outputs.app-slug }} RELEASE_GITHUB_APP_SLUG: ${{ steps.release-app-token.outputs.app-slug }}
......
...@@ -7,10 +7,13 @@ on: ...@@ -7,10 +7,13 @@ on:
# Allow manual runs # Allow manual runs
workflow_dispatch: workflow_dispatch:
permissions:
contents: read
jobs: jobs:
create-pull-request: create-pull-request:
runs-on: ubuntu-latest runs-on: ubuntu-latest
if: github.repository_owner == 'vercel' environment: bot-autonomous
steps: steps:
- name: Create GitHub App token - name: Create GitHub App token
id: release-app-token id: release-app-token
......
...@@ -19,6 +19,7 @@ env: ...@@ -19,6 +19,7 @@ env:
jobs: jobs:
create-pull-request: create-pull-request:
runs-on: ubuntu-latest runs-on: ubuntu-latest
environment: bot-autonomous
permissions: permissions:
# The built-in token is only used to read the facebook/react compare API # The built-in token is only used to read the facebook/react compare API
# for the changelog. Everything that writes to this repository # for the changelog. Everything that writes to this repository
...@@ -71,8 +72,10 @@ jobs: ...@@ -71,8 +72,10 @@ jobs:
- name: Create Pull Request - name: Create Pull Request
shell: bash shell: bash
run: pnpm sync-react --actor "${{ github.actor }}" --commit --create-pull --version "${{ inputs.version }}" run: pnpm sync-react --actor "$ACTOR" --commit --create-pull --version "$INPUT_VERSION"
env: env:
ACTOR: ${{ github.actor }}
INPUT_VERSION: ${{ inputs.version }}
# Only used to authenticate the facebook/react compare API request # Only used to authenticate the facebook/react compare API request
# that builds the changelog, so it doesn't hit anonymous rate limits. # that builds the changelog, so it doesn't hit anonymous rate limits.
# The commits, branch, and Pull Request all use the app token below. # The commits, branch, and Pull Request all use the app token below.
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment