Skip to content

chore(ci): rename version tag #437

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

Merged
merged 4 commits into from
Apr 28, 2022
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
24 changes: 15 additions & 9 deletions scripts/release/__tests__/create-release-issue.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -46,19 +46,21 @@ describe('create release issue', () => {
current: '0.0.1',
releaseType: 'patch',
},

php: {
current: '0.0.1',
releaseType: 'patch',
},

java: {
current: '0.0.1',
releaseType: 'patch',
},
})
).toMatchInlineSnapshot(`
"- [x] javascript: v0.0.1 -> \`patch\` _(e.g. v0.0.2)_
- [x] java: v0.0.1 -> \`patch\` _(e.g. v0.0.2)_
- [x] php: v0.0.1 -> \`patch\` _(e.g. v0.0.2)_"
"- [x] javascript: 0.0.1 -> \`patch\` _(e.g. 0.0.2)_
- [x] java: 0.0.1 -> \`patch\` _(e.g. 0.0.2)_
- [x] php: 0.0.1 -> \`patch\` _(e.g. 0.0.2)_"
`);
});

Expand All @@ -69,20 +71,22 @@ describe('create release issue', () => {
current: '0.0.1',
releaseType: 'patch',
},

php: {
current: '0.0.1',
releaseType: null,
noCommit: true,
},

java: {
current: '0.0.1',
releaseType: 'patch',
},
})
).toMatchInlineSnapshot(`
"- [x] javascript: v0.0.1 -> \`patch\` _(e.g. v0.0.2)_
- [x] java: v0.0.1 -> \`patch\` _(e.g. v0.0.2)_
- ~php: v0.0.1 (no commit)~"
"- [x] javascript: 0.0.1 -> \`patch\` _(e.g. 0.0.2)_
- [x] java: 0.0.1 -> \`patch\` _(e.g. 0.0.2)_
- ~php: 0.0.1 (no commit)~"
`);
});

Expand All @@ -93,21 +97,23 @@ describe('create release issue', () => {
current: '0.0.1',
releaseType: 'patch',
},

php: {
current: '0.0.1',
releaseType: 'minor',
},

java: {
current: '0.0.1',
releaseType: 'patch',
skipRelease: true,
},
})
).toMatchInlineSnapshot(`
"- [x] javascript: v0.0.1 -> \`patch\` _(e.g. v0.0.2)_
- [ ] java: v0.0.1 -> \`patch\` _(e.g. v0.0.2)_
"- [x] javascript: 0.0.1 -> \`patch\` _(e.g. 0.0.2)_
- [ ] java: 0.0.1 -> \`patch\` _(e.g. 0.0.2)_
- No \`feat\` or \`fix\` commit, thus unchecked by default.
- [x] php: v0.0.1 -> \`minor\` _(e.g. v0.1.0)_"
- [x] php: 0.0.1 -> \`minor\` _(e.g. 0.1.0)_"
`);
});

Expand Down
6 changes: 3 additions & 3 deletions scripts/release/__tests__/process-release.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -7,9 +7,9 @@ describe('process release', () => {
const versions = getVersionsToRelease(`
## Version Changes

- [x] javascript: v1.0.0 -> \`minor\` (e.g. v1.1.0)
- [x] php: v2.0.0 -> \`patch\` (e.g. v2.0.1)
- [ ] java: v3.0.0 -> \`patch\` (e.g. v3.0.1)
- [x] javascript: 1.0.0 -> \`minor\` (e.g. 1.1.0)
- [x] php: 2.0.0 -> \`patch\` (e.g. 2.0.1)
- [ ] java: 3.0.0 -> \`patch\` (e.g. 3.0.1)
`);

expect(Object.keys(versions)).toEqual(['javascript', 'php']);
Expand Down
4 changes: 2 additions & 2 deletions scripts/release/create-release-issue.ts
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,7 @@ export function getVersionChangesText(versions: Versions): string {
const { current, releaseType, noCommit, skipRelease } = versions[lang];

if (noCommit) {
return `- ~${lang}: v${current} (${TEXT.noCommit})~`;
return `- ~${lang}: ${current} (${TEXT.noCommit})~`;
}

if (!current) {
Expand All @@ -51,7 +51,7 @@ export function getVersionChangesText(versions: Versions): string {
const next = semver.inc(current, releaseType!);
const checked = skipRelease ? ' ' : 'x';
return [
`- [${checked}] ${lang}: v${current} -> \`${releaseType}\` _(e.g. v${next})_`,
`- [${checked}] ${lang}: ${current} -> \`${releaseType}\` _(e.g. ${next})_`,
skipRelease && TEXT.descriptionForSkippedLang,
]
.filter(Boolean)
Expand Down
23 changes: 18 additions & 5 deletions scripts/release/process-release.ts
Original file line number Diff line number Diff line change
Expand Up @@ -82,7 +82,7 @@ export function getVersionsToRelease(issueBody: string): VersionsToRelease {
getMarkdownSection(issueBody, TEXT.versionChangeHeader)
.split('\n')
.forEach((line) => {
const result = line.match(/- \[x\] (.+): v(.+) -> `(.+)`/);
const result = line.match(/- \[x\] (.+): (.+) -> `(.+)`/);
if (!result) {
return;
}
Expand Down Expand Up @@ -159,9 +159,9 @@ async function updateChangelog({
const existingContent = (await exists(changelogPath))
? (await fsp.readFile(changelogPath)).toString()
: '';
const changelogHeader = `## [v${next}](${getGitHubUrl(
const changelogHeader = `## [${next}](${getGitHubUrl(
lang
)}/compare/v${current}...v${next})`;
)}/compare/${current}...${next})`;
const newChangelog = getMarkdownSection(
getMarkdownSection(issueBody, TEXT.changelogHeader),
`### ${lang}`
Expand All @@ -172,6 +172,16 @@ async function updateChangelog({
);
}

function formatGitTag({
lang,
version,
}: {
lang: string;
version: string;
}): string {
return lang === 'go' ? `v${version}` : version;
}

async function isAuthorizedRelease(): Promise<boolean> {
const octokit = getOctokit(process.env.GITHUB_TOKEN!);
const { data: members } = await octokit.rest.teams.listMembersInOrg({
Expand Down Expand Up @@ -266,11 +276,14 @@ async function processRelease(): Promise<void> {

const { current, releaseType } = versionsToRelease[lang];
const next = semver.inc(current, releaseType);
const tag = formatGitTag({ lang, version: next! });
await gitCommit({
message: `chore: release v${next}`,
message: `chore: release ${tag}`,
cwd: tempGitDir,
});
await execa('git', ['tag', tag], {
cwd: tempGitDir,
});
await execa('git', ['tag', `v${next}`], { cwd: tempGitDir });
await run(`git push --follow-tags`, { cwd: tempGitDir });
}

Expand Down