Skip to content

Commit

Permalink
[Release Notes Automation] Set the default time zone to PST (#533)
Browse files Browse the repository at this point in the history
* Set the default time zone to Central Time before running the scripts

* fix typo

* update the default time zone to PST

* update comments

* update logs

---------

Co-authored-by: calebk1 <[email protected]>
  • Loading branch information
yangyansong-adbe and calebk1 authored Mar 20, 2024
1 parent c3074c9 commit baef8d8
Show file tree
Hide file tree
Showing 3 changed files with 18 additions and 9 deletions.
9 changes: 9 additions & 0 deletions .github/scripts/release_notes/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,15 @@ if (token == undefined) {
throw new Error("token is undefined")
}

//before running the script, make sure the default time zone is set to PST in the GitHub action
process.env.TZ = "America/Los_Angeles"

const offset = new Date().getTimezoneOffset()

if (offset != 420) {
throw new Error("The default time zone is not set to PST")
}

run()

async function run() {
Expand Down
12 changes: 6 additions & 6 deletions .github/scripts/release_notes/update-release-notes.js
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ governing permissions and limitations under the License.

const { fetchReleaseInfo } = require('./github-release');
const { fetchAndroidReleaseInfo } = require('./android-release');
const { capitalizeFirstLetter, convertIOSDateToRleaseDateFormat, extractReleaseNotes } = require('./utils');
const { capitalizeFirstLetter, convertISODateToRleaseDateFormat, extractReleaseNotes } = require('./utils');
const lodashTemplate = require('lodash.template');
const fs = require("fs");

Expand Down Expand Up @@ -102,12 +102,12 @@ function extractBOMTableContent(releaseNote) {
return newLines
}

function generateReleaseNoteSection(IOSDateString, platform, extension, version, releaseNote) {
function generateReleaseNoteSection(ISODateString, platform, extension, version, releaseNote) {
let array = extractReleaseNotes(releaseNote)
// remove the empty lines
array = array.filter(line => line.trim() != '')
let releaseNoteSection = releaseNoteTemplateGenerator({
date: convertIOSDateToRleaseDateFormat(IOSDateString),
date: convertISODateToRleaseDateFormat(ISODateString),
title: `${platform} ${extension} ${version}`,
note: array.join('\n')
})
Expand All @@ -125,10 +125,10 @@ function generateReleaseNoteSectionWithoutDateLine(platform, extension, version,
return releaseNoteSection
}

function generateBOMReleaseNoteSection(IOSDateString, platform, extension, version, releaseNote) {
function generateBOMReleaseNoteSection(ISODateString, platform, extension, version, releaseNote) {
let array = extractBOMTableContent(releaseNote)
let releaseNoteSection = BOMreleaseNoteTemplateGenerator({
date: convertIOSDateToRleaseDateFormat(IOSDateString),
date: convertISODateToRleaseDateFormat(ISODateString),
title: generateReleaseTitle(platform, extension, version),
note: array.join('\n')
})
Expand Down Expand Up @@ -199,7 +199,7 @@ async function updateReleaseNotesPage(filePath, releaseInfoArray) {
console.error(`Already updated: ${titleLine}`)
continue
}
let dateStr = convertIOSDateToRleaseDateFormat(releaseInfo.published_at)
let dateStr = convertISODateToRleaseDateFormat(releaseInfo.published_at)
let dateLine = `## ${dateStr}`
// If the date line exists in the file, find the index of the date line and add the release notes after it.
if (hasLineStartWith(dateLine, contentLines)) {
Expand Down
6 changes: 3 additions & 3 deletions .github/scripts/release_notes/utils.js
Original file line number Diff line number Diff line change
Expand Up @@ -65,8 +65,8 @@ function capitalizeFirstLetter(string) {
}

// TODO: consider using dayjs to handle date format
function convertIOSDateToRleaseDateFormat(ios1086DateStr) {
const date = new Date(ios1086DateStr)
function convertISODateToRleaseDateFormat(iso8601DateStr) {
const date = new Date(iso8601DateStr)
const month = date.getMonth()
const day = date.getDate()
const year = date.getFullYear()
Expand All @@ -80,6 +80,6 @@ module.exports = {
releaseFileContainsLineStartWith,
saveJsonObjToFile,
extractReleaseNotes,
convertIOSDateToRleaseDateFormat,
convertISODateToRleaseDateFormat,
capitalizeFirstLetter
}

0 comments on commit baef8d8

Please sign in to comment.