Skip to content

Commit

Permalink
fix: update release notes overview
Browse files Browse the repository at this point in the history
  • Loading branch information
DaRaFF committed Jul 25, 2022
1 parent 68764c9 commit 15decb1
Show file tree
Hide file tree
Showing 4 changed files with 54 additions and 4 deletions.
2 changes: 1 addition & 1 deletion cli.js
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
#!/usr/bin/env node
console.log('release-notes-patch -> v1.5.5 (changed upcoming release format (PRs to categorize))')
console.log('release-notes-patch -> v1.5.6 (update release notes overview)')
const argv = require('yargs')
.demandOption(['token', 'owner', 'repo', 'sha', 'tag'])
.help(false)
Expand Down
23 changes: 20 additions & 3 deletions index.js
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@ const getPullBySha = require('./lib/git/get-pull-by-sha')
const addPatchToReleaseNote = require('./lib/add-patch-to-release-note')
const addPatchToUpcomingReleaseNote = require('./lib/add-patch-to-upcoming-release-note')
const updateContent = require('./lib/git/update-content')
const patchReleaseNotesOverview = require('./patch-release-notes-overview')


const createBranchList = require('./lib/create-branch-list')
Expand Down Expand Up @@ -41,7 +42,7 @@ module.exports = async ({token, owner, repo, sha, tag, test = false} = {}) => {
const originReleaseNote = Buffer.from(releaseNote.content, 'base64').toString('utf8')

let patchedReleaseNotes
// patch release notes for upcoming release
// patch release notes detail for upcoming release
if (release.branchName === 'master') {
const pull = await getPullBySha({owner, repo, token, sha})
patchedReleaseNotes = addPatchToUpcomingReleaseNote({
Expand All @@ -51,7 +52,7 @@ module.exports = async ({token, owner, repo, sha, tag, test = false} = {}) => {
path,
pull
})
// patch release notes of official releases
// patch release notes detail of official releases
} else {
patchedReleaseNotes = addPatchToReleaseNote({
owner,
Expand All @@ -65,8 +66,11 @@ module.exports = async ({token, owner, repo, sha, tag, test = false} = {}) => {

const patchedBase64ReleaseNotes = Buffer.from(patchedReleaseNotes).toString('base64')

const {patchedBase64ReleaseNotesOverview, releaseNotesOverviewSha, releaseNotesOverviewHtml} = await patchReleaseNotesOverview({token, owner, repo, sha, tag, test, release})

if (test) return `TEST MODE: do not commit changes`

// update release notes detail
await updateContent({
owner: targetOwner,
repo: targetRepo,
Expand All @@ -78,5 +82,18 @@ module.exports = async ({token, owner, repo, sha, tag, test = false} = {}) => {
branch: branchName
})

return `update of release-notes with tag ${tag} at ${releaseNote.html_url} sucessfull`
// update release notes overview
await updateContent({
owner: targetOwner,
repo: targetRepo,
token,
path: 'data/releases.json',
message: `fix(${release.branchName}): update release notes overview for ${release.branchName} for ${repo} with tag ${tag}`,
content: patchedBase64ReleaseNotesOverview,
sha: releaseNotesOverviewSha.sha,
branch: branchName
})

return `update of release-notes with tag ${tag} at ${releaseNote.html_url} sucessfull\n\n` +
`update of release-notes overview with tag ${tag} at ${releaseNotesOverviewHtml} sucessfull`
}
1 change: 1 addition & 0 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@
"license": "ISC",
"dependencies": {
"axios": "^0.23.0",
"lodash": "^4.17.21",
"moment": "^2.24.0",
"yargs": "^12.0.2"
},
Expand Down
32 changes: 32 additions & 0 deletions patch-release-notes-overview.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,32 @@
const _ = require('lodash')
const getReleaseNote = require('./lib/get-release-note')
const targetOwner = 'livingdocsIO'
const targetRepo = 'documentation'

module.exports = async ({token, owner, repo, sha, tag, test = false, release} = {}) => {
const path = `data/releases.json`
const {releaseNote, branchName} = await getReleaseNote({
owner: targetOwner,
repo: targetRepo,
path,
token,
releaseName: release.branchName
})

// base64 to string
const originContent = JSON.parse(Buffer.from(releaseNote.content, 'base64').toString('utf8'))
const patchedContent = _.cloneDeep(originContent)

if (repo === 'livingdocs-editor') {
patchedContent[release.branchName].editorVersion = tag
console.log(`\n\nUpdate Release Notes overview: Set '${release.branchName}.editorVersion' to ${tag}\n\n`)
}
if (repo === 'livingdocs-server') {
patchedContent[release.branchName].serverVersion = tag
console.log(`\n\nUpdate Release Notes overview: Set '${release.branchName}.serverVersion' to ${tag}\n\n`)
}

const patchedBase64Content = Buffer.from(JSON.stringify(patchedContent)).toString('base64')

return {patchedBase64Content, releaseNotesOverviewSha: releaseNote.sha, releaseNotesOverviewHtml: releaseNote.html_url}
}

0 comments on commit 15decb1

Please sign in to comment.