From e7f703cc274dbea81d64d77d1ad88fd515ee4fe5 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E9=98=BFCai?= Date: Wed, 13 Nov 2024 16:24:09 +0800 Subject: [PATCH 1/4] fix(ci): exact tag date version chore(ci): `pull-request.yml` only running in Tencent/tdesign --- .github/workflows/pull-request.yml | 1 + packages/auto-release/src/utils.ts | 15 ++++++++++----- 2 files changed, 11 insertions(+), 5 deletions(-) diff --git a/.github/workflows/pull-request.yml b/.github/workflows/pull-request.yml index 2de2ac78..6b619ad5 100644 --- a/.github/workflows/pull-request.yml +++ b/.github/workflows/pull-request.yml @@ -8,6 +8,7 @@ on: jobs: modify-services: + if: github.repository == 'Tencent/tdesign' runs-on: ubuntu-latest outputs: services-changed: ${{ steps.services-changed.outputs.changed }} diff --git a/packages/auto-release/src/utils.ts b/packages/auto-release/src/utils.ts index b706ce9a..a15fd5c5 100644 --- a/packages/auto-release/src/utils.ts +++ b/packages/auto-release/src/utils.ts @@ -38,10 +38,10 @@ export function getReleaseData() { /** * @description 检查日期是否在指定日期范围内 * 在每个月的1号、8号、15号、22号生成 - * 1号生成上个月的22号到最后一天的版本 - * 8号生成这个月的1号到7号的版本 - * 15号生成这个月的8号到14号的版本 - * 22号生成这个月的15号到21号的版本 + * 1号(原应在29号):生成上个月的22号 - 最后一天的版本(原应在28号) + * 8号:生成这个月的1号 - 7号的版本 + * 15号:生成这个月的8号 - 14号的版本 + * 22号:生成这个月的15号 - 21号的版本 */ let START_DATE = ''; @@ -65,19 +65,24 @@ export function getReleaseData() { const monthShort = today.toLocaleString('en-US', { month: 'short' }); const year = today.getFullYear(); let times = '1st'; + let tagDay = today.getDate(); console.log('today', today.getDate()); switch (today.getDate()) { case 1: + tagDay = 28; times = '4th'; break; case 8: + tagDay = 7; times = '1st'; break; case 15: + tagDay = 14; times = '2nd'; break; case 22: + tagDay = 21; times = '3rd'; break; default: @@ -85,7 +90,7 @@ export function getReleaseData() { break; } - const tag = `v${today.getFullYear()}.${today.getMonth() + 1}.${today.getDate()}`; + const tag = `v${today.getFullYear()}.${today.getMonth() + 1}.${tagDay}`; const title = `TDesign Weekly Release (${monthShort} ${times} ${year})`; console.log('tag', tag); From 7f22efd67fc6484bcb3eeee2caa240d667ebd560 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E9=98=BFCai?= Date: Wed, 13 Nov 2024 18:55:07 +0800 Subject: [PATCH 2/4] fix: fix the month number of release tag in case 1 --- packages/auto-release/src/utils.ts | 19 ++++++++++++------- 1 file changed, 12 insertions(+), 7 deletions(-) diff --git a/packages/auto-release/src/utils.ts b/packages/auto-release/src/utils.ts index a15fd5c5..5e88159b 100644 --- a/packages/auto-release/src/utils.ts +++ b/packages/auto-release/src/utils.ts @@ -61,16 +61,21 @@ export function getReleaseData() { } console.log(`今天是:${today},开始日期:${START_DATE},结束日期:${END_DATE}`); - // 标题 - const monthShort = today.toLocaleString('en-US', { month: 'short' }); - const year = today.getFullYear(); - let times = '1st'; + // release tag & 标题 + let monthShort = today.toLocaleString('en-US', { month: 'short' }); + + const tagYear = today.getFullYear(); + let tagMonth = today.getMonth() + 1; let tagDay = today.getDate(); + let times = '1st'; + console.log('today', today.getDate()); switch (today.getDate()) { case 1: tagDay = 28; + tagMonth = today.getMonth(); + monthShort = new Date(today.getFullYear(), today.getMonth() - 1).toLocaleString('en-US', { month: 'short' }); times = '4th'; break; case 8: @@ -86,12 +91,12 @@ export function getReleaseData() { times = '3rd'; break; default: - times = '1st'; + console.error('日期不在指定范围内'); break; } - const tag = `v${today.getFullYear()}.${today.getMonth() + 1}.${tagDay}`; - const title = `TDesign Weekly Release (${monthShort} ${times} ${year})`; + const tag = `v${tagYear}.${tagMonth}.${tagDay}`; + const title = `TDesign Weekly Release (${monthShort} ${times} ${tagYear})`; console.log('tag', tag); console.log('title', title); From 659fa61924b4c0f69b54c85b31eb0b017fc0cd13 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E9=98=BFCai?= Date: Wed, 13 Nov 2024 19:20:05 +0800 Subject: [PATCH 3/4] fix: various scenarios of date boundaries --- packages/auto-release/src/utils.ts | 17 ++++++++--------- 1 file changed, 8 insertions(+), 9 deletions(-) diff --git a/packages/auto-release/src/utils.ts b/packages/auto-release/src/utils.ts index 5e88159b..15e89a4e 100644 --- a/packages/auto-release/src/utils.ts +++ b/packages/auto-release/src/utils.ts @@ -47,7 +47,7 @@ export function getReleaseData() { let START_DATE = ''; let END_DATE = ''; - const today = new Date(); + const today = new Date('2024-06-01'); // 获取昨天的日期并且只取年月日格式化成'yyyy-mm-dd' const someDaysAgo = new Date(today); @@ -62,20 +62,19 @@ export function getReleaseData() { console.log(`今天是:${today},开始日期:${START_DATE},结束日期:${END_DATE}`); // release tag & 标题 - let monthShort = today.toLocaleString('en-US', { month: 'short' }); - - const tagYear = today.getFullYear(); - let tagMonth = today.getMonth() + 1; let tagDay = today.getDate(); + console.log('today', tagDay); + + const tagYear = (today.getMonth() === 0 && today.getDate() === 1) ? today.getFullYear() - 1 : today.getFullYear(); + const tagMonth = (today.getMonth() === 0 && tagDay === 1) ? 12 : today.getMonth() + (tagDay === 1 ? 0 : 1); + + const monthShort = new Date(tagYear, tagMonth - 1).toLocaleString('en-US', { month: 'short' }); let times = '1st'; - console.log('today', today.getDate()); - switch (today.getDate()) { + switch (tagDay) { case 1: tagDay = 28; - tagMonth = today.getMonth(); - monthShort = new Date(today.getFullYear(), today.getMonth() - 1).toLocaleString('en-US', { month: 'short' }); times = '4th'; break; case 8: From 0a0f79dcaec57cabcc40f9621b2cced9559cb644 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E9=98=BFCai?= Date: Thu, 14 Nov 2024 14:33:33 +0800 Subject: [PATCH 4/4] fix: remove redundant data --- packages/auto-release/src/utils.ts | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/packages/auto-release/src/utils.ts b/packages/auto-release/src/utils.ts index 15e89a4e..119f7b72 100644 --- a/packages/auto-release/src/utils.ts +++ b/packages/auto-release/src/utils.ts @@ -47,7 +47,7 @@ export function getReleaseData() { let START_DATE = ''; let END_DATE = ''; - const today = new Date('2024-06-01'); + const today = new Date(); // 获取昨天的日期并且只取年月日格式化成'yyyy-mm-dd' const someDaysAgo = new Date(today);