Skip to content

Commit 41cfab7

Browse files
author
harvey_xiang
committed
ci: update sync release
1 parent fb8109b commit 41cfab7

1 file changed

Lines changed: 13 additions & 1 deletion

File tree

scripts/fetch-releases.mjs

Lines changed: 13 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
import { writeFileSync } from 'fs'
1+
import { writeFileSync, readFileSync, existsSync } from 'fs'
22
import fetch from 'node-fetch'
33

44
function processReleases(data) {
@@ -87,6 +87,18 @@ async function fetchReleases() {
8787
}, null, 2)
8888

8989
const targetPath = new URL('../content/releases.json', import.meta.url)
90+
91+
// Check if there are any new versions or changes
92+
if (existsSync(targetPath)) {
93+
const existingContent = readFileSync(targetPath, 'utf8')
94+
const existingContentObj = JSON.parse(existingContent)
95+
96+
if (existingContentObj.versions[0].name === processedData[0].name) {
97+
console.log(`current version is ${existingContentObj.versions[0].name}, No new versions or changes detected. Skipping write.`)
98+
return
99+
}
100+
}
101+
90102
writeFileSync(targetPath, changelogContent)
91103

92104
console.log('Successfully generated releases data at content/releases.json')

0 commit comments

Comments
 (0)