Skip to content

Commit

Permalink
cherry-pick RHEL6 skip/release only
Browse files Browse the repository at this point in the history
  • Loading branch information
Roman-Shchukin authored and kirill-ivlev committed Feb 16, 2023
1 parent 3c50b1b commit 122f5de
Show file tree
Hide file tree
Showing 5 changed files with 99 additions and 12 deletions.
17 changes: 10 additions & 7 deletions .azure-pipelines/pipeline.yml
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,9 @@ parameters:
- name: skipRhelRelease
type: boolean
default: true
- name: releaseRhelOnly
type: boolean
default: false

# Targets
- name: win_x64
Expand Down Expand Up @@ -66,7 +69,7 @@ stages:
jobs:

# Windows (x64)
- ${{ if parameters.win_x64 }}:
- ${{ if and(parameters.win_x64, not(parameters.releaseRhelOnly)) }}:
- template: build-jobs.yml
parameters:
jobName: build_windows_x64
Expand All @@ -86,7 +89,7 @@ stages:
buildAlternatePackage: ${{ parameters.buildAlternatePackage }}

# Windows (x86)
- ${{ if parameters.win_x86 }}:
- ${{ if and(parameters.win_x86, not(parameters.releaseRhelOnly)) }}:
- template: build-jobs.yml
parameters:
jobName: build_windows_x86
Expand All @@ -104,7 +107,7 @@ stages:
buildAlternatePackage: ${{ parameters.buildAlternatePackage }}

# Linux (x64)
- ${{ if parameters.linux_x64 }}:
- ${{ if and(parameters.linux_x64, not(parameters.releaseRhelOnly)) }}:
- template: build-jobs.yml
parameters:
jobName: build_linux_x64
Expand All @@ -122,7 +125,7 @@ stages:
buildAlternatePackage: ${{ parameters.buildAlternatePackage }}

# Linux (ARM)
- ${{ if parameters.linux_arm }}:
- ${{ if and(parameters.linux_arm, not(parameters.releaseRhelOnly)) }}:
- template: build-jobs.yml
parameters:
jobName: build_linux_arm
Expand All @@ -141,7 +144,7 @@ stages:
buildAlternatePackage: ${{ parameters.buildAlternatePackage }}

# Linux (ARM64)
- ${{ if parameters.linux_arm64 }}:
- ${{ if and(parameters.linux_arm64, not(parameters.releaseRhelOnly)) }}:
- template: build-jobs.yml
parameters:
jobName: build_linux_arm64
Expand All @@ -161,7 +164,7 @@ stages:
buildAlternatePackage: ${{ parameters.buildAlternatePackage }}

# RHEL6 (x64)
- ${{ if and(parameters.rhel6_x64, not(skipRhelRelease)) }}:
- ${{ if and(parameters.rhel6_x64, not(parameters.skipRhelRelease), parameters.releaseRhelOnly) }}:
- template: build-jobs.yml
parameters:
jobName: build_rhel6_x64
Expand All @@ -180,7 +183,7 @@ stages:
buildAlternatePackage: ${{ parameters.buildAlternatePackage }}

# macOS x64
- ${{ if parameters.macOS_x64 }}:
- ${{ if and(parameters.macOS_x64, not(parameters.releaseRhelOnly)) }}:
- template: build-jobs.yml
parameters:
jobName: build_osx
Expand Down
4 changes: 4 additions & 0 deletions .vsts.ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,9 @@ parameters:
type: boolean
displayName: macOS (x64)
default: true
- name: skipRhelRelease
type: boolean
default: true

pr:
branches:
Expand All @@ -42,6 +45,7 @@ extends:
componentDetection: ${{ eq(variables['Build.Reason'], 'PullRequest') }}
publishArtifacts: ${{ ne(variables['Build.Reason'], 'PullRequest') }}
buildAlternatePackage: false
skipRhelRelease: ${{ parameters.skipRhelRelease }}
win_x64: ${{ parameters.win_x64 }}
win_x86: ${{ parameters.win_x86 }}
linux_x64: ${{ parameters.linux_x64 }}
Expand Down
5 changes: 5 additions & 0 deletions .vsts.release.yml
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,10 @@ parameters:
type: boolean
default: true
displayName: Skip RHEL Release
- name: releaseRhelOnly
type: boolean
default: false
displayName: Release RHEL Only

- name: onlyGitHubRelease
type: boolean
Expand All @@ -38,6 +42,7 @@ extends:
sign: true
publishArtifacts: true
skipRhelRelease: ${{ parameters.skipRhelRelease }}
releaseRhelOnly: ${{ parameters.releaseRhelOnly }}

preBuildStages:
- ${{ if and(not(parameters.buildStageOnly), eq(variables['Build.SourceBranch'], 'refs/heads/master')) }}:
Expand Down
24 changes: 22 additions & 2 deletions release/createAdoPrs.js
Original file line number Diff line number Diff line change
Expand Up @@ -30,17 +30,37 @@ const connection = new azdev.WebApi('https://dev.azure.com/mseng', authHandler);
*/
function createIntegrationFiles(newRelease)
{
const xmlFilePath = path.join(INTEGRATION_DIR, 'InstallAgentPackage.xml')
fs.mkdirSync(INTEGRATION_DIR, { recursive: true });
util.fillAgentParameters(
path.join(__dirname, '..', 'src', 'Misc', 'InstallAgentPackage.template.xml'),
path.join(INTEGRATION_DIR, 'InstallAgentPackage.xml'),
xmlFilePath,
newRelease
);
clearEmptyHashValueLine(xmlFilePath);
clearEmptyXmlNodes(xmlFilePath);

const publishScriptFilePath = path.join(INTEGRATION_DIR, 'Publish.ps1')
util.fillAgentParameters(
path.join(__dirname, '..', 'src', 'Misc', 'Publish.template.ps1'),
path.join(INTEGRATION_DIR, 'Publish.ps1'),
publishScriptFilePath,
newRelease
);
clearEmptyHashValueLine(publishScriptFilePath);
}

function clearEmptyXmlNodes(filePath) {
var xmlFile = fs.readFileSync(filePath, 'utf-8');
while (xmlFile.length != (xmlFile = xmlFile.replace(/\s*<[\w\s="]+>\n*\s*<\/[\w\s="]+>/g, "")).length) {
}
fs.writeFileSync(filePath, xmlFile);
}

function clearEmptyHashValueLine(filePath) {
const text = fs.readFileSync(filePath, 'utf-8');
const lines = text.split('\n');
const modifiedLines = lines.filter((line) => !line.includes('<HASH_VALUE>'));
fs.writeFileSync(filePath, modifiedLines.join('\n').replace(/\n\r(\n\r)+/g, '\n\r'));
}

function commitAndPush(directory, release, branch)
Expand Down
61 changes: 58 additions & 3 deletions release/fillReleaseNotesTemplate.js
Original file line number Diff line number Diff line change
Expand Up @@ -21,12 +21,66 @@ function addHashesToReleaseNotes(releaseNotes) {
// Inside package column, we have the package name inside the square brackets
const packageName = packageColumn.substring(packageColumn.indexOf('[') + 1, packageColumn.indexOf(']'));

return line.replace('<HASH>', hashes[packageName]);
if (hashes[packageName])
return line.replace('<HASH>', hashes[packageName]);
else
return line;
});

return modifiedLines.join('\n');
}

/**
*
* @param {*} releaseNotes Release notes template text content
* @returns Release notes where not filling in lines is removed
*/
function removeMissingBuild(releaseNotes) {
var buildNames = [];
var buildDescriptionIndexes = [];

const lines = releaseNotes.split('\n');
lines.forEach((line) => {
if (line.includes('<HASH>')) {
buildNames.push(line.substring(line.indexOf('|') + 1, line.indexOf('|', line.indexOf('|') + 1)).trim());
}
});

for (var i = 0; i < lines.length; i++) {
if (containBuildDescriptionHeader(lines[i], buildNames) !== -1) {
var endIndex = -1;
var numberOfOccurrences = 0;
buildDescriptionIndexes.push(i - 1); // add empty string before description index
buildDescriptionIndexes.push(i);
while (i < lines.length && endIndex === -1)
{
i++;
buildDescriptionIndexes.push(i);
if (lines[i].indexOf('```') !== -1) {
numberOfOccurrences++;
if (numberOfOccurrences === 2) {
endIndex = i;
}
}
}
}
}

return lines
.filter((line, idx) => line.indexOf('<HASH>') === -1 && buildDescriptionIndexes.indexOf(idx) === -1)
.join('\n');
}

/**
*
* @param {*} line Line of release notes
* @param {*} buildNames List of build names
* @returns index of buildescription header
*/
function containBuildDescriptionHeader(line, buildNames) {
return buildNames.findIndex(bn => line.indexOf('## ' + bn) >= 0);
}

/**
* @param {string} releaseNotes Release notes template text content
* @param {string} agentVersion Agent version, e.g. 2.193.0
Expand All @@ -51,8 +105,9 @@ function main() {
const releaseNotes = fs.readFileSync(releaseNotesPath, 'utf-8');

const releaseNotesWithAgentVersion = addAgentVersionToReleaseNotes(releaseNotes, agentVersion);
const filledReleaseNotes = addHashesToReleaseNotes(releaseNotesWithAgentVersion);
fs.writeFileSync(releaseNotesPath, filledReleaseNotes);
const filledReleaseNotes = addHashesToReleaseNotes(releaseNotesWithAgentVersion);
const cleanedReleaseNotes = removeMissingBuild(filledReleaseNotes);
fs.writeFileSync(releaseNotesPath, cleanedReleaseNotes);
}

main();

0 comments on commit 122f5de

Please sign in to comment.