Skip to content

Commit

Permalink
chore(repo): Introduce canary releases from main
Browse files Browse the repository at this point in the history
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.
  • Loading branch information
dimkl committed Oct 6, 2023
1 parent 22b8126 commit 9e08961
Show file tree
Hide file tree
Showing 3 changed files with 88 additions and 0 deletions.
69 changes: 69 additions & 0 deletions .github/workflows/release-canary.yml
Original file line number Diff line number Diff line change
@@ -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 }
})
}
1 change: 1 addition & 0 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -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",
Expand Down
18 changes: 18 additions & 0 deletions scripts/canary.mjs
Original file line number Diff line number Diff line change
@@ -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');
}

0 comments on commit 9e08961

Please sign in to comment.