Skip to content

Commit

Permalink
chore(release): add engine versions to release (#30021)
Browse files Browse the repository at this point in the history
  • Loading branch information
sampaiodiego authored Aug 17, 2023
1 parent 4f7e11c commit f93648a
Show file tree
Hide file tree
Showing 5 changed files with 66 additions and 4 deletions.
5 changes: 5 additions & 0 deletions .changeset/moody-comics-cheat.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
---
'@rocket.chat/release-action': minor
---

Add back "Engine Versions" to the release notes
4 changes: 2 additions & 2 deletions packages/release-action/src/bumpNextVersion.ts
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ import { createNpmFile } from './createNpmFile';
import { fixWorkspaceVersionsBeforePublish } from './fixWorkspaceVersionsBeforePublish';
import { commitChanges, createBranch, createTag, pushNewBranch } from './gitUtils';
import { setupOctokit } from './setupOctokit';
import { getChangelogEntry, bumpFileVersions, readPackageJson } from './utils';
import { getChangelogEntry, bumpFileVersions, readPackageJson, getEngineVersionsMd } from './utils';

export async function bumpNextVersion({
githubToken,
Expand Down Expand Up @@ -49,7 +49,7 @@ export async function bumpNextVersion({
throw new Error('Could not find changelog entry for version newVersion');
}

const prBody = changelogEntry.content;
const prBody = (await getEngineVersionsMd(cwd)) + changelogEntry.content;

const finalVersion = newVersion.split('-')[0];

Expand Down
41 changes: 41 additions & 0 deletions packages/release-action/src/getMetadata.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,41 @@
import { readFile } from 'fs/promises';
import path from 'path';

import { getExecOutput } from '@actions/exec';

import { readPackageJson } from './utils';

export async function getMongoVersion(cwd: string) {
try {
const workflows = await readFile(path.join(cwd, '.github/workflows/ci.yml'), 'utf8');

const mongoMatch = workflows.match(/compatibleMongoVersions\\": \[([^\]]+)\]/);
if (!mongoMatch) {
return [];
}

return mongoMatch[1].replace(/["'\\ ]/g, '').split(',');
} catch (e) {
console.error(e);
}
return [];
}

export async function getNodeNpmVersions(cwd: string): Promise<{ node: string; yarn: string; npm: string }> {
const packageJson = await readPackageJson(cwd);

return packageJson.engines;
}

export async function getAppsEngineVersion() {
try {
const result = await getExecOutput('yarn why @rocket.chat/apps-engine --json');

const match = result.stdout.match(/"@rocket\.chat\/meteor@workspace:apps\/meteor".*"@rocket\.chat\/apps\-engine@[^#]+#npm:([^"]+)"/);
if (match) {
return match[1];
}
} catch (e) {
console.error(e);
}
}
4 changes: 2 additions & 2 deletions packages/release-action/src/publishRelease.ts
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ import { createNpmFile } from './createNpmFile';
import { fixWorkspaceVersionsBeforePublish } from './fixWorkspaceVersionsBeforePublish';
import { checkoutBranch, commitChanges, createTag, getCurrentBranch, mergeBranch, pushChanges } from './gitUtils';
import { setupOctokit } from './setupOctokit';
import { bumpFileVersions, createBumpFile, getChangelogEntry, readPackageJson } from './utils';
import { bumpFileVersions, createBumpFile, getChangelogEntry, getEngineVersionsMd, readPackageJson } from './utils';

export async function publishRelease({
githubToken,
Expand Down Expand Up @@ -73,7 +73,7 @@ export async function publishRelease({
throw new Error('Could not find changelog entry for version newVersion');
}

const releaseBody = changelogEntry.content;
const releaseBody = (await getEngineVersionsMd(cwd)) + changelogEntry.content;

core.info('update version in all files to new');
await bumpFileVersions(cwd, currentVersion, newVersion);
Expand Down
16 changes: 16 additions & 0 deletions packages/release-action/src/utils.ts
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,8 @@ import remarkParse from 'remark-parse';
import remarkStringify from 'remark-stringify';
import unified from 'unified';

import { getAppsEngineVersion, getMongoVersion, getNodeNpmVersions } from './getMetadata';

export const BumpLevels = {
dep: 0,
patch: 1,
Expand Down Expand Up @@ -103,3 +105,17 @@ Bump ${pkgName} version.

await writeFile(filePath, data, 'utf8');
}

export async function getEngineVersionsMd(cwd: string) {
const { node } = await getNodeNpmVersions(cwd);
const appsEngine = await getAppsEngineVersion();
const mongo = await getMongoVersion(cwd);

return `### Engine versions
- Node: \`${node}\`
- MongoDB: \`${mongo.join(', ')}\`
- Apps-Engine: \`${appsEngine}\`
`;
}

0 comments on commit f93648a

Please sign in to comment.