From 2dc571510b3cd5e0687e9de4c7fe31c1bbe18161 Mon Sep 17 00:00:00 2001 From: Dimitris Klouvas Date: Fri, 6 Oct 2023 17:20:58 +0300 Subject: [PATCH] chore(repo): Introduce canary releases from main The main branch will produce canary releases until the next major version is ready for release. To produce a staging and production release, open a PR from the main-v4 branch. --- .changeset/red-monkeys-sing.md | 5 ++++ .github/workflows/release-canary.yml | 36 ++++++++++++++++++++++++++++ package.json | 4 +++- scripts/canary.mjs | 18 ++++++++++++++ 4 files changed, 62 insertions(+), 1 deletion(-) create mode 100644 .changeset/red-monkeys-sing.md create mode 100644 .github/workflows/release-canary.yml create mode 100755 scripts/canary.mjs diff --git a/.changeset/red-monkeys-sing.md b/.changeset/red-monkeys-sing.md new file mode 100644 index 00000000000..2dacb87ff3d --- /dev/null +++ b/.changeset/red-monkeys-sing.md @@ -0,0 +1,5 @@ +--- +--- + +Introduce `@canary` releases and change current LTS branch to `main-v4` to be used as +base branch for `@staging` and `@latest` releases until next major version is stable. diff --git a/.github/workflows/release-canary.yml b/.github/workflows/release-canary.yml new file mode 100644 index 00000000000..4f08f5e8873 --- /dev/null +++ b/.github/workflows/release-canary.yml @@ -0,0 +1,36 @@ +name: Canary release +run-name: Canary release from ${{ github.ref_name }} + +on: + push: + branches: + - main + +concurrency: + group: ${{ github.workflow }}-${{ github.ref }} + cancel-in-progress: true + +jobs: + canary-release: + if: ${{ github.repository == 'clerkinc/javascript' }} + runs-on: ${{ vars.RUNNER_LARGE }} + env: + TURBO_TOKEN: ${{ secrets.TURBO_TOKEN }} + TURBO_TEAM: ${{ vars.TURBO_TEAM }} + TURBO_REMOTE_ONLY: true + steps: + - name: Checkout repo + uses: actions/checkout@v3 + + - name: Setup + uses: ./.github/actions/setup + + - name: Version packages for canary + id: version-packages + run: npm run version:canary | tail -1 >> "$GITHUB_OUTPUT" + + - name: Canary release + if: steps.version-packages.outputs.success == '1' + run: npm run release:canary + env: + NODE_AUTH_TOKEN: ${{ secrets.NPM_TOKEN }} diff --git a/package.json b/package.json index 9fcda4dd924..d13e99f9925 100644 --- a/package.json +++ b/package.json @@ -25,6 +25,7 @@ "nuke": "./scripts/nuke.sh", "prepare": "husky install", "release": "TURBO_FORCE=true FORCE_COLOR=1 npm run build -- --force && changeset publish && git push --follow-tags", + "release:canary": "TURBO_FORCE=true FORCE_COLOR=1 npm run build && changeset publish --tag canary --no-git-tag", "release:snapshot": "TURBO_FORCE=true FORCE_COLOR=1 npm run build && changeset publish --tag snapshot --no-git-tag", "release:staging": "TURBO_FORCE=true FORCE_COLOR=1 npm run build && changeset publish --tag staging --no-git-tag", "release:verdaccio": "if [ \"$(npm config get registry)\" = \"https://registry.npmjs.org/\" ]; then echo 'Error: Using default registry' && exit 1; else TURBO_FORCE=true TURBO_CONCURRENCY=4 npm run build && changeset publish --no-git-tag; fi", @@ -37,6 +38,7 @@ "test:integration:remix": "echo 'placeholder'", "update:lockfile": "npm run nuke && npm install -D --arch=x64 --platform=linux turbo && npm install -D --arch=arm64 --platform=darwin turbo", "version": "changeset version && ./scripts/version-info.sh", + "version:canary": "./scripts/canary.mjs", "version:snapshot": "./scripts/snapshot.mjs", "version:staging": "./scripts/staging.mjs", "yalc:all": "for d in packages/*/; do echo $d; cd $d; yalc push --replace --sig; cd '../../'; done" @@ -94,4 +96,4 @@ "node": ">=16.8.0", "npm": ">=8.5.0" } -} +} \ No newline at end of file diff --git a/scripts/canary.mjs b/scripts/canary.mjs new file mode 100755 index 00000000000..e3e552c01c4 --- /dev/null +++ b/scripts/canary.mjs @@ -0,0 +1,18 @@ +#!/usr/bin/env zx + +import 'zx/globals'; + +import { constants } from './common.mjs'; + +await $`npx json -I -f ${constants.ChangesetConfigFile} -e "this.changelog = false"`; + +const res = await $`npx changeset version --snapshot canary`; +const success = !res.stderr.includes('No unreleased changesets found'); + +await $`git checkout HEAD -- ${constants.ChangesetConfigFile}`; + +if (success) { + echo('success=1'); +} else { + echo('success=0'); +}