Skip to content

Commit

Permalink
Add frontend update script to automate sync with latest frontend rele…
Browse files Browse the repository at this point in the history
…ase (#435)

* Add frontend update script

* nit

* Update URL
  • Loading branch information
huchenlei authored Dec 5, 2024
1 parent 2db6fad commit 72d0219
Show file tree
Hide file tree
Showing 2 changed files with 42 additions and 1 deletion.
3 changes: 2 additions & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -49,7 +49,8 @@
"typescript": "yarn run tsc",
"vite:compile": "vite build --config vite.main.config.ts && vite build --config vite.preload.config.ts",
"vite:types": "vite build --config vite.types.config.ts && node scripts/prepareTypes.js",
"release:types": "node scripts/releaseTypes.js"
"release:types": "node scripts/releaseTypes.js",
"update:frontend": "node scripts/updateFrontend.js"
},
"devDependencies": {
"@electron/fuses": "^1.8.0",
Expand Down
40 changes: 40 additions & 0 deletions scripts/updateFrontend.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,40 @@
const { execSync } = require('child_process')
const { readFileSync, writeFileSync } = require('fs')

async function main() {
try {
// Create a new branch with version-bump prefix
console.log('Creating new branch...')
const date = new Date().toISOString().split('T')[0]
const timestamp = new Date().getTime()
const branchName = `version-bump-${date}-${timestamp}`
execSync(`git checkout -b ${branchName} -t origin/main`, { stdio: 'inherit' })

// Get latest frontend release: https://github.com/Comfy-Org/ComfyUI_frontend/releases
const latestRelease = 'https://api.github.com/repos/Comfy-Org/ComfyUI_frontend/releases/latest'
const latestReleaseData = await fetch(latestRelease)
const latestReleaseTag = (await latestReleaseData.json()).tag_name
const version = latestReleaseTag.replace('v', '')

// Update frontend version in package.json
const packageJson = JSON.parse(readFileSync('./package.json', 'utf8'))
packageJson.config.frontendVersion = version
writeFileSync('./package.json', JSON.stringify(packageJson, null, 2))

// Commit the version bump
execSync(`git commit -am "[chore] Update frontend to ${version}"`, { stdio: 'inherit' })

// Create the PR
console.log('Creating PR...')
execSync(
`gh pr create --title "[chore] Update frontend to ${version}" --label "dependencies" --body "Automated frontend update to ${version}"`,
{ stdio: 'inherit' }
)

console.log(`✅ Successfully created PR for frontend ${version}`)
} catch (error) {
console.error('❌ Error during release process:', error.message)
}
}

main()

0 comments on commit 72d0219

Please sign in to comment.