Skip to content

Commit f97ebaa

Browse files
committed
refactor: update pubilsh flow
1 parent 3c84d81 commit f97ebaa

File tree

4 files changed

+18
-79
lines changed

4 files changed

+18
-79
lines changed

.changeset/README.md

Lines changed: 5 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -15,22 +15,15 @@ So, we are using our own "grouping" release strategy in this monorepo:
1515

1616
### Core
1717

18-
The release group that includes the Logto core products, which consists of the following packages:
18+
The release group that includes the Logto core service and its schemas and cli, which consists of the following packages:
1919

20-
- @logto/console
2120
- @logto/core (main)
22-
- @logto/integration-tests
23-
- @logto/ui
24-
25-
Their version will be in sync, and forms our main release.
26-
27-
### CLI
28-
29-
The release group that includes Logto CLI and its aliases:
30-
31-
- @logto/cli (main)
21+
- @logto/schemas
22+
- @logto/cli
3223
- @logto/create
3324

25+
Their versions will be always in sync, and forms our main release.
26+
3427
### Others
3528

3629
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.

.changeset/config.json

Lines changed: 1 addition & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -5,14 +5,11 @@
55
"//": "CAUTION: When updating the fields below, you should also update README accordingly.",
66
"fixed": [[
77
"@logto/core",
8-
"@logto/console",
9-
"@logto/integration-tests",
10-
"@logto/ui",
8+
"@logto/schemas",
119
"@logto/cli",
1210
"@logto/create"
1311
]],
1412
"linked": [[
15-
"@logto/schemas",
1613
"@logto/phrases",
1714
"@logto/phrases-ui"
1815
]],

.github/workflows/changesets.yml

Lines changed: 8 additions & 27 deletions
Original file line numberDiff line numberDiff line change
@@ -1,34 +1,16 @@
11
name: Changesets
22

33
on:
4-
workflow_dispatch:
5-
inputs:
6-
releaseGroup:
7-
description: 'The release group to bump version and create pull request'
8-
required: true
9-
type: choice
10-
# This should be synced with `/.scripts/version.js`
11-
options:
12-
- core
13-
- toolkit
14-
4+
push:
5+
branches:
6+
- master
157
pull_request:
168

179
concurrency:
1810
group: ${{ github.workflow }}-${{ github.head_ref || github.run_id }}
1911

2012
jobs:
2113
changesets:
22-
strategy:
23-
matrix:
24-
# Multiline expression https://stackoverflow.com/a/67532120/12514940
25-
group: |-
26-
${{
27-
github.event_name == 'pull_request' &&
28-
fromJSON('["core", "toolkit"]') ||
29-
fromJSON(format('["{0}"]', inputs.releaseGroup))
30-
}}
31-
3214
runs-on: ubuntu-latest
3315

3416
steps:
@@ -55,19 +37,18 @@ jobs:
5537
5638
- name: Version packages
5739
run: |
58-
node .scripts/version.js ${{ matrix.group }}
40+
node .scripts/version.js
5941
pnpm i --no-frozen-lockfile
6042
git status
6143
6244
- name: Create pull request
63-
if: github.event_name == 'workflow_dispatch'
45+
if: github.event_name == 'push'
6446
uses: peter-evans/create-pull-request@v4
6547
with:
6648
token: ${{ secrets.BOT_PAT }}
67-
commit-message: 'release: version ${{ matrix.group }} packages'
49+
commit-message: 'release: version packages'
6850
committer: silverhand-bot <[email protected]>
6951
author: silverhand-bot <[email protected]>
7052
base: master
71-
branch: release/version-${{ matrix.group }}-packages
72-
title: 'release: version ${{ matrix.group }} packages'
73-
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.'
53+
branch: release/version-packages
54+
title: 'release: version packages'

.scripts/version.js

Lines changed: 4 additions & 36 deletions
Original file line numberDiff line numberDiff line change
@@ -2,38 +2,8 @@ import { exec } from 'node:child_process';
22
import { promisify } from 'node:util';
33

44
const execAsync = promisify(exec);
5-
const versionGroup = process.argv[2];
65

7-
if (process.argv.length > 3) {
8-
throw new Error('Extraneous arguments found. Only one optional argument for version group name is allowed.');
9-
}
10-
11-
// This is configured based on our practice. Change with care.
12-
// Should be synced with `/.github/workflows/changesets.yml`
13-
const allowedGroups = { core: 'core', toolkit: 'toolkit' };
14-
if (!Object.values(allowedGroups).includes(versionGroup)) {
15-
throw new Error('Version group is invalid. Should be one of ' + Object.values(allowedGroups).join(', ') + '.');
16-
}
17-
18-
const { allPackages } = await import('./packages-meta.js');
19-
20-
const getIgnoreGroup = () => {
21-
console.log(`=== Versioning ${versionGroup} group packages ===`);
22-
23-
return allPackages.filter(({ path }) => {
24-
if (versionGroup === allowedGroups.toolkit) {
25-
return !path.includes(allowedGroups.toolkit + '/');
26-
}
27-
28-
return false;
29-
});
30-
}
31-
32-
const ignoreGroup = getIgnoreGroup();
33-
const ignoreCmd = ignoreGroup
34-
.map(({ name }) => ` \\\n --ignore ${name}`)
35-
.join('');
36-
const cmd = ('pnpm changeset version' + ignoreCmd);
6+
const cmd = ('pnpm changeset version');
377

388
const catchCmdError = ({ stderr, stdout, code }) => {
399
console.log(stdout);
@@ -45,11 +15,9 @@ console.log(cmd);
4515

4616
await execAsync(cmd).catch(catchCmdError);
4717

48-
const filterCmd = ignoreGroup
49-
.map(({ name }) => ` \\\n --filter \\!${name}`)
50-
.join('');
5118
// Manually run lifecycle script since changesets didn't
52-
await execAsync(`pnpm -r ${filterCmd} version`).catch(catchCmdError);
19+
await execAsync(`pnpm -r version`).catch(catchCmdError);
5320

5421
// Sanity check for prepublish scripts
55-
await execAsync(`pnpm -r ${filterCmd} prepublishOnly`).catch(catchCmdError);
22+
await execAsync(`pnpm -r prepack`).catch(catchCmdError);
23+
await execAsync(`pnpm -r prepublishOnly`).catch(catchCmdError);

0 commit comments

Comments
 (0)