-
Notifications
You must be signed in to change notification settings - Fork 27
fix(scripts): update release issue process #537
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Changes from 11 commits
5e3bc02
f908c17
b26409a
b1cf7b3
65c1524
d34dad1
e9d125e
1abfdc7
5bf8914
77101ee
5f5f624
2b8478d
1db6043
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
This file was deleted.
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -1,4 +1,5 @@ | ||
| /* eslint-disable no-console */ | ||
| import execa from 'execa'; | ||
| import { copy } from 'fs-extra'; | ||
|
|
||
| import { | ||
|
|
@@ -10,13 +11,21 @@ import { | |
| REPO_URL, | ||
| ensureGitHubToken, | ||
| } from '../../common'; | ||
| import { getLanguageFolder } from '../../config'; | ||
| import { cloneRepository, configureGitHubAuthor } from '../../release/common'; | ||
| import { getLanguageFolder, getPackageVersionDefault } from '../../config'; | ||
| import { | ||
| cloneRepository, | ||
| configureGitHubAuthor, | ||
| RELEASED_TAG, | ||
| } from '../../release/common'; | ||
| import type { Language } from '../../types'; | ||
| import { getNbGitDiff } from '../utils'; | ||
|
|
||
| import text from './text'; | ||
|
|
||
| const IS_RELEASE_COMMIT = | ||
shortcuts marked this conversation as resolved.
Show resolved
Hide resolved
|
||
| process.env.IS_RELEASE_COMMIT?.startsWith(text.commitPrepareReleaseMessage) || | ||
| false; | ||
|
|
||
| export function decideWhereToSpread(commitMessage: string): Language[] { | ||
| if (commitMessage.startsWith('chore: release')) { | ||
| return []; | ||
|
|
@@ -60,6 +69,16 @@ export function cleanUpCommitMessage(commitMessage: string): string { | |
| return [prCommit[1], `${REPO_URL}/pull/${prCommit[2]}`].join('\n\n'); | ||
| } | ||
|
|
||
| function formatGitTag({ | ||
| lang, | ||
| version, | ||
| }: { | ||
| lang: Language | 'go'; | ||
shortcuts marked this conversation as resolved.
Outdated
Show resolved
Hide resolved
|
||
| version: string; | ||
| }): string { | ||
| return lang === 'go' ? `v${version}` : version; | ||
| } | ||
|
|
||
| async function spreadGeneration(): Promise<void> { | ||
| const githubToken = ensureGitHubToken(); | ||
|
|
||
|
|
@@ -77,6 +96,21 @@ async function spreadGeneration(): Promise<void> { | |
| const commitMessage = cleanUpCommitMessage(lastCommitMessage); | ||
| const langs = decideWhereToSpread(lastCommitMessage); | ||
|
|
||
| // At this point, we know the release will happen on every clients | ||
millotp marked this conversation as resolved.
Show resolved
Hide resolved
|
||
| // So we want to set the released tag at the monorepo level too. | ||
| if (IS_RELEASE_COMMIT) { | ||
| // remove old `released` tag | ||
| await run( | ||
| `git fetch origin refs/tags/${RELEASED_TAG}:refs/tags/${RELEASED_TAG}` | ||
| ); | ||
| await run(`git tag -d ${RELEASED_TAG}`); | ||
| await run(`git push --delete origin ${RELEASED_TAG}`); | ||
|
|
||
| // create new `released` tag | ||
| await run(`git tag released`); | ||
| await run(`git push --tags`); | ||
| } | ||
|
|
||
| for (const lang of langs) { | ||
| const { tempGitDir } = await cloneRepository({ | ||
| lang, | ||
|
|
@@ -100,14 +134,23 @@ async function spreadGeneration(): Promise<void> { | |
| continue; | ||
| } | ||
|
|
||
| const version = getPackageVersionDefault(lang); | ||
| const tag = formatGitTag({ lang, version }); | ||
| const message = IS_RELEASE_COMMIT ? `chore: release ${tag}` : commitMessage; | ||
|
|
||
| await configureGitHubAuthor(tempGitDir); | ||
| await run(`git add .`, { cwd: tempGitDir }); | ||
| await gitCommit({ | ||
| message: commitMessage, | ||
| message, | ||
| coAuthors: [author, ...coAuthors], | ||
| cwd: tempGitDir, | ||
| }); | ||
| await run(`git push`, { cwd: tempGitDir }); | ||
| await execa('git', ['tag', tag], { | ||
|
||
| cwd: tempGitDir, | ||
| }); | ||
| await run(IS_RELEASE_COMMIT ? 'git push --follow-tags' : 'git push', { | ||
| cwd: tempGitDir, | ||
| }); | ||
| console.log(`✅ Spread the generation to ${lang} repository.`); | ||
| } | ||
| } | ||
|
|
||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -64,7 +64,7 @@ async function preCommit() { | |
| } | ||
|
|
||
| console.log( | ||
| chalk.bgYellow('[INFO]'), | ||
| chalk.black.bgYellow('[INFO]'), | ||
|
Member
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. this was hard to read |
||
| `Generated file found, unstaging: ${stagedFile}` | ||
| ); | ||
|
|
||
|
|
||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -6,7 +6,6 @@ | |
| "createMatrix": "ts-node ci/githubActions/createMatrix.ts", | ||
| "createReleaseIssue": "ts-node release/create-release-issue.ts", | ||
|
Collaborator
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. is createReleaseIssue still used ?
Member
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Yep to create a PR, I wanted to rename it in this PR but I was afraid the diff would be too big, so I'll do it before merging/once merged |
||
| "pre-commit": "./ci/husky/pre-commit.js", | ||
| "processRelease": "ts-node release/process-release.ts", | ||
| "pushGeneratedCode": "ts-node ci/codegen/pushGeneratedCode.ts", | ||
| "renovateWeeklyPR": "ts-node ci/githubActions/renovateWeeklyPR.ts", | ||
| "setRunVariables": "ts-node ci/githubActions/setRunVariables.ts", | ||
|
|
||
This file was deleted.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I have a doubt on this one, hopefully it prints the latest commit message once on
main