diff --git a/.backportrc.json b/.backportrc.json index 8be51399..570748c4 100644 --- a/.backportrc.json +++ b/.backportrc.json @@ -8,8 +8,6 @@ "prTitle": "{{sourcePullRequest.title}} (backport #{{sourcePullRequest.number}})", "targetBranchChoices": [ "main", - "maintenance/v5.0", - "maintenance/v5.1", "maintenance/v5.2", "maintenance/v5.3" ], diff --git a/.github/workflows/auto-tag-dev-v5.2.yml b/.github/workflows/auto-tag-dev-v5.2.yml index fb94605b..8b530133 100644 --- a/.github/workflows/auto-tag-dev-v5.2.yml +++ b/.github/workflows/auto-tag-dev-v5.2.yml @@ -56,4 +56,4 @@ jobs: git config user.name "github-actions" git config user.email "github-actions@github.com" - name: Tag PreRelease - run: yarn tag-release --idempotent --no-sign --push --prerelease=dev + run: yarn tag-release --idempotent --no-sign --push --prerelease=dev --release-line=5.2 diff --git a/.github/workflows/auto-tag-dev-v5.3.yml b/.github/workflows/auto-tag-dev-v5.3.yml index ffd8ff20..eb9fdabd 100644 --- a/.github/workflows/auto-tag-dev-v5.3.yml +++ b/.github/workflows/auto-tag-dev-v5.3.yml @@ -56,4 +56,4 @@ jobs: git config user.name "github-actions" git config user.email "github-actions@github.com" - name: Tag PreRelease - run: yarn tag-release --idempotent --no-sign --push --prerelease=dev + run: yarn tag-release --idempotent --no-sign --push --prerelease=dev --release-line=5.3 diff --git a/.github/workflows/auto-tag-dev.yml b/.github/workflows/auto-tag-dev.yml index 06843c3f..430a99ff 100644 --- a/.github/workflows/auto-tag-dev.yml +++ b/.github/workflows/auto-tag-dev.yml @@ -55,4 +55,4 @@ jobs: git config user.name "github-actions" git config user.email "github-actions@github.com" - name: Tag PreRelease - run: yarn tag-release --idempotent --no-sign --push --prerelease=dev + run: yarn tag-release --idempotent --no-sign --push --prerelease=dev --release-line=5.4 diff --git a/.github/workflows/auto-tag-releases-v5.2.yml b/.github/workflows/auto-tag-releases-v5.2.yml index 418234be..d92193a1 100644 --- a/.github/workflows/auto-tag-releases-v5.2.yml +++ b/.github/workflows/auto-tag-releases-v5.2.yml @@ -56,4 +56,4 @@ jobs: git config user.name "github-actions" git config user.email "github-actions@github.com" - name: Tag Release - run: "yarn tag-release --idempotent --no-sign --push " + run: yarn tag-release --idempotent --no-sign --push --release-line=5.2 diff --git a/.github/workflows/auto-tag-releases-v5.3.yml b/.github/workflows/auto-tag-releases-v5.3.yml index a245957b..726f8776 100644 --- a/.github/workflows/auto-tag-releases-v5.3.yml +++ b/.github/workflows/auto-tag-releases-v5.3.yml @@ -56,4 +56,4 @@ jobs: git config user.name "github-actions" git config user.email "github-actions@github.com" - name: Tag Release - run: "yarn tag-release --idempotent --no-sign --push " + run: yarn tag-release --idempotent --no-sign --push --release-line=5.3 diff --git a/.github/workflows/auto-tag-releases.yml b/.github/workflows/auto-tag-releases.yml index c482a822..dc6a76e1 100644 --- a/.github/workflows/auto-tag-releases.yml +++ b/.github/workflows/auto-tag-releases.yml @@ -55,4 +55,4 @@ jobs: git config user.name "github-actions" git config user.email "github-actions@github.com" - name: Tag Release - run: "yarn tag-release --idempotent --no-sign --push " + run: yarn tag-release --idempotent --no-sign --push --release-line=5.4 diff --git a/.github/workflows/upgrade-maintenance-v5.2.yml b/.github/workflows/upgrade-maintenance-v5.2.yml index 6401fb18..415d5da0 100644 --- a/.github/workflows/upgrade-maintenance-v5.2.yml +++ b/.github/workflows/upgrade-maintenance-v5.2.yml @@ -27,7 +27,7 @@ jobs: - name: Back-port projenrc changes from main env: CI: "false" - run: git fetch origin main && git checkout FETCH_HEAD -- .projenrc.ts projenrc README.md && yarn projen + run: git fetch origin main && git checkout FETCH_HEAD -- README.md && yarn projen - name: Upgrade dependencies run: npx projen upgrade - name: Find mutations diff --git a/.github/workflows/upgrade-maintenance-v5.3.yml b/.github/workflows/upgrade-maintenance-v5.3.yml index 6a6ce0a8..205243d2 100644 --- a/.github/workflows/upgrade-maintenance-v5.3.yml +++ b/.github/workflows/upgrade-maintenance-v5.3.yml @@ -27,7 +27,7 @@ jobs: - name: Back-port projenrc changes from main env: CI: "false" - run: git fetch origin main && git checkout FETCH_HEAD -- .projenrc.ts projenrc README.md && yarn projen + run: git fetch origin main && git checkout FETCH_HEAD -- README.md && yarn projen - name: Upgrade dependencies run: npx projen upgrade - name: Find mutations diff --git a/.projenrc.ts b/.projenrc.ts index 88aa3ca8..3abc5bf2 100644 --- a/.projenrc.ts +++ b/.projenrc.ts @@ -251,44 +251,44 @@ new BuildWorkflow(project); const supported = new SupportPolicy(project); const releases = new ReleaseWorkflow(project) .autoTag({ + releaseLine: SUPPORT_POLICY.current, preReleaseId: 'dev', runName: 'Auto-Tag Prerelease (default branch)', schedule: '0 0 * * 0,2-6', // Tuesday though sundays at midnight }) .autoTag({ + releaseLine: SUPPORT_POLICY.current, runName: 'Auto-Tag Release (default branch)', schedule: '0 0 * * 1', // Mondays at midnight }); // We'll stagger release schedules so as to avoid everything going out at once. let hour = 0; -for (const [version, until] of Object.entries(SUPPORT_POLICY.maintenance)) { - if (Date.now() <= until.getTime()) { - // Stagger schedules every 5 hours, rolling. 5 was selected because it's co-prime to 24. - hour = (hour + 5) % 24; - - const tag = `v${version}`; - - releases - .autoTag({ - preReleaseId: 'dev', - runName: `Auto-Tag Prerelease (${tag})`, - schedule: `0 ${hour} * * 0,2-6`, // Tuesday though sundays - branch: supported.branches[version], - nameSuffix: tag, - }) - .autoTag({ - runName: `Auto-Tag Release (${tag})`, - schedule: `0 ${hour} * * 1`, // Mondays - branch: supported.branches[version], - nameSuffix: tag, - }); - } +for (const [version, branch] of Object.entries(supported.activeBranches(false))) { + // Stagger schedules every 5 hours, rolling. 5 was selected because it's co-prime to 24. + hour = (hour + 5) % 24; + const tag = `v${version}`; + releases + .autoTag({ + releaseLine: version, + preReleaseId: 'dev', + runName: `Auto-Tag Prerelease (${tag})`, + schedule: `0 ${hour} * * 0,2-6`, // Tuesday though sundays + branch, + nameSuffix: tag, + }) + .autoTag({ + releaseLine: version, + runName: `Auto-Tag Release (${tag})`, + schedule: `0 ${hour} * * 1`, // Mondays + branch, + nameSuffix: tag, + }); } // Allow PR backports to all maintained versions new PullRequestBackport(project, { - branches: Object.values(supported.branches), + branches: Object.values(supported.activeBranches()), }); project.synth(); diff --git a/projenrc/release.ts b/projenrc/release.ts index 687eb9de..8316a1e9 100644 --- a/projenrc/release.ts +++ b/projenrc/release.ts @@ -291,6 +291,11 @@ class TagReleaseTask { } interface AutoTagWorkflowProps { + /** + * The version used as the tagging base + */ + readonly releaseLine: string; + /** * The branch on which to trigger this AutoTagWorkflow. * @@ -388,8 +393,8 @@ class AutoTagWorkflow { { name: `Tag ${props.preReleaseId ? 'PreRelease' : 'Release'}`, run: `yarn tag-release --idempotent --no-sign --push ${ - props.preReleaseId ? `--prerelease=${props.preReleaseId}` : '' - }`, + props.preReleaseId ? `--prerelease=${props.preReleaseId} ` : '' + }--release-line=${props.releaseLine}`, }, ], }); diff --git a/projenrc/support.ts b/projenrc/support.ts index 5ed45597..b299b0aa 100644 --- a/projenrc/support.ts +++ b/projenrc/support.ts @@ -49,4 +49,22 @@ export class SupportPolicy { readonly: true, }); } + + /** + * Get all actively maintained branches + */ + public activeBranches(includeCurrent = true): { + [version: string]: string; + } { + return Object.fromEntries( + Object.entries(this.branches).filter(([version]) => { + if (includeCurrent && version === SUPPORT_POLICY.current) { + return true; + } + + // check if branch is still maintained + return Date.now() <= SUPPORT_POLICY.maintenance[version as any]?.getTime(); + }), + ); + } } diff --git a/projenrc/tag-release.ts b/projenrc/tag-release.ts index 0de71116..1fe90ea8 100644 --- a/projenrc/tag-release.ts +++ b/projenrc/tag-release.ts @@ -15,6 +15,7 @@ async function main(): Promise { remote, sign, verbose, + releaseLine, } = await yargs .scriptName('npx projen tag-release') .option('idempotent', { @@ -62,10 +63,21 @@ async function main(): Promise { desc: 'Do not actually create a tag, just determine what it would be', default: false, }) + .option('release-line', { + alias: 'r', + type: 'string', + desc: 'The version line for this release. This will be checked against the actual available typescript version and fail if they do not match. If not provided the current typescript version will be released.', + default: versionMajorMinor, + }) .help().argv; if (verbose) { - console.debug(`Current release line: ${versionMajorMinor}`); + console.debug(`Expected release line: ${releaseLine}`); + console.debug(`Detected release line: ${versionMajorMinor}`); + } + + if (releaseLine !== versionMajorMinor) { + throw new Error(`Release line mismatch: expected ${releaseLine}, got ${versionMajorMinor}`); } // Shell out to a git command and ensure it returns successfully, and returns @@ -119,7 +131,7 @@ async function main(): Promise { } // Check if the work-tree is dirty or not... - const dirty = await git('diff', '--staged'); + const dirty = await git('diff', '--cached'); if (dirty != '') { if (ignoreDirty) { console.warn('↧↧↧↧↧↧↧↧↧↧↧↧↧↧↧↧↧↧↧↧↧↧↧↧↧↧↧↧↧↧↧↧↧↧↧↧↧↧↧↧↧↧↧↧↧↧↧↧↧↧↧↧↧↧↧↧↧↧↧↧↧↧↧↧↧↧↧↧↧↧↧↧↧↧↧↧↧'); diff --git a/projenrc/upgrade-dependencies.ts b/projenrc/upgrade-dependencies.ts index 2ae320a3..1a4aeb01 100644 --- a/projenrc/upgrade-dependencies.ts +++ b/projenrc/upgrade-dependencies.ts @@ -29,7 +29,7 @@ export class JsiiDependencyUpgrades extends Component { JsonPatch.add('/jobs/upgrade/steps/3', { name: 'Back-port projenrc changes from main', env: { CI: 'false' }, - run: 'git fetch origin main && git checkout FETCH_HEAD -- .projenrc.ts projenrc README.md && yarn projen', + run: 'git fetch origin main && git checkout FETCH_HEAD -- README.md && yarn projen', }), ); }