diff --git a/packages/notify/lib/action.mjs b/packages/notify/lib/action.mjs index 4388ce4..ea138a1 100644 --- a/packages/notify/lib/action.mjs +++ b/packages/notify/lib/action.mjs @@ -23,7 +23,7 @@ export async function action({ name }) { return false; } - const { markdown, levels } = createContent(all); + const { markdown, levels } = await createContent(all); logger.json({ levels }); diff --git a/packages/notify/lib/utils.mjs b/packages/notify/lib/utils.mjs index 5140fc4..3796343 100644 --- a/packages/notify/lib/utils.mjs +++ b/packages/notify/lib/utils.mjs @@ -119,7 +119,7 @@ const configs = { }, }; -function getlog(from, to) { +async function getlog(from, to) { console.log({ from, to }); return gitlog({ @@ -129,7 +129,7 @@ function getlog(from, to) { }); } -function getLogs() { +async function getLogs() { try { if (!GIT_PREVIOUS_COMMIT) { throw new Error('GIT_PREVIOUS_COMMIT is null'); @@ -159,14 +159,15 @@ const DEPOT_URL = `${PROJECT_WEB_URL}/d/${DEPOT_NAME}`; const headerPattern = /^(\w*)(?:\((\S*)\))?:\s?(.*)$/; -function getCommits() { +async function getCommits() { const io = !GIT_PREVIOUS_COMMIT || (GIT_COMMIT && GIT_COMMIT === GIT_PREVIOUS_COMMIT) ? [] : sortBy( Object.entries( groupBy( - getLogs().map(({ abbrevHash, hash, subject }) => ({ + // eslint-disable-next-line unicorn/no-await-expression-member + (await getLogs()).map(({ abbrevHash, hash, subject }) => ({ hash, abbrevHash, message: sync(subject, { headerPattern }), @@ -233,7 +234,7 @@ function short(hash) { return hash.slice(0, 7); } -export function createContent({ +export async function createContent({ project = '未命名项目', type, manual = true, @@ -241,8 +242,9 @@ export function createContent({ isLatest = false, image, version = true, + rc = false, }) { - const levels = getCommits(); + const levels = await getCommits(); return { levels: levels @@ -355,7 +357,9 @@ export function createContent({ type: 'text', value: `版本编号:${getVersion({ isLatest, - version, + version: rc + ? `${version}-rc${CI_BUILD_NUMBER}` + : version, })}`, }, ], diff --git a/packages/notify/package.json b/packages/notify/package.json index c4cf345..85a63ba 100644 --- a/packages/notify/package.json +++ b/packages/notify/package.json @@ -1,6 +1,6 @@ { "name": "@bring-it/notify", - "version": "0.3.4", + "version": "0.3.5", "description": "Send releases notifications", "license": "MIT", "author": { @@ -42,7 +42,7 @@ "devDependencies": { "conventional-commits-parser": "^5.0.0", "fast-clean": "^1.3.2", - "gitlog": "^4.0.8", + "gitlog": "^5.0.1", "lodash": "^4.17.21", "mdast-util-to-markdown": "^2.1.0", "semver": "^7.6.2" diff --git a/pnpm-lock.yaml b/pnpm-lock.yaml index 701ea41..002553d 100644 --- a/pnpm-lock.yaml +++ b/pnpm-lock.yaml @@ -69,8 +69,8 @@ importers: specifier: ^1.3.2 version: 1.3.2 gitlog: - specifier: ^4.0.8 - version: 4.0.8 + specifier: ^5.0.1 + version: 5.0.1 lodash: specifier: ^4.17.21 version: 4.17.21 @@ -1252,9 +1252,9 @@ packages: get-tsconfig@4.7.5: resolution: {integrity: sha512-ZCuZCnlqNzjb4QprAzXKdpp/gh6KTxSJuw3IBsPnV/7fV4NxC9ckB+vPTt8w7fJA0TaSD7c55BR47JD6MEDyDw==} - gitlog@4.0.8: - resolution: {integrity: sha512-FcTLP7Rc0H1vWXD+J/aj5JS1uiCEBblcYXlcacRAT73N26OMYFFzrBXYmDozmWlV2K7zwK5PrH16/nuRNhqSlQ==} - engines: {node: '>= 10.x'} + gitlog@5.0.1: + resolution: {integrity: sha512-cxKQGlSJkZn2KsSmiHh7UtjYgUio7cwHPmCW0w1cAdsARpfqHaDtrZtS8hs2/sAXySxn/baV0f7mzTXtS1d2Cg==} + engines: {node: '>= 20.x'} glob-parent@5.1.2: resolution: {integrity: sha512-AOIgSQCepiJYwP3ARnGx+5VnTu2HBYdzbGP45eLw1vr3zB3vZLeyed1sC9hnbcOc9/SrMyM5RPQrkGz4aS9Zow==} @@ -2284,9 +2284,6 @@ packages: tsconfig-paths@3.15.0: resolution: {integrity: sha512-2Ac2RgzDe/cn48GvOe3M+o82pEFewD3UPbyoUHHdKasHwJKjds4fLXWf/Ux5kATBKN20oaFGu+jbElp1pos0mg==} - tslib@2.6.3: - resolution: {integrity: sha512-xNvxJEOUiWPGhUuUdQgAJPKOOJfGnIyKySOc09XkKsgdUV/3E2zvwZYdejjmRgPCgcym1juLH3226yA7sEFJKQ==} - tweetnacl@0.14.5: resolution: {integrity: sha512-KXXFFdAbFXY4geFIwoyNK+f5Z1b7swfXABfL7HXCmoIWMKU3dmS26672A4EeQtDzLKy7SXmfBu51JolvEKwtGA==} @@ -3813,10 +3810,9 @@ snapshots: dependencies: resolve-pkg-maps: 1.0.0 - gitlog@4.0.8: + gitlog@5.0.1: dependencies: debug: 4.3.5 - tslib: 2.6.3 transitivePeerDependencies: - supports-color @@ -4819,8 +4815,6 @@ snapshots: minimist: 1.2.8 strip-bom: 3.0.0 - tslib@2.6.3: {} - tweetnacl@0.14.5: {} type-check@0.4.0: