From 0bc8544411d7f3dcdd2e7fae9cdf36e6376be40f Mon Sep 17 00:00:00 2001 From: duanfuxiang Date: Mon, 6 Jan 2025 21:17:22 +0800 Subject: [PATCH] update github release note --- .github/scripts/get-changelog.js | 99 +++++++++++++++++++++++--------- .github/workflows/release.yml | 1 + CHANGELOG.md | 7 --- CHANGELOG.yaml | 29 ++++++++++ 4 files changed, 101 insertions(+), 35 deletions(-) delete mode 100644 CHANGELOG.md create mode 100644 CHANGELOG.yaml diff --git a/.github/scripts/get-changelog.js b/.github/scripts/get-changelog.js index c72b1f7..d2e67c1 100755 --- a/.github/scripts/get-changelog.js +++ b/.github/scripts/get-changelog.js @@ -2,40 +2,83 @@ const fs = require('fs'); const path = require('path'); +const yaml = require('js-yaml'); // Get version from command line argument const version = process.argv[2]; if (!version) { - console.error('Please provide version as argument'); + console.error('Error: Please provide version as argument'); process.exit(1); } -// Read CHANGELOG.md -const changelogPath = path.join(process.cwd(), 'CHANGELOG.md'); -const content = fs.readFileSync(changelogPath, 'utf8'); - -// Split content into sections by h2 headers -const sections = content.split(/\n## /); - -// Find the section for the specified version -const versionSection = sections.find(section => section.trim().startsWith(version)); - -if (!versionSection) { - console.error(`No changelog found for version ${version}`); +try { + // Read CHANGELOG.yaml + const changelogPath = path.join(process.cwd(), 'CHANGELOG.yaml'); + const content = fs.readFileSync(changelogPath, 'utf8'); + + // Parse YAML content + const changelog = yaml.load(content); + + if (!changelog || !Array.isArray(changelog.releases)) { + console.error('Error: Invalid changelog format. Expected array of releases.'); + process.exit(1); + } + + // Find the release entry for the specified version + const release = changelog.releases.find(r => r.version === version); + + if (!release) { + console.error(`Error: No changelog found for version ${version}`); + process.exit(1); + } + + // Format the release notes + let output = ''; + + // Features + if (release.features && release.features.length > 0) { + output += '### ✨ New Features\n\n'; + release.features.forEach(feature => { + output += `- ${feature}\n`; + }); + output += '\n'; + } + + // Fixes + if (release.fixes && release.fixes.length > 0) { + output += '### 🐛 Bug Fixes\n\n'; + release.fixes.forEach(fix => { + output += `- ${fix}\n`; + }); + output += '\n'; + } + + // Improvements + if (release.improvements && release.improvements.length > 0) { + output += '### 🚀 Improvements\n\n'; + release.improvements.forEach(improvement => { + output += `- ${improvement}\n`; + }); + output += '\n'; + } + + // Other changes + if (release.other && release.other.length > 0) { + output += '### 📝 Other Changes\n\n'; + release.other.forEach(change => { + output += `- ${change}\n`; + }); + } + + if (!output) { + console.error('Error: No changes found in the release'); + process.exit(1); + } + + // Output the formatted release notes + console.log(output.trim()); + +} catch (error) { + console.error(`Error processing changelog: ${error.message}`); process.exit(1); } - -// Extract and format the changelog entries -const lines = versionSection - .split('\n') - .slice(1) // Remove the version line itself - .filter(line => line.trim().startsWith('- ')) // Only keep bullet points - .join('\n') - .trim(); - -if (!lines) { - console.error('No bullet points found in changelog section'); - process.exit(1); -} - -console.log(lines); diff --git a/.github/workflows/release.yml b/.github/workflows/release.yml index 9a45cb5..183b1f6 100644 --- a/.github/workflows/release.yml +++ b/.github/workflows/release.yml @@ -23,6 +23,7 @@ jobs: id: build run: | npm install + npm install js-yaml npm run build - name: Test diff --git a/CHANGELOG.md b/CHANGELOG.md deleted file mode 100644 index 45a55e1..0000000 --- a/CHANGELOG.md +++ /dev/null @@ -1,7 +0,0 @@ -# Changelog - -## 0.0.2 - -### Fixed -- Fixed memory leak in chat interface -- Corrected markdown rendering issues diff --git a/CHANGELOG.yaml b/CHANGELOG.yaml new file mode 100644 index 0000000..f485631 --- /dev/null +++ b/CHANGELOG.yaml @@ -0,0 +1,29 @@ +releases: + - version: "0.0.2" + improvements: + - "Converted webp to gif format for better compatibility" + - "Added demo gif for better documentation" + other: + - "Updated GitHub release process" + - "Updated release notes" + - "Added changelog documentation" + - "Removed unused markdown files and low quality demo images" + + - version: "0.0.1" + features: + - "Implemented real-time code suggestions" + - "Initial release of obsidian-infio-copilot plugin" + - "Basic functionality for AI-powered assistance in Obsidian" + - "Interactive chat with selected notes" + - "Smart autocomplete based on your notes" + - "Enhanced user experience with customizable prompts" + - "Integration with Obsidian's search functionality" + fixes: + - "Fixed markdown rendering issues in the editor" + - "Resolved connection timeout problems" + improvements: + - "Enhanced code completion performance" + - "Optimized memory usage" + other: + - "Updated documentation" + - "Added more test coverage"