From 9e08961bf40e5f00b59d9a10f5648c74ca28115c 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 clerk-v4 branch. --- .github/workflows/release-canary.yml | 69 ++++++++++++++++++++++++++++ package.json | 1 + scripts/canary.mjs | 18 ++++++++ 3 files changed, 88 insertions(+) create mode 100644 .github/workflows/release-canary.yml create mode 100755 scripts/canary.mjs diff --git a/.github/workflows/release-canary.yml b/.github/workflows/release-canary.yml new file mode 100644 index 00000000000..0ea16d637f4 --- /dev/null +++ b/.github/workflows/release-canary.yml @@ -0,0 +1,69 @@ +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: ubuntu-latest + 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 }} + + - name: Trigger workflows on related repos + uses: actions/github-script@v6 + with: + result-encoding: string + retries: 3 + retry-exempt-status-codes: 400,401 + github-token: ${{ secrets.CLERK_COOKIE_PAT }} + script: | + const clerkjsVersion = require('./packages/clerk-js/package.json').version; + const nextjsVersion = require('./packages/nextjs/package.json').version; + + if (clerkjsVersion.includes('canary')) { + console.log('clerk-js changed, will notify clerkinc/cloudflare-workers'); + github.rest.actions.createWorkflowDispatch({ + owner: 'clerkinc', + repo: 'cloudflare-workers', + workflow_id: 'release-canary-clerkjs-proxy.yml', + ref: 'main', + inputs: { version: clerkjsVersion } + }) + } + + if (nextjsVersion.includes('canary')) { + console.log('clerk/nextjs changed, will notify clerkinc/accounts'); + github.rest.actions.createWorkflowDispatch({ + owner: 'clerkinc', + repo: 'accounts', + workflow_id: 'release-canary.yml', + ref: 'main', + inputs: { version: nextjsVersion } + }) + } diff --git a/package.json b/package.json index 07c90191886..a4c29f80078 100644 --- a/package.json +++ b/package.json @@ -78,6 +78,7 @@ "version": "npx changeset version && ./scripts/version-info.sh", "version:snapshot": "./scripts/snapshot.mjs", "version:staging": "./scripts/staging.mjs", + "version:canary": "./scripts/canary.mjs", "release": "FORCE_COLOR=1 TURBO_CONCURRENCY=4 npm run build -- --force && npm run test && npx changeset publish && git push --follow-tags", "release:snapshot": "FORCE_COLOR=1 TURBO_CONCURRENCY=4 npm run build && npx changeset publish --tag snapshot --no-git-tag", "release:staging": "FORCE_COLOR=1 TURBO_CONCURRENCY=4 npm run build && npx changeset publish --tag staging --no-git-tag", 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'); +}