**chore(release): enhance deployment workflows with GitHub release automation**
- Added functionality to auto-generate GitHub releases: - Included `scripts/create-github-release.js` to automate release creation with notes. - Modified `scripts/publish-cli.js` to create GitHub releases after publishing packages. - Updated `package.json` to call the GitHub release script during `deploy` and `deploy:cli` commands. - Introduced `CHANGELOG.md` for both main and CLI packages: - Enabled auto-updating of CHANGELOG.md from GitHub release notes. - Added a new `scripts/update-changelog.js` script to synchronize release details with changelogs. - Ensured `CHANGELOG.md` files are included in the published packages. - Improved documentation visibility by displaying release notes on npmjs.com. This update streamlines the release process, ensuring consistent documentation, and aligns npm releases with corresponding GitHub releases for better transparency.
This commit is contained in:
parent
cc3350c578
commit
6d13a6737e
7 changed files with 257 additions and 2 deletions
77
scripts/create-github-release.js
Normal file
77
scripts/create-github-release.js
Normal file
|
|
@ -0,0 +1,77 @@
|
|||
#!/usr/bin/env node
|
||||
|
||||
/**
|
||||
* Create GitHub Release Script
|
||||
*
|
||||
* This script creates a GitHub release with auto-generated release notes
|
||||
* for the current version of the package.
|
||||
*
|
||||
* It uses the GitHub CLI (gh) to create the release, so the gh CLI must be installed
|
||||
* and authenticated with appropriate permissions.
|
||||
*
|
||||
* The script:
|
||||
* 1. Gets the current version from package.json
|
||||
* 2. Creates a GitHub release for that version
|
||||
* 3. Auto-generates release notes based on commits since the last release
|
||||
*
|
||||
* This ensures that each npm release has a corresponding GitHub release with notes.
|
||||
*/
|
||||
|
||||
import { execSync } from 'child_process'
|
||||
import fs from 'fs'
|
||||
import path from 'path'
|
||||
import { fileURLToPath } from 'url'
|
||||
|
||||
// Get the directory of the current module
|
||||
const __filename = fileURLToPath(import.meta.url)
|
||||
const __dirname = path.dirname(__filename)
|
||||
|
||||
// Path to the root directory
|
||||
const rootDir = path.join(__dirname, '..')
|
||||
|
||||
// Path to package.json
|
||||
const packageJsonPath = path.join(rootDir, 'package.json')
|
||||
|
||||
// Read package.json
|
||||
const packageJson = JSON.parse(fs.readFileSync(packageJsonPath, 'utf8'))
|
||||
const version = packageJson.version
|
||||
|
||||
// Check if GitHub CLI is installed
|
||||
try {
|
||||
execSync('gh --version', { stdio: 'ignore' })
|
||||
} catch (error) {
|
||||
console.error('Error: GitHub CLI (gh) is not installed or not in PATH')
|
||||
console.error('Please install it from https://cli.github.com/ and authenticate with `gh auth login`')
|
||||
process.exit(1)
|
||||
}
|
||||
|
||||
// Create the GitHub release
|
||||
try {
|
||||
console.log(`Creating GitHub release for v${version}...`)
|
||||
|
||||
// Create a release with auto-generated notes
|
||||
// The --generate-notes flag automatically generates release notes based on PRs and commits
|
||||
execSync(
|
||||
`gh release create v${version} --title "v${version}" --generate-notes`,
|
||||
{ stdio: 'inherit', cwd: rootDir }
|
||||
)
|
||||
|
||||
console.log(`GitHub release v${version} created successfully!`)
|
||||
|
||||
// Update CHANGELOG.md with the release notes
|
||||
console.log('Updating CHANGELOG.md with release notes...')
|
||||
execSync('node scripts/update-changelog.js', { stdio: 'inherit', cwd: rootDir })
|
||||
} catch (error) {
|
||||
// If the release already exists, this is not a fatal error
|
||||
if (error.message.includes('already exists')) {
|
||||
console.log(`GitHub release v${version} already exists, skipping creation.`)
|
||||
|
||||
// Still update CHANGELOG.md with the release notes
|
||||
console.log('Updating CHANGELOG.md with release notes...')
|
||||
execSync('node scripts/update-changelog.js', { stdio: 'inherit', cwd: rootDir })
|
||||
} else {
|
||||
console.error('Error creating GitHub release:', error.message)
|
||||
// Don't exit with error to allow the npm publish to continue
|
||||
// process.exit(1)
|
||||
}
|
||||
}
|
||||
Loading…
Add table
Add a link
Reference in a new issue