diff --git a/.github/workflows/build_test_deploy.yml b/.github/workflows/build_test_deploy.yml index 8bcff220a5134..7ac08e8e1c77e 100644 --- a/.github/workflows/build_test_deploy.yml +++ b/.github/workflows/build_test_deploy.yml @@ -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 @@ -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} @@ -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 @@ -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 @@ -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 @@ -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 @@ -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 @@ -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 @@ -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 @@ -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} @@ -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 diff --git a/.github/workflows/trigger_release.yml b/.github/workflows/trigger_release.yml new file mode 100644 index 0000000000000..d7b79da4cf326 --- /dev/null +++ b/.github/workflows/trigger_release.yml @@ -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 }} diff --git a/package.json b/package.json index 0795404fc7c48..1cb9484c6c4cc 100644 --- a/package.json +++ b/package.json @@ -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", @@ -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", diff --git a/pnpm-lock.yaml b/pnpm-lock.yaml index c534f3220f2eb..4afcd59fe0530 100644 --- a/pnpm-lock.yaml +++ b/pnpm-lock.yaml @@ -78,6 +78,7 @@ importers: abort-controller: 3.0.0 alex: 9.1.0 amphtml-validator: 1.0.35 + ansi-escapes: 4.3.2 async-sema: 3.0.1 body-parser: 1.20.1 browserslist: 4.20.2 @@ -256,6 +257,7 @@ importers: abort-controller: 3.0.0 alex: 9.1.0 amphtml-validator: 1.0.35 + ansi-escapes: 4.3.2 async-sema: 3.0.1 body-parser: 1.20.1 browserslist: 4.20.2 @@ -4934,7 +4936,7 @@ packages: '@jest/transform': 27.0.6 '@jest/types': 27.5.1 '@types/node': 18.11.18 - ansi-escapes: 4.3.0 + ansi-escapes: 4.3.2 chalk: 4.1.2 emittery: 0.8.1 exit: 0.1.2 @@ -8121,6 +8123,12 @@ packages: dependencies: type-fest: 0.8.1 + /ansi-escapes/4.3.2: + resolution: {integrity: sha512-gKXj5ALrKWQLsYG9jlTRmR/xKluxHV+Z9QEwNIgCfM1/uwPMCuzVVnh5mwTd+OuBZcwSIMbqssNWRm1lE51QaQ==} + engines: {node: '>=8'} + dependencies: + type-fest: 0.21.3 + /ansi-regex/2.1.1: resolution: {integrity: sha512-TIGnTpdo+E3+pCyAluZvtED5p5wCqLdezCyhPZzKPcxvFplEt4i+W7OONCKgeZFT3+y5NZZfOOS/Bdcanm1MYA==} engines: {node: '>=0.10.0'} @@ -14485,7 +14493,7 @@ packages: resolution: {integrity: sha512-0crLweprevJ02tTuA6ThpoAERAGyVILC4sS74uib58Xf/zSr1/ZWtmm7D5CI+bSQEaA04f0K7idaHpQbSWgiVQ==} engines: {node: '>=8.0.0'} dependencies: - ansi-escapes: 4.3.0 + ansi-escapes: 4.3.2 chalk: 4.1.2 cli-cursor: 3.1.0 cli-width: 3.0.0 @@ -15890,7 +15898,7 @@ packages: '@jest/test-result': 27.5.1 '@jest/types': 27.5.1 '@types/node': 18.11.18 - ansi-escapes: 4.3.0 + ansi-escapes: 4.3.2 chalk: 4.1.2 jest-util: 27.5.1 string-length: 4.0.1 @@ -16797,7 +16805,7 @@ packages: resolution: {integrity: sha512-9fkkDevMefjg0mmzWFBW8YkFP91OrizzkW3diF7CpG+S2EYdy4+TVfGwz1zeF8x7hCx1ovSPTOE9Ngib74qqUg==} engines: {node: '>=10'} dependencies: - ansi-escapes: 4.3.0 + ansi-escapes: 4.3.2 cli-cursor: 3.1.0 slice-ansi: 4.0.0 wrap-ansi: 6.2.0 @@ -23615,7 +23623,7 @@ packages: resolution: {integrity: sha512-un0FmiRUQNr5PJqy9kP7c40F5BOfpGlYTrxonDChEZB7pzZxRNp/bt+ymiy9/npwXya9KH99nJ/GXFIiUkYGFQ==} engines: {node: '>=8'} dependencies: - ansi-escapes: 4.3.0 + ansi-escapes: 4.3.2 supports-hyperlinks: 2.1.0 dev: true @@ -24150,6 +24158,10 @@ packages: resolution: {integrity: sha512-Ne+eE4r0/iWnpAxD852z3A+N0Bt5RN//NjJwRd2VFHEmrywxf5vsZlh4R6lixl6B+wz/8d+maTSAkN1FIkI3LQ==} engines: {node: '>=10'} + /type-fest/0.21.3: + resolution: {integrity: sha512-t0rzBq87m3fVcduHDUFhKmyyX+9eo6WQjZvf51Ea/M0Q7+T374Jp1aUiyUl0GKxp8M/OETVHSDvmkyPgvX+X2w==} + engines: {node: '>=10'} + /type-fest/0.4.1: resolution: {integrity: sha512-IwzA/LSfD2vC1/YDYMv/zHP4rDF1usCwllsDpbolT3D4fUepIO7f9K70jjmUewU/LmGUKJcwcVtDCpnKk4BPMw==} engines: {node: '>=6'} diff --git a/scripts/start-release.js b/scripts/start-release.js new file mode 100644 index 0000000000000..2658f87f46af3 --- /dev/null +++ b/scripts/start-release.js @@ -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()