Skip to content

Commit

Permalink
[Release Notes Automation] several enhancements (#550)
Browse files Browse the repository at this point in the history
  • Loading branch information
yangyansong-adbe authored Apr 2, 2024
1 parent 593f30c commit e7cc075
Show file tree
Hide file tree
Showing 3 changed files with 23 additions and 7 deletions.
2 changes: 1 addition & 1 deletion .github/scripts/release_notes/android-release.js
Original file line number Diff line number Diff line change
Expand Up @@ -158,7 +158,7 @@ function buildGitHubInfo(artifactId, artifactVersion) {
case "identity":
case "signal":
return {
repoName: `aepsdk-${artifactId}-android`,
repoName: `aepsdk-core-android`,
tagName: `v${artifactVersion}-${artifactId}`
}

Expand Down
3 changes: 1 addition & 2 deletions .github/scripts/release_notes/github-release.js
Original file line number Diff line number Diff line change
Expand Up @@ -95,11 +95,10 @@ async function fetchReleaseInfoWithTagName(token, owner, repo, tag) {
};

console.log(`request options: ${JSON.stringify(options)}`)

return new Promise((resolve) => {
let reqGet = https.request(options, function (res) {
if (res.statusCode != 200) {
console.error(`Error: response statusCode: ${res.statusCode}, please check if the tag (${tag}) exists in Github repo.`)
throw Error(`Error: response statusCode: ${res.statusCode}, please check if the tag (${tag}) exists in Github repo.`)
}
console.log(`response statusCode: ${res.statusCode}`)

Expand Down
25 changes: 21 additions & 4 deletions .github/scripts/release_notes/update-release-notes.js
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@ const { fetchAndroidReleaseInfo } = require('./android-release');
const { capitalizeFirstLetter, convertISODateToRleaseDateFormat, extractReleaseNotes } = require('./utils');
const lodashTemplate = require('lodash.template');
const fs = require("fs");
const _ = require('lodash');

const repoNames = [
"aepsdk-roku",
Expand Down Expand Up @@ -102,10 +103,27 @@ function extractBOMTableContent(releaseNote) {
return newLines
}

function cleanupReleaseContent(items) {
// Find the index of the first non-empty item
const firstNonEmptyIndex = _.findIndex(items, item => item.trim() !== '');

// Find the index of the last non-empty item
const lastNonEmptyIndex = _.findLastIndex(items, item => item.trim() !== '');

// If no non-empty items are found, return an empty array
if (firstNonEmptyIndex === -1 || lastNonEmptyIndex === -1) {
return [];
}

// Return the array sliced from the first to the last non-empty item
const trimmedItems = items.slice(firstNonEmptyIndex, lastNonEmptyIndex + 1);
// If the first non-empty item is "-", replace it with "*"
return trimmedItems.map(item => item.replace(/^\s*-/, '*'))
}

function generateReleaseNoteSection(ISODateString, platform, extension, version, releaseNote) {
let array = extractReleaseNotes(releaseNote)
// remove the empty lines
array = array.filter(line => line.trim() != '')
array = cleanupReleaseContent(array)
let releaseNoteSection = releaseNoteTemplateGenerator({
date: convertISODateToRleaseDateFormat(ISODateString),
title: `${platform} ${extension} ${version}`,
Expand All @@ -116,8 +134,7 @@ function generateReleaseNoteSection(ISODateString, platform, extension, version,

function generateReleaseNoteSectionWithoutDateLine(platform, extension, version, releaseNote) {
let array = extractReleaseNotes(releaseNote)
// remove the empty lines
array = array.filter(line => line.trim() != '')
array = cleanupReleaseContent(array)
let releaseNoteSection = releaseNoteWithoutDateTemplateGenerator({
title: `${platform} ${extension} ${version}`,
note: array.join('\n')
Expand Down

0 comments on commit e7cc075

Please sign in to comment.