-
Notifications
You must be signed in to change notification settings - Fork 842
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
Update release versioning for snapshot releases #8389
Changes from all commits
df589ee
2846dcb
1c03a87
ff8b9bb
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,6 +1,6 @@ | ||
{ | ||
"name": "@elastic/eui-theme-common", | ||
"version": "0.0.9", | ||
"version": "0.0.11", | ||
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. The last eui-theme-common version update was not committed. I must've forgotten to include it when doing it manually. |
||
"description": "EUI theme common", | ||
"license": "SEE LICENSE IN LICENSE.txt", | ||
"scripts": { | ||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -19,7 +19,12 @@ import { | |
deleteObsoleteChangelogs, | ||
updateChangelogContent, | ||
} from '../update_changelog'; | ||
import { getUpcomingVersion, getVersionTypeFromChangelog } from '../version'; | ||
import { | ||
getUniqueSnapshotId, | ||
getUpcomingSnapshotVersion, | ||
getUpcomingVersion, | ||
getVersionTypeFromChangelog, | ||
} from '../version'; | ||
import { commitFiles, isFileAddedToGit, stageFiles } from '../git_utils'; | ||
|
||
/** | ||
|
@@ -37,49 +42,57 @@ export const stepUpdateVersions = async ( | |
const filesToCommit: string[] = []; | ||
const changedWorkspaces: YarnWorkspace[] = []; | ||
const rootWorkspaceDir = getRootWorkspaceDir(); | ||
const snapshotId = getUniqueSnapshotId(); | ||
|
||
for (const workspace of workspaces) { | ||
logger.debug(`Calculating changes in ${workspace.name}`); | ||
|
||
const workspaceDir = path.join(rootWorkspaceDir, workspace.location); | ||
const currentVersion = await getWorkspacePackageVersion(workspaceDir); | ||
|
||
const { changelogMap, changelog, hasChanges, processedChangelogFiles } = | ||
await collateChangelogFiles(workspaceDir); | ||
if (options.type === 'snapshot') { | ||
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 could be done better and moved to separate functions but we can clean it up later |
||
const newVersion = getUpcomingSnapshotVersion(currentVersion, snapshotId); | ||
await updateWorkspaceVersion(workspace.name, newVersion); | ||
|
||
if (!hasChanges) { | ||
logger.debug(`[${workspace.name}] No changes detected`); | ||
continue; | ||
} | ||
logger.info(`[${workspace.name}] Updating version ${currentVersion} -> ${newVersion}`); | ||
} else { | ||
const { changelogMap, changelog, hasChanges, processedChangelogFiles } = | ||
await collateChangelogFiles(workspaceDir); | ||
|
||
const versionType = getVersionTypeFromChangelog(changelogMap); | ||
const newVersion = getUpcomingVersion(currentVersion, versionType); | ||
if (!hasChanges) { | ||
logger.debug(`[${workspace.name}] No changes detected`); | ||
continue; | ||
} | ||
|
||
const statsStr = Object.entries(changelogMap) | ||
.filter(([_, items]) => items.length) | ||
.map(([name, items]) => `${items.length} ${name.toLowerCase()}`); | ||
const versionType = getVersionTypeFromChangelog(changelogMap); | ||
const newVersion = getUpcomingVersion(currentVersion, versionType); | ||
|
||
logger.info( | ||
`[${workspace.name}] Updating version ${currentVersion} -> ${newVersion} (${versionType} update; ${statsStr})` | ||
); | ||
const statsStr = Object.entries(changelogMap) | ||
.filter(([_, items]) => items.length) | ||
.map(([name, items]) => `${items.length} ${name.toLowerCase()}`); | ||
|
||
const updatedYearChangelogPath = await updateChangelogContent( | ||
workspaceDir, | ||
changelog, | ||
newVersion | ||
); | ||
await deleteObsoleteChangelogs(processedChangelogFiles); | ||
logger.info( | ||
`[${workspace.name}] Updating version ${currentVersion} -> ${newVersion} (${versionType} update; ${statsStr})` | ||
); | ||
|
||
// Update package.json version string | ||
await updateWorkspaceVersion(workspace.name, newVersion); | ||
const updatedYearChangelogPath = await updateChangelogContent( | ||
workspaceDir, | ||
changelog, | ||
newVersion | ||
); | ||
await deleteObsoleteChangelogs(processedChangelogFiles); | ||
|
||
filesToCommit.push(getWorkspacePackageJsonPath(workspaceDir)); | ||
filesToCommit.push(updatedYearChangelogPath); | ||
// Update package.json version string | ||
await updateWorkspaceVersion(workspace.name, newVersion); | ||
|
||
// Only stage and commit changelog files that are added to git (versioned) | ||
for (const file of processedChangelogFiles) { | ||
if (await isFileAddedToGit(file)) { | ||
filesToCommit.push(file); | ||
filesToCommit.push(getWorkspacePackageJsonPath(workspaceDir)); | ||
filesToCommit.push(updatedYearChangelogPath); | ||
|
||
// Only stage and commit changelog files that are added to git (versioned) | ||
for (const file of processedChangelogFiles) { | ||
if (await isFileAddedToGit(file)) { | ||
filesToCommit.push(file); | ||
} | ||
} | ||
} | ||
|
||
|
@@ -90,16 +103,18 @@ export const stepUpdateVersions = async ( | |
throw new Error('There are no changes to release'); | ||
} | ||
|
||
// Stage yarn.lock changes | ||
const yarnLockPath = path.join(rootWorkspaceDir, 'yarn.lock'); | ||
filesToCommit.push(yarnLockPath); | ||
await stageFiles([yarnLockPath]); | ||
if (options.type !== 'snapshot') { | ||
// Stage yarn.lock changes | ||
const yarnLockPath = path.join(rootWorkspaceDir, 'yarn.lock'); | ||
filesToCommit.push(yarnLockPath); | ||
await stageFiles([yarnLockPath]); | ||
|
||
// Stage updated package.json files | ||
await stageFiles(filesToCommit); | ||
// Stage updated package.json files | ||
await stageFiles(filesToCommit); | ||
|
||
// Commit all package.json files and yarn.lock | ||
await commitFiles('chore: update package versions [skip ci]', filesToCommit); | ||
// Commit all package.json files and yarn.lock | ||
await commitFiles('chore: update package versions [skip ci]', filesToCommit); | ||
} | ||
|
||
return changedWorkspaces; | ||
}; |
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.
This is needed so that yarn replaces it during packing to an exact version instead of compatible with (
^
) version