0
Fork 0
mirror of https://github.com/logto-io/logto.git synced 2024-12-16 20:26:19 -05:00

refactor: update pubilsh flow

This commit is contained in:
Gao Sun 2023-04-02 17:05:18 +08:00
parent 3c84d81ff5
commit f97ebaa3db
No known key found for this signature in database
GPG key ID: 13EBE123E4773688
4 changed files with 18 additions and 79 deletions

View file

@ -15,22 +15,15 @@ So, we are using our own "grouping" release strategy in this monorepo:
### Core ### Core
The release group that includes the Logto core products, which consists of the following packages: The release group that includes the Logto core service and its schemas and cli, which consists of the following packages:
- @logto/console
- @logto/core (main) - @logto/core (main)
- @logto/integration-tests - @logto/schemas
- @logto/ui - @logto/cli
Their version will be in sync, and forms our main release.
### CLI
The release group that includes Logto CLI and its aliases:
- @logto/cli (main)
- @logto/create - @logto/create
Their versions will be always in sync, and forms our main release.
### Others ### Others
For simplicity, we will tag other **public** packages separately and publish them to NPM. But in most cases, no GitHub release will present for these packages. For simplicity, we will tag other **public** packages separately and publish them to NPM. But in most cases, no GitHub release will present for these packages.

View file

@ -5,14 +5,11 @@
"//": "CAUTION: When updating the fields below, you should also update README accordingly.", "//": "CAUTION: When updating the fields below, you should also update README accordingly.",
"fixed": [[ "fixed": [[
"@logto/core", "@logto/core",
"@logto/console", "@logto/schemas",
"@logto/integration-tests",
"@logto/ui",
"@logto/cli", "@logto/cli",
"@logto/create" "@logto/create"
]], ]],
"linked": [[ "linked": [[
"@logto/schemas",
"@logto/phrases", "@logto/phrases",
"@logto/phrases-ui" "@logto/phrases-ui"
]], ]],

View file

@ -1,17 +1,9 @@
name: Changesets name: Changesets
on: on:
workflow_dispatch: push:
inputs: branches:
releaseGroup: - master
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:
@ -19,16 +11,6 @@ concurrency:
jobs: jobs:
changesets: changesets:
strategy:
matrix:
# 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
steps: steps:
@ -55,19 +37,18 @@ jobs:
- name: Version packages - name: Version packages
run: | run: |
node .scripts/version.js ${{ matrix.group }} node .scripts/version.js
pnpm i --no-frozen-lockfile pnpm i --no-frozen-lockfile
git status git status
- name: Create pull request - name: Create pull request
if: github.event_name == 'workflow_dispatch' if: github.event_name == 'push'
uses: peter-evans/create-pull-request@v4 uses: peter-evans/create-pull-request@v4
with: with:
token: ${{ secrets.BOT_PAT }} token: ${{ secrets.BOT_PAT }}
commit-message: 'release: version ${{ matrix.group }} packages' commit-message: 'release: version packages'
committer: silverhand-bot <bot@silverhand.io> committer: silverhand-bot <bot@silverhand.io>
author: silverhand-bot <bot@silverhand.io> author: silverhand-bot <bot@silverhand.io>
base: master base: master
branch: release/version-${{ matrix.group }}-packages branch: release/version-packages
title: 'release: version ${{ matrix.group }} packages' title: 'release: version packages'
body: 'This is an automatic pull request from the result of `node .scripts/version.js ${{ matrix.group }}` command. Merge it will trigger the publish flow for versioned packages.'

View file

@ -2,38 +2,8 @@ import { exec } from 'node:child_process';
import { promisify } from 'node:util'; import { promisify } from 'node:util';
const execAsync = promisify(exec); const execAsync = promisify(exec);
const versionGroup = process.argv[2];
if (process.argv.length > 3) { const cmd = ('pnpm changeset version');
throw new Error('Extraneous arguments found. Only one optional argument for version group name is allowed.');
}
// 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(', ') + '.');
}
const { allPackages } = await import('./packages-meta.js');
const getIgnoreGroup = () => {
console.log(`=== Versioning ${versionGroup} group packages ===`);
return allPackages.filter(({ path }) => {
if (versionGroup === allowedGroups.toolkit) {
return !path.includes(allowedGroups.toolkit + '/');
}
return false;
});
}
const ignoreGroup = getIgnoreGroup();
const ignoreCmd = ignoreGroup
.map(({ name }) => ` \\\n --ignore ${name}`)
.join('');
const cmd = ('pnpm changeset version' + ignoreCmd);
const catchCmdError = ({ stderr, stdout, code }) => { const catchCmdError = ({ stderr, stdout, code }) => {
console.log(stdout); console.log(stdout);
@ -45,11 +15,9 @@ console.log(cmd);
await execAsync(cmd).catch(catchCmdError); await execAsync(cmd).catch(catchCmdError);
const filterCmd = ignoreGroup
.map(({ name }) => ` \\\n --filter \\!${name}`)
.join('');
// Manually run lifecycle script since changesets didn't // Manually run lifecycle script since changesets didn't
await execAsync(`pnpm -r ${filterCmd} version`).catch(catchCmdError); await execAsync(`pnpm -r version`).catch(catchCmdError);
// Sanity check for prepublish scripts // Sanity check for prepublish scripts
await execAsync(`pnpm -r ${filterCmd} prepublishOnly`).catch(catchCmdError); await execAsync(`pnpm -r prepack`).catch(catchCmdError);
await execAsync(`pnpm -r prepublishOnly`).catch(catchCmdError);