mirror of
https://github.com/logto-io/logto.git
synced 2025-03-24 22:41:28 -05:00
ci: manually dispatch and add sanity check in workflow (#2838)
This commit is contained in:
parent
6e2951fafc
commit
40980b3ada
3 changed files with 26 additions and 6 deletions
24
.github/workflows/changesets.yml
vendored
24
.github/workflows/changesets.yml
vendored
|
@ -1,9 +1,17 @@
|
||||||
name: Changesets
|
name: Changesets
|
||||||
|
|
||||||
on:
|
on:
|
||||||
push:
|
workflow_dispatch:
|
||||||
branches:
|
inputs:
|
||||||
- master
|
releaseGroup:
|
||||||
|
description: 'The release group to bump version and create pull request'
|
||||||
|
required: true
|
||||||
|
type: choice
|
||||||
|
# This should be synced with `/.scripts/version.js`
|
||||||
|
options:
|
||||||
|
- core
|
||||||
|
- toolkit
|
||||||
|
|
||||||
pull_request:
|
pull_request:
|
||||||
|
|
||||||
concurrency:
|
concurrency:
|
||||||
|
@ -13,7 +21,13 @@ jobs:
|
||||||
changesets:
|
changesets:
|
||||||
strategy:
|
strategy:
|
||||||
matrix:
|
matrix:
|
||||||
group: [core, toolkit]
|
# Multiline expression https://stackoverflow.com/a/67532120/12514940
|
||||||
|
group: |-
|
||||||
|
${{
|
||||||
|
github.event_name == 'pull_request' &&
|
||||||
|
fromJSON('["core", "toolkit"]') ||
|
||||||
|
fromJSON(format('["{0}"]', inputs.releaseGroup))
|
||||||
|
}}
|
||||||
|
|
||||||
runs-on: ubuntu-latest
|
runs-on: ubuntu-latest
|
||||||
|
|
||||||
|
@ -46,7 +60,7 @@ jobs:
|
||||||
git status
|
git status
|
||||||
|
|
||||||
- name: Create pull request
|
- name: Create pull request
|
||||||
if: github.event_name == 'push'
|
if: github.event_name == 'workflow_dispatch'
|
||||||
uses: peter-evans/create-pull-request@v4
|
uses: peter-evans/create-pull-request@v4
|
||||||
with:
|
with:
|
||||||
token: ${{ secrets.BOT_PAT }}
|
token: ${{ secrets.BOT_PAT }}
|
||||||
|
|
|
@ -9,6 +9,7 @@ if (process.argv.length > 3) {
|
||||||
}
|
}
|
||||||
|
|
||||||
// This is configured based on our practice. Change with care.
|
// This is configured based on our practice. Change with care.
|
||||||
|
// Should be synced with `/.github/workflows/changesets.yml`
|
||||||
const allowedGroups = { core: 'core', toolkit: 'toolkit' };
|
const allowedGroups = { core: 'core', toolkit: 'toolkit' };
|
||||||
if (!Object.values(allowedGroups).includes(versionGroup)) {
|
if (!Object.values(allowedGroups).includes(versionGroup)) {
|
||||||
throw new Error('Version group is invalid. Should be one of ' + Object.values(allowedGroups).join(', ') + '.');
|
throw new Error('Version group is invalid. Should be one of ' + Object.values(allowedGroups).join(', ') + '.');
|
||||||
|
@ -33,7 +34,8 @@ const ignoreCmd = getIgnoreGroup()
|
||||||
.join('');
|
.join('');
|
||||||
const cmd = ('pnpm changeset version' + ignoreCmd);
|
const cmd = ('pnpm changeset version' + ignoreCmd);
|
||||||
|
|
||||||
const catchCmdError = ({ stderr, code }) => {
|
const catchCmdError = ({ stderr, stdout, code }) => {
|
||||||
|
console.log(stdout);
|
||||||
console.error(stderr);
|
console.error(stderr);
|
||||||
process.exit(code ?? 1);
|
process.exit(code ?? 1);
|
||||||
};
|
};
|
||||||
|
@ -44,3 +46,6 @@ await execAsync(cmd).catch(catchCmdError);
|
||||||
|
|
||||||
// Manually run lifecycle script since changesets didn't
|
// Manually run lifecycle script since changesets didn't
|
||||||
await execAsync('pnpm -r version').catch(catchCmdError);
|
await execAsync('pnpm -r version').catch(catchCmdError);
|
||||||
|
|
||||||
|
// Sanity check for prepublish scripts
|
||||||
|
await execAsync('pnpm -r prepublishOnly').catch(catchCmdError);
|
||||||
|
|
|
@ -30,6 +30,7 @@
|
||||||
"dev": "tsc -p tsconfig.build.json --watch --preserveWatchOutput --incremental",
|
"dev": "tsc -p tsconfig.build.json --watch --preserveWatchOutput --incremental",
|
||||||
"lint": "eslint --ext .ts src",
|
"lint": "eslint --ext .ts src",
|
||||||
"lint:report": "pnpm lint --format json --output-file report.json",
|
"lint:report": "pnpm lint --format json --output-file report.json",
|
||||||
|
"prepublishOnly": "! ls alterations/next-*",
|
||||||
"prepack": "pnpm build",
|
"prepack": "pnpm build",
|
||||||
"test:only": "NODE_OPTIONS=--experimental-vm-modules jest",
|
"test:only": "NODE_OPTIONS=--experimental-vm-modules jest",
|
||||||
"test": "pnpm build:test && pnpm test:only",
|
"test": "pnpm build:test && pnpm test:only",
|
||||||
|
|
Loading…
Add table
Reference in a new issue