Skip to content
Merged
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
93 changes: 48 additions & 45 deletions .github/workflows/release.yml
Original file line number Diff line number Diff line change
Expand Up @@ -84,28 +84,29 @@ jobs:
const clerkUiVersion = require('./packages/ui/package.json').version;
const nextjsVersion = require('./packages/nextjs/package.json').version;

github.rest.actions.createWorkflowDispatch({
owner: 'clerk',
repo: 'sdk-infra-workers',
workflow_id: 'update-pkg-versions.yml',
ref: 'main',
inputs: { clerkjsVersion, clerkUiVersion }
})

github.rest.actions.createWorkflowDispatch({
owner: 'clerk',
repo: 'dashboard',
workflow_id: 'prepare-nextjs-sdk-update.yml',
ref: 'main',
inputs: { version: nextjsVersion }
})

github.rest.actions.createWorkflowDispatch({
owner: 'clerk',
repo: 'clerk-docs',
workflow_id: 'typedoc.yml',
ref: 'main',
})
const dispatches = [
github.rest.actions.createWorkflowDispatch({
owner: 'clerk',
repo: 'sdk-infra-workers',
workflow_id: 'update-pkg-versions.yml',
ref: 'main',
inputs: { clerkjsVersion, clerkUiVersion }
}),
github.rest.actions.createWorkflowDispatch({
owner: 'clerk',
repo: 'dashboard',
workflow_id: 'prepare-nextjs-sdk-update.yml',
ref: 'main',
inputs: { version: nextjsVersion }
}),
github.rest.actions.createWorkflowDispatch({
owner: 'clerk',
repo: 'clerk-docs',
workflow_id: 'typedoc.yml',
ref: 'main',
}),
];
await Promise.all(dispatches);
} else{
core.warning("Changeset in pre-mode should not prepare a ClerkJS production release")
}
Expand Down Expand Up @@ -185,25 +186,31 @@ jobs:
const clerkUiVersion = require('./packages/ui/package.json').version;
const nextjsVersion = require('./packages/nextjs/package.json').version;

github.rest.actions.createWorkflowDispatch({
owner: 'clerk',
repo: 'sdk-infra-workers',
workflow_id: 'update-pkg-versions.yml',
ref: 'main',
inputs: { clerkjsVersion, clerkUiVersion, sourceCommit: context.sha }
})

if (nextjsVersion.includes('canary')) {
console.log('clerk/nextjs changed, will notify clerk/accounts');
const dispatches = [
github.rest.actions.createWorkflowDispatch({
owner: 'clerk',
repo: 'accounts',
workflow_id: 'release-staging.yml',
repo: 'sdk-infra-workers',
workflow_id: 'update-pkg-versions.yml',
ref: 'main',
inputs: { version: nextjsVersion }
})
inputs: { clerkjsVersion, clerkUiVersion, sourceCommit: context.sha }
}),
];

if (nextjsVersion.includes('canary')) {
console.log('clerk/nextjs changed, will notify clerk/accounts');
dispatches.push(
github.rest.actions.createWorkflowDispatch({
owner: 'clerk',
repo: 'accounts',
workflow_id: 'release-staging.yml',
ref: 'main',
inputs: { version: nextjsVersion }
}),
);
}

await Promise.all(dispatches);

snapshot-release:
name: Snapshot release
if: ${{ github.event_name == 'issue_comment' && startsWith(github.event.comment.body, '!snapshot') && github.repository == 'clerk/javascript' && github.event.issue.pull_request }}
Expand All @@ -213,6 +220,7 @@ jobs:
permissions:
contents: read
id-token: write
pull-requests: write
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Needed so that GITHUB_TOKEN can react to !snapshot comments and write the response when the release finishes.


steps:
- name: Limit action to Clerk members
Expand Down Expand Up @@ -249,16 +257,14 @@ jobs:
result-encoding: string
retries: 3
retry-exempt-status-codes: 400,401
github-token: ${{ secrets.CLERK_COOKIE_PAT }}
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

GITHUB_TOKEN is the default value, no need to be explicit, see https://github.com/actions/github-script/tree/v7

script: |
const commentCreated = new Date(context.payload.comment.created_at);

const pr = await github.rest.pulls.get({
const { data: pr } = await github.rest.pulls.get({
owner: 'clerk',
repo: 'javascript',
pull_number: context.issue.number,
});

const prLastUpdated = new Date(pr.updated_at);

if (prLastUpdated > commentCreated) {
Expand Down Expand Up @@ -291,15 +297,15 @@ jobs:

- name: Version packages for snapshot
id: version-packages
run: npm run version-packages:snapshot ${{ steps.extract-snapshot-name.outputs.name }} | tail -1 >> "$GITHUB_OUTPUT"
run: pnpm version-packages:snapshot ${{ steps.extract-snapshot-name.outputs.name }} | tail -1 >> "$GITHUB_OUTPUT"

- name: Build release
if: steps.version-packages.outputs.success == '1'
run: npx turbo build $TURBO_ARGS
run: pnpm turbo build $TURBO_ARGS

- name: Snapshot release
if: steps.version-packages.outputs.success == '1'
run: npm run release:snapshot
run: pnpm release:snapshot
env:
NPM_CONFIG_PROVENANCE: true

Expand Down Expand Up @@ -335,15 +341,13 @@ jobs:
if: steps.version-packages.outputs.success == '1'
uses: peter-evans/create-or-update-comment@v3.0.0
with:
token: ${{ secrets.CLERK_COOKIE_PAT }}
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

GITHUB_TOKEN is the default value, no need to be explicit, see https://github.com/peter-evans/create-or-update-comment/tree/v3.0.0

comment-id: ${{ github.event.comment.id }}
reactions: heart

- name: Minimize previous snapshot comments
if: steps.version-packages.outputs.success == '1'
uses: actions/github-script@v7
with:
github-token: ${{ secrets.CLERK_COOKIE_PAT }}
script: |
const { data: comments } = await github.rest.issues.listComments({
owner: context.repo.owner,
Expand Down Expand Up @@ -373,7 +377,6 @@ jobs:
if: steps.version-packages.outputs.success == '1'
uses: peter-evans/create-or-update-comment@v3.0.0
with:
token: ${{ secrets.CLERK_COOKIE_PAT }}
issue-number: ${{ github.event.issue.number }}
body: |
Hey @${{ github.event.comment.user.login }} - the snapshot version command generated the following package versions:
Expand Down