0
Fork 0
mirror of https://github.com/logto-io/logto.git synced 2025-03-17 22:31:28 -05:00

ci: manually dispatch and add sanity check in workflow (#2838)

This commit is contained in:
Gao Sun 2023-01-07 21:14:17 +08:00 committed by GitHub
parent 6e2951fafc
commit 40980b3ada
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
3 changed files with 26 additions and 6 deletions

View file

@ -1,9 +1,17 @@
name: Changesets
on:
push:
branches:
- master
workflow_dispatch:
inputs:
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:
concurrency:
@ -13,7 +21,13 @@ jobs:
changesets:
strategy:
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
@ -46,7 +60,7 @@ jobs:
git status
- name: Create pull request
if: github.event_name == 'push'
if: github.event_name == 'workflow_dispatch'
uses: peter-evans/create-pull-request@v4
with:
token: ${{ secrets.BOT_PAT }}

View file

@ -9,6 +9,7 @@ if (process.argv.length > 3) {
}
// This is configured based on our practice. Change with care.
// Should be synced with `/.github/workflows/changesets.yml`
const allowedGroups = { core: 'core', toolkit: 'toolkit' };
if (!Object.values(allowedGroups).includes(versionGroup)) {
throw new Error('Version group is invalid. Should be one of ' + Object.values(allowedGroups).join(', ') + '.');
@ -33,7 +34,8 @@ const ignoreCmd = getIgnoreGroup()
.join('');
const cmd = ('pnpm changeset version' + ignoreCmd);
const catchCmdError = ({ stderr, code }) => {
const catchCmdError = ({ stderr, stdout, code }) => {
console.log(stdout);
console.error(stderr);
process.exit(code ?? 1);
};
@ -44,3 +46,6 @@ await execAsync(cmd).catch(catchCmdError);
// Manually run lifecycle script since changesets didn't
await execAsync('pnpm -r version').catch(catchCmdError);
// Sanity check for prepublish scripts
await execAsync('pnpm -r prepublishOnly').catch(catchCmdError);

View file

@ -30,6 +30,7 @@
"dev": "tsc -p tsconfig.build.json --watch --preserveWatchOutput --incremental",
"lint": "eslint --ext .ts src",
"lint:report": "pnpm lint --format json --output-file report.json",
"prepublishOnly": "! ls alterations/next-*",
"prepack": "pnpm build",
"test:only": "NODE_OPTIONS=--experimental-vm-modules jest",
"test": "pnpm build:test && pnpm test:only",