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

ci: separate release groups (#2775)

This commit is contained in:
Gao Sun 2022-12-30 13:49:00 +08:00 committed by GitHub
parent f42b82d13b
commit f7a2bdf7a8
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
4 changed files with 52 additions and 9 deletions

View file

@ -11,14 +11,16 @@ concurrency:
jobs: jobs:
changesets: changesets:
strategy:
matrix:
group: [core, toolkit]
runs-on: ubuntu-latest runs-on: ubuntu-latest
steps: steps:
- uses: actions/checkout@v3 - uses: actions/checkout@v3
with: with:
# Set Git operations with the bot PAT since we have tag protection rule
token: ${{ secrets.BOT_PAT }} token: ${{ secrets.BOT_PAT }}
fetch-depth: 0
- name: Setup Node and pnpm - name: Setup Node and pnpm
uses: silverhand-io/actions-node-pnpm-run-steps@v2 uses: silverhand-io/actions-node-pnpm-run-steps@v2
@ -39,7 +41,7 @@ jobs:
- name: Version packages - name: Version packages
run: | run: |
pnpm changeset version node .scripts/version.js ${{ matrix.group }}
pnpm i --no-frozen-lockfile pnpm i --no-frozen-lockfile
git status git status
@ -48,10 +50,10 @@ jobs:
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 packages' commit-message: 'release: version ${{ matrix.group }} 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-packages branch: release/version-${{ matrix.group }}-packages
title: 'release: version packages' title: 'release: version ${{ matrix.group }} packages'
body: 'This is an automatic pull request from the result of `pnpm changeset version` command. Merge it will trigger the publish flow for versioned 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.'

41
.scripts/version.js Normal file
View file

@ -0,0 +1,41 @@
import { exec } from 'node:child_process';
import { promisify } from 'node:util';
const execAsync = promisify(exec);
const versionGroup = process.argv[2];
if (process.argv.length > 3) {
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.
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 ignoreCmd = getIgnoreGroup()
.map(({ name }) => ` \\\n --ignore ${name}`)
.join('');
const cmd = ('pnpm changeset version' + ignoreCmd);
console.log(cmd);
await execAsync(cmd).catch(({ stderr, code }) => {
console.error(stderr);
process.exit(code ?? 1);
});

View file

@ -21,7 +21,7 @@
}, },
"devDependencies": { "devDependencies": {
"@jest/types": "^29.1.2", "@jest/types": "^29.1.2",
"@logto/connector-kit": "workspace:1.0.0-beta.30", "@logto/connector-kit": "workspace:*",
"@logto/js": "1.0.0-beta.14", "@logto/js": "1.0.0-beta.14",
"@logto/node": "1.0.0-beta.14", "@logto/node": "1.0.0-beta.14",
"@logto/schemas": "workspace:*", "@logto/schemas": "workspace:*",

View file

@ -462,7 +462,7 @@ importers:
packages/integration-tests: packages/integration-tests:
specifiers: specifiers:
'@jest/types': ^29.1.2 '@jest/types': ^29.1.2
'@logto/connector-kit': workspace:1.0.0-beta.30 '@logto/connector-kit': workspace:*
'@logto/js': 1.0.0-beta.14 '@logto/js': 1.0.0-beta.14
'@logto/node': 1.0.0-beta.14 '@logto/node': 1.0.0-beta.14
'@logto/schemas': workspace:* '@logto/schemas': workspace:*