Skip to content
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

Add downgrade logic for branch in DocLinkService #3483

Merged
Merged
1 change: 1 addition & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -200,6 +200,7 @@ Inspired from [Keep a Changelog](https://keepachangelog.com/en/1.0.0/)
- Add path ignore for markdown files for CI ([#2312](https://github.com/opensearch-project/OpenSearch-Dashboards/pull/2312))
- Updating WS scans to ignore BWC artifacts in `cypress` ([#2408](https://github.com/opensearch-project/OpenSearch-Dashboards/pull/2408))
- [CI] Run functional test repo as workflow ([#2503](https://github.com/opensearch-project/OpenSearch-Dashboards/pull/2503))
- [CI] Patch pkg.branch according to pkg.version when build ([#3483](https://github.com/opensearch-project/OpenSearch-Dashboards/pull/3483))

### 📝 Documentation

Expand Down
13 changes: 12 additions & 1 deletion src/dev/build/tasks/create_package_json_task.ts
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,7 @@
*/

import { copyWorkspacePackages } from '@osd/pm';
import { parse } from 'semver';

import { read, write, Task } from '../lib';

Expand All @@ -37,14 +38,24 @@ export const CreatePackageJson: Task = {

async run(config, log, build) {
const pkg = config.getOpenSearchDashboardsPkg();
/**
* OpenSearch server has a logic that if the pkg.branch is "main",
* set the docVersion to latest. So here we exclude main.
*/
const semverResult = parse(config.getBuildVersion());
const shouldPatch = semverResult && pkg.branch !== 'main';
const branch = shouldPatch ? `${semverResult.major}.${semverResult.minor}` : pkg.branch;
if (shouldPatch) {
log.info(`Patch branch property: ${branch}`);
}

const newPkg = {
name: pkg.name,
private: true,
description: pkg.description,
keywords: pkg.keywords,
version: config.getBuildVersion(),
SuZhou-Joe marked this conversation as resolved.
Show resolved Hide resolved
branch: pkg.branch,
branch,
build: {
number: config.getBuildNumber(),
sha: config.getBuildSha(),
Expand Down