Skip to content
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

Add workflow to trigger release #47461

Merged
merged 6 commits into from
Mar 23, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
22 changes: 11 additions & 11 deletions .github/workflows/build_test_deploy.yml
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,7 @@ jobs:
uses: actions/setup-node@v3
if: ${{ steps.docs-change.outputs.docsChange == 'nope' }}
with:
node-version: 16
node-version: ${{ env.NODE_LTS_VERSION }}
check-latest: true

- uses: actions/checkout@v3
Expand Down Expand Up @@ -117,7 +117,7 @@ jobs:
- name: Setup node
uses: actions/setup-node@v3
with:
node-version: 16
node-version: ${{ env.NODE_LTS_VERSION }}
check-latest: true

- run: npm i -g pnpm@${PNPM_VERSION}
Expand Down Expand Up @@ -195,7 +195,7 @@ jobs:
uses: actions/setup-node@v3
if: ${{needs.build.outputs.docsChange == 'nope'}}
with:
node-version: 16
node-version: ${{ env.NODE_LTS_VERSION }}
check-latest: true

# https://github.com/actions/virtual-environments/issues/1187
Expand Down Expand Up @@ -243,7 +243,7 @@ jobs:
uses: actions/setup-node@v3
if: ${{needs.build.outputs.docsChange == 'nope'}}
with:
node-version: 16
node-version: ${{ env.NODE_LTS_VERSION }}
check-latest: true

- uses: actions/cache@v3
Expand Down Expand Up @@ -782,7 +782,7 @@ jobs:
uses: actions/setup-node@v3
if: ${{needs.build.outputs.docsChange == 'nope'}}
with:
node-version: 16
node-version: ${{ env.NODE_MAINTENANCE_VERSION }}
check-latest: true

- uses: actions/cache@v3
Expand Down Expand Up @@ -922,7 +922,7 @@ jobs:
uses: actions/setup-node@v3
if: ${{needs.build.outputs.docsChange == 'nope'}}
with:
node-version: 16
node-version: ${{ env.NODE_LTS_VERSION }}
check-latest: true

# https://github.com/actions/virtual-environments/issues/1187
Expand Down Expand Up @@ -1020,7 +1020,7 @@ jobs:
- name: Setup node
uses: actions/setup-node@v3
with:
node-version: 16
node-version: ${{ env.NODE_LTS_VERSION }}
check-latest: true

- uses: actions/cache@v3
Expand Down Expand Up @@ -1347,7 +1347,7 @@ jobs:
uses: actions/setup-node@v3
if: ${{ !matrix.settings.docker }}
with:
node-version: 16
node-version: ${{ env.NODE_LTS_VERSION }}
check-latest: true

- name: Install
Expand Down Expand Up @@ -1418,7 +1418,7 @@ jobs:
- name: Setup node
uses: actions/setup-node@v3
with:
node-version: 16
node-version: ${{ env.NODE_LTS_VERSION }}
check-latest: true

- name: Install Rust
Expand Down Expand Up @@ -1466,7 +1466,7 @@ jobs:
if: ${{needs.build.outputs.docsChange == 'nope'}}
uses: actions/setup-node@v3
with:
node-version: 16
node-version: ${{ env.NODE_LTS_VERSION }}
check-latest: true

- run: npm i -g turbo@${{ env.TURBO_VERSION }} pnpm@${PNPM_VERSION}
Expand Down Expand Up @@ -1539,7 +1539,7 @@ jobs:
uses: actions/setup-node@v3
if: ${{needs.build.outputs.docsChange == 'nope'}}
with:
node-version: 16
node-version: ${{ env.NODE_LTS_VERSION }}
check-latest: true

- uses: actions/cache@v3
Expand Down
64 changes: 64 additions & 0 deletions .github/workflows/trigger_release.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,64 @@
on:
workflow_call:
inputs:
releaseType:
description: stable or canary (case sensitive)?
required: true
type: string

semverType:
description: patch, minor, or major (case sensitive)?
type: string

secrets:
START_RELEASE_TOKEN:
required: true

name: Trigger Release

jobs:
start:
runs-on: ubuntu-latest
env:
NEXT_TELEMETRY_DISABLED: 1
# we build a dev binary for use in CI so skip downloading
# canary next-swc binaries in the monorepo
NEXT_SKIP_NATIVE_POSTINSTALL: 1

environment: release-${{ github.event.inputs.releaseType }}
steps:
- name: Setup node
uses: actions/setup-node@v3
if: ${{ steps.docs-change.outputs.docsChange == 'nope' }}
with:
node-version: 18
check-latest: true

- uses: actions/checkout@v3
with:
fetch-depth: 25

# https://github.com/actions/virtual-environments/issues/1187
- name: tune linux network
run: sudo ethtool -K eth0 tx off rx off

- run: npm i -g pnpm@${PNPM_VERSION}

- id: get-store-path
run: echo STORE_PATH=$(pnpm store path) >> $GITHUB_OUTPUT

- uses: actions/cache@v3
timeout-minutes: 5
id: cache-pnpm-store
with:
path: ${{ steps.get-store-path.outputs.STORE_PATH }}
key: pnpm-store-${{ hashFiles('pnpm-lock.yaml') }}
restore-keys: |
pnpm-store-
pnpm-store-${{ hashFiles('pnpm-lock.yaml') }}

- run: pnpm install

- run: pnpm run build

- run: node ./scripts/start-release.js --release-type ${{ github.event.inputs.releaseType }} --semver-type ${{ github.event.inputs.semverType }}
3 changes: 2 additions & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,7 @@
"types": "lerna run types --stream",
"typescript": "turbo run typescript",
"prepublishOnly": "turbo run build",
"publish-canary": "git checkout canary && git pull && lerna version prerelease --preid canary --force-publish && release --pre --skip-questions",
"publish-canary": "git checkout canary && git pull && lerna version prerelease --preid canary --force-publish && release --pre --skip-questions --show-url",
"publish-stable": "lerna version --force-publish",
"lint-staged": "lint-staged",
"next-with-deps": "./scripts/next-with-deps.sh",
Expand Down Expand Up @@ -117,6 +117,7 @@
"@zeit/next-typescript": "1.1.2-canary.0",
"abort-controller": "3.0.0",
"alex": "9.1.0",
"ansi-escapes": "4.3.2",
"amphtml-validator": "1.0.35",
"async-sema": "3.0.1",
"body-parser": "1.20.1",
Expand Down
22 changes: 17 additions & 5 deletions pnpm-lock.yaml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

77 changes: 77 additions & 0 deletions scripts/start-release.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,77 @@
const path = require('path')
const execa = require('execa')
const resolveFrom = require('resolve-from')
const ansiEscapes = require('ansi-escapes')

async function main() {
const args = process.argv
const releaseType = args[args.indexOf('--release-type') + 1]
const semverType = args[args.indexOf('--semver-type') + 1]
const isCanary = releaseType === 'canary'

if (releaseType !== 'stable' && releaseType !== 'canary') {
console.log(`Invalid release type ${releaseType}, must be stable or canary`)
return
}
if (!isCanary && !['patch', 'minor', 'stable'].includes(semverType)) {
console.log(
`Invalid semver type ${semverType}, must be one of ${semverType.join(
', '
)}`
)
return
}

const githubToken = process.env.START_RELEASE_TOKEN

if (!githubToken) {
console.log(`Missing START_RELEASE_TOKEN`)
return
}

const configStorePath = resolveFrom(
path.join(process.cwd(), 'node_modules/release'),
'configstore'
)
const ConfigStore = require(configStorePath)

const config = new ConfigStore('release')
config.set('token', githubToken)

await execa(
`git remote set-url origin https://ijjk:${githubToken}@github.com/vercel/next.js`,
{ stdio: 'inherit', shell: true }
)
await execa(`git config user.name "JJ Kasper"`, {
stdio: 'inherit',
shell: true,
})
await execa(`git config user.email "jj@jjsweb.site"`, {
stdio: 'inherit',
shell: true,
})

const child = execa(`pnpm publish-${isCanary ? 'canary' : 'stable'}`, {
stdio: 'pipe',
shell: true,
})

child.stdout.pipe(process.stdout)
child.stderr.pipe(process.stderr)

if (isCanary) {
child.stdin.write('y\n')
} else {
if (semverType === 'minor') {
child.stdin.write(ansiEscapes.cursorDown(1))
}
if (semverType === 'major') {
child.stdin.write(ansiEscapes.cursorDown(1))
child.stdin.write(ansiEscapes.cursorDown(1))
}
child.stdin.write('\n')
}
await child
}

main()