From c809de1fe67a90b2a8d1746614e055f529af81cc Mon Sep 17 00:00:00 2001
From: "mergify[bot]" <37929162+mergify[bot]@users.noreply.github.com>
Date: Sat, 9 Sep 2023 13:59:17 +0000
Subject: [PATCH] ci: always use version named branches (backport #752) (#754)
This is an automatic backport of pull request #752 done by [Mergify](https://mergify.com).
---
Mergify commands and options
More conditions and actions can be found in the [documentation](https://docs.mergify.com/).
You can also trigger Mergify actions by commenting on this pull request:
- `@Mergifyio refresh` will re-evaluate the rules
- `@Mergifyio rebase` will rebase this PR on its base branch
- `@Mergifyio update` will merge the base branch into this PR
- `@Mergifyio backport ` will backport this PR on `` branch
Additionally, on Mergify [dashboard](https://dashboard.mergify.com) you can:
- look at your merge queues
- generate the Mergify configuration with the config editor.
Finally, you can contact us on https://mergify.com
---
.gitattributes | 2 +-
.github/workflows/release.yml | 8 ++--
.../{upgrade-main.yml => upgrade-v4.yml} | 12 +++---
.gitignore | 2 +-
.projen/deps.json | 1 +
.projen/files.json | 2 +-
.projen/tasks.json | 32 +++++++--------
.projenrc.ts | 10 +++--
package-lock.json | 2 +-
package.json | 6 +--
projenrc/ReleaseBranches.ts | 40 ++++++++++++++-----
11 files changed, 72 insertions(+), 45 deletions(-)
rename .github/workflows/{upgrade-main.yml => upgrade-v4.yml} (91%)
diff --git a/.gitattributes b/.gitattributes
index 19864b83..7b603134 100644
--- a/.gitattributes
+++ b/.gitattributes
@@ -9,8 +9,8 @@
/.github/workflows/pull-request-lint.yml linguist-generated
/.github/workflows/release-v3.yml linguist-generated
/.github/workflows/release.yml linguist-generated
-/.github/workflows/upgrade-main.yml linguist-generated
/.github/workflows/upgrade-v3.yml linguist-generated
+/.github/workflows/upgrade-v4.yml linguist-generated
/.gitignore linguist-generated
/.mergify.yml linguist-generated
/.npmignore linguist-generated
diff --git a/.github/workflows/release.yml b/.github/workflows/release.yml
index c2475a99..0f02031d 100644
--- a/.github/workflows/release.yml
+++ b/.github/workflows/release.yml
@@ -19,7 +19,7 @@ jobs:
uses: actions/checkout@v3
with:
fetch-depth: 0
- ref: main
+ ref: v4
- name: Set git identity
run: |-
git config user.name "github-actions"
@@ -30,8 +30,8 @@ jobs:
node-version: 16.x
- name: Install dependencies
run: npm ci
- - name: release
- run: npx projen release
+ - name: release:v4
+ run: npx projen release:v4
- name: Check for new commits
id: git_remote
run: echo "latest_commit=$(git ls-remote origin -h ${{ github.ref }} | cut -f1)" >> $GITHUB_OUTPUT
@@ -222,5 +222,5 @@ jobs:
GIT_USER_EMAIL: github-actions@github.com
GITHUB_USE_SSH: "true"
SSH_AUTH_SOCK: /tmp/ssh_agent.sock
- GIT_BRANCH: main
+ GIT_BRANCH: v4
run: npx -p publib@latest publib-golang
diff --git a/.github/workflows/upgrade-main.yml b/.github/workflows/upgrade-v4.yml
similarity index 91%
rename from .github/workflows/upgrade-main.yml
rename to .github/workflows/upgrade-v4.yml
index 893bbc22..f82cbb41 100644
--- a/.github/workflows/upgrade-main.yml
+++ b/.github/workflows/upgrade-v4.yml
@@ -1,6 +1,6 @@
# ~~ Generated by projen. To modify, edit .projenrc.ts and run "npx projen".
-name: upgrade-main
+name: upgrade-v4
on:
workflow_dispatch: {}
schedule:
@@ -17,7 +17,7 @@ jobs:
- name: Checkout
uses: actions/checkout@v3
with:
- ref: main
+ ref: v4
- name: Setup Node.js
uses: actions/setup-node@v3
with:
@@ -54,7 +54,7 @@ jobs:
- name: Checkout
uses: actions/checkout@v3
with:
- ref: main
+ ref: v4
- name: Download patch
uses: actions/download-artifact@v3
with:
@@ -80,8 +80,8 @@ jobs:
------
- *Automatically created by projen via the "upgrade-main" workflow*
- branch: github-actions/upgrade-main
+ *Automatically created by projen via the "upgrade-v4" workflow*
+ branch: github-actions/upgrade-v4
title: "chore(deps): upgrade dependencies"
labels: auto-approve
body: |-
@@ -91,7 +91,7 @@ jobs:
------
- *Automatically created by projen via the "upgrade-main" workflow*
+ *Automatically created by projen via the "upgrade-v4" workflow*
author: github-actions
committer: github-actions
signoff: true
diff --git a/.gitignore b/.gitignore
index b14cb031..fe781faa 100644
--- a/.gitignore
+++ b/.gitignore
@@ -48,7 +48,7 @@ junit.xml
!/.github/workflows/release.yml
!/.github/workflows/release-v3.yml
!/.mergify.yml
-!/.github/workflows/upgrade-main.yml
+!/.github/workflows/upgrade-v4.yml
!/.github/workflows/upgrade-v3.yml
!/.github/pull_request_template.md
!/.npmrc
diff --git a/.projen/deps.json b/.projen/deps.json
index f012d1e3..fe7096ff 100644
--- a/.projen/deps.json
+++ b/.projen/deps.json
@@ -131,6 +131,7 @@
},
{
"name": "typescript",
+ "version": "4.9.x",
"type": "build"
},
{
diff --git a/.projen/files.json b/.projen/files.json
index 8ea1eac7..3b64e0c2 100644
--- a/.projen/files.json
+++ b/.projen/files.json
@@ -8,8 +8,8 @@
".github/workflows/pull-request-lint.yml",
".github/workflows/release-v3.yml",
".github/workflows/release.yml",
- ".github/workflows/upgrade-main.yml",
".github/workflows/upgrade-v3.yml",
+ ".github/workflows/upgrade-v4.yml",
".gitignore",
".mergify.yml",
".npmrc",
diff --git a/.projen/tasks.json b/.projen/tasks.json
index 4c8a03c7..9128e5e1 100644
--- a/.projen/tasks.json
+++ b/.projen/tasks.json
@@ -266,8 +266,8 @@
}
]
},
- "publish:git": {
- "name": "publish:git",
+ "publish:git:v3": {
+ "name": "publish:git:v3",
"description": "Prepends the release changelog onto the project changelog, creates a release commit, and tags the release",
"env": {
"CHANGELOG": "dist/dist/changelog.md",
@@ -283,13 +283,13 @@
"builtin": "release/tag-version"
},
{
- "exec": "git push --follow-tags origin main"
+ "exec": "git push --follow-tags origin v3"
}
],
"condition": "! git log --oneline -1 | grep -q \"chore(release):\""
},
- "publish:git:v3": {
- "name": "publish:git:v3",
+ "publish:git:v4": {
+ "name": "publish:git:v4",
"description": "Prepends the release changelog onto the project changelog, creates a release commit, and tags the release",
"env": {
"CHANGELOG": "dist/dist/changelog.md",
@@ -305,17 +305,17 @@
"builtin": "release/tag-version"
},
{
- "exec": "git push --follow-tags origin v3"
+ "exec": "git push --follow-tags origin v4"
}
],
"condition": "! git log --oneline -1 | grep -q \"chore(release):\""
},
- "release": {
- "name": "release",
- "description": "Prepare a release from \"main\" branch",
+ "release:v3": {
+ "name": "release:v3",
+ "description": "Prepare a release from \"v3\" branch",
"env": {
"RELEASE": "true",
- "MAJOR": "4"
+ "MAJOR": "3"
},
"steps": [
{
@@ -335,12 +335,12 @@
}
]
},
- "release:v3": {
- "name": "release:v3",
- "description": "Prepare a release from \"v3\" branch",
+ "release:v4": {
+ "name": "release:v4",
+ "description": "Prepare a release from \"v4\" branch",
"env": {
"RELEASE": "true",
- "MAJOR": "3"
+ "MAJOR": "4"
},
"steps": [
{
@@ -417,13 +417,13 @@
"exec": "npm update npm-check-updates"
},
{
- "exec": "npm-check-updates --upgrade --target=minor --peer --dep=dev,peer,prod,optional --filter=@types/eslint,@types/jest,@types/node,@typescript-eslint/eslint-plugin,@typescript-eslint/parser,esbuild,eslint-import-resolver-node,eslint-import-resolver-typescript,eslint-plugin-import,eslint,jest-junit,jest-mock,jest,jsii-diff,jsii-docgen,jsii-pacmak,npm-check-updates,projen,standard-version,ts-jest,ts-morph,ts-node,typescript,aws-cdk-lib,constructs"
+ "exec": "npm-check-updates --upgrade --target=minor --peer --dep=dev,peer,prod,optional --filter=@types/eslint,@types/jest,@types/node,@typescript-eslint/eslint-plugin,@typescript-eslint/parser,esbuild,eslint-import-resolver-node,eslint-import-resolver-typescript,eslint-plugin-import,eslint,jest-junit,jest-mock,jest,jsii-diff,jsii-docgen,jsii-pacmak,npm-check-updates,projen,standard-version,ts-jest,ts-morph,ts-node,aws-cdk-lib,constructs"
},
{
"exec": "npm install"
},
{
- "exec": "npm update @types/eslint @types/jest @types/node @typescript-eslint/eslint-plugin @typescript-eslint/parser esbuild eslint-import-resolver-node eslint-import-resolver-typescript eslint-plugin-import eslint jest-junit jest-mock jest jsii-diff jsii-docgen jsii-pacmak npm-check-updates projen standard-version ts-jest ts-morph ts-node typescript aws-cdk-lib constructs"
+ "exec": "npm update @types/eslint @types/jest @types/node @typescript-eslint/eslint-plugin @typescript-eslint/parser esbuild eslint-import-resolver-node eslint-import-resolver-typescript eslint-plugin-import eslint jest-junit jest-mock jest jsii-diff jsii-docgen jsii-pacmak npm-check-updates projen standard-version ts-jest ts-morph ts-node aws-cdk-lib constructs"
},
{
"exec": "npx projen"
diff --git a/.projenrc.ts b/.projenrc.ts
index 8ae5b411..bad7bffd 100644
--- a/.projenrc.ts
+++ b/.projenrc.ts
@@ -5,17 +5,23 @@ import { IntegrationTests } from './projenrc/IntegrationTests';
import { Esbuild } from './src/private/esbuild-source';
const releaseBranches: StableReleaseBranches = {
- main: {
+ v4: {
+ isCurrent: true,
majorVersion: 4,
cdkVersion: '2.12.0',
minNodeVersion: '16.x', // should be 14.x but that version doesn't build anymore
releaseSchedule: '0 5 15 * *',
+ jsiiVersion: '1.x',
+ typescriptVersion: '4.9.x',
},
v3: {
majorVersion: 3,
cdkVersion: '2.0.0',
+ syntheticsVersion: '2.0.0-alpha.11',
minNodeVersion: '16.x', // should be 14.x but that version doesn't build anymore
releaseSchedule: '0 5 15 * *',
+ jsiiVersion: '1.x',
+ typescriptVersion: '4.9.x',
},
};
@@ -95,9 +101,7 @@ const project = new awscdk.AwsCdkConstructLibrary({
},
// Dependencies
- cdkVersion: releaseBranches.main.cdkVersion,
devDeps: [
- `@aws-cdk/aws-synthetics-alpha@${releaseBranches.main.cdkVersion}-alpha.0`,
'@types/eslint',
Esbuild.spec,
'jest-mock',
diff --git a/package-lock.json b/package-lock.json
index 982a1756..97b100b8 100644
--- a/package-lock.json
+++ b/package-lock.json
@@ -37,7 +37,7 @@
"ts-jest": "^27",
"ts-morph": "^17.0.1",
"ts-node": "^10",
- "typescript": "^4.9.5"
+ "typescript": "4.9.x"
},
"optionalDependencies": {
"esbuild": "^0.18.0"
diff --git a/package.json b/package.json
index 7be37203..0ab22460 100644
--- a/package.json
+++ b/package.json
@@ -27,10 +27,10 @@
"post-upgrade": "npx projen post-upgrade",
"pre-compile": "npx projen pre-compile",
"prepare:readme": "npx projen prepare:readme",
- "publish:git": "npx projen publish:git",
"publish:git:v3": "npx projen publish:git:v3",
- "release": "npx projen release",
+ "publish:git:v4": "npx projen publish:git:v4",
"release:v3": "npx projen release:v3",
+ "release:v4": "npx projen release:v4",
"rosetta": "npx projen rosetta",
"test": "npx projen test",
"test:watch": "npx projen test:watch",
@@ -74,7 +74,7 @@
"ts-jest": "^27",
"ts-morph": "^17.0.1",
"ts-node": "^10",
- "typescript": "^4.9.5"
+ "typescript": "4.9.x"
},
"peerDependencies": {
"aws-cdk-lib": "^2.12.0",
diff --git a/projenrc/ReleaseBranches.ts b/projenrc/ReleaseBranches.ts
index e24b236d..41c3c9d9 100644
--- a/projenrc/ReleaseBranches.ts
+++ b/projenrc/ReleaseBranches.ts
@@ -1,10 +1,14 @@
import { Component, JsonPatch, release, typescript } from 'projen';
export interface StableReleaseBranchOptions extends Omit {
+ isCurrent?: boolean;
minNodeVersion: string;
releaseSchedule: string;
npmDistTags?: string[];
cdkVersion: string;
+ jsiiVersion: string;
+ typescriptVersion: string;
+ syntheticsVersion?: string;
}
export interface StableReleaseBranches {
@@ -14,15 +18,20 @@ export interface StableReleaseBranches {
export class StableReleases extends Component {
public project: typescript.TypeScriptProject;
- public constructor(project: typescript.TypeScriptProject, options: StableReleaseBranches) {
+ public constructor(project: typescript.TypeScriptProject, public readonly branches: StableReleaseBranches) {
super(project);
this.project = project;
for (const branch of project.release?.branches ?? []) {
- const opts = options[branch];
- const isDefaultBranch = this.isDefaultBranch(branch);
+ const opts = branches[branch];
+ const isCurrentBranch = this.isCurrentBranch(branch);
const releaseWorkflow = this.getReleaseWorkflow(branch);
+ // Features only for current branch
+ if (isCurrentBranch) {
+ project.addDevDeps( `@aws-cdk/aws-synthetics-alpha@${opts.syntheticsVersion ?? opts.cdkVersion + '-alpha.0'}`);
+ }
+
// Release schedule
releaseWorkflow?.patch(JsonPatch.replace('/on/schedule', [{ cron: opts.releaseSchedule }]));
@@ -38,7 +47,7 @@ export class StableReleases extends Component {
gitBranch: branch,
});
const publishChangelogTask = ['publish', 'git'];
- if (!isDefaultBranch) {
+ if (!isCurrentBranch) {
publishChangelogTask.push(branch);
}
releaseWorkflow?.patch(JsonPatch.add('/jobs/release/steps/-', {
@@ -62,12 +71,13 @@ export class StableReleases extends Component {
}
}
- private isDefaultBranch(branch: string): boolean {
- return branch === 'main';
+ private isCurrentBranch(branch: string): boolean {
+ const [currentBranch] = Object.entries(this.branches).find(([_, options]) => options.isCurrent) || [];
+ return branch === currentBranch;
}
private getReleaseWorkflow(branch: string) {
- if (this.isDefaultBranch(branch)) {
+ if (this.isCurrentBranch(branch)) {
return this.project.tryFindObjectFile('.github/workflows/release.yml');
}
@@ -90,20 +100,32 @@ export class StableReleases extends Component {
}
-export function releaseOptions(branches: StableReleaseBranches, currentBranch = 'main'): {
+export function releaseOptions(branches: StableReleaseBranches): {
npmDistTag: string;
defaultReleaseBranch: string;
majorVersion: number;
+ prerelease?: string;
releaseBranches: StableReleaseBranches;
workflowNodeVersion: string;
releaseTrigger: release.ReleaseTrigger;
+ cdkVersion: string;
+ jsiiVersion: string;
+ typescriptVersion: string;
} {
- const current = branches[currentBranch];
+ const [currentBranch, current] = Object.entries(branches).find(([_, options]) => options.isCurrent) || [];
+ if (!currentBranch || !current) {
+ throw Error('Exactly one branch must be the current version');
+ }
+
return {
npmDistTag: 'latest',
defaultReleaseBranch: currentBranch,
majorVersion: current.majorVersion,
workflowNodeVersion: current.minNodeVersion,
+ prerelease: current.prerelease,
+ cdkVersion: current.cdkVersion,
+ jsiiVersion: current.jsiiVersion,
+ typescriptVersion: current.typescriptVersion,
releaseBranches: Object.fromEntries(
Object.entries(branches)
.filter(([b]) => b !== currentBranch)