เรียนรู้วิธีสร้าง Automated Release Workflow สำหรับ Frappe App รวมถึง Version Bump, CHANGELOG Generation, Git Tags และ GitHub Release

การ Release Frappe App แบบ Manual นั้นใช้เวลาและมีโอกาสผิดพลาด บทความนี้จะแนะนำวิธีสร้าง Automated Release Workflow ที่ช่วยให้การ Bump Version, Generate CHANGELOG, และ Create GitHub Release เป็นเรื่องง่าย
your_app/__init__.py - __version__ = "x.y.z"frontend/package.json - "version": "x.y.z"package.json - "version": "x.y.z"CHANGELOG.md - Auto-generatedcd apps/your_app
yarn add -D standard-version
# หรือ
npm install --save-dev standard-version{
"name": "your_app",
"version": "1.0.0",
"devDependencies": {
"standard-version": "^9.5.0"
},
"scripts": {
"release": "standard-version",
"release:patch": "standard-version --release-as patch",
"release:minor": "standard-version --release-as minor",
"release:major": "standard-version --release-as major"
}
}สำหรับ Sync Version ไปยังหลายไฟล์:
ใช้ Format นี้สำหรับ Commit Messages:
| Prefix | CHANGELOG Section | ตัวอย่าง |
|---|---|---|
feat: | ✨ Features | feat: add dark mode toggle |
fix: | 🐛 Bug Fixes | fix: resolve login timeout |
docs: | 📚 Documentation | docs: update API reference |
chore: | 🔧 Maintenance | chore: update dependencies |
ci: | 👷 CI/CD | ci: add GitHub Actions workflow |
refactor: | ♻️ Refactoring | refactor: simplify auth logic |
perf: | ⚡ Performance | perf: optimize database queries |
test: | 🧪 Tests | test: add unit tests for utils |
git add --all
git commit -m "feat: add new dashboard feature"# Patch Release (1.0.0 → 1.0.1)
yarn release:patch
# Minor Release (1.0.0 → 1.1.0)
yarn release:minor
# Major Release (1.0.0 → 2.0.0)
yarn release:majorstandard-version จะ:
chore(release): x.y.zvx.y.zตรวจสอบว่าทุกไฟล์ถูก Update:
# Check Python version
grep "__version__" your_app/__init__.py
# Check package.json
cat package.json | grep version
# Check frontend/package.json
cat frontend/package.json | grep versiongit push origin develop --follow-tagsสำคัญ: ใช้ --follow-tags เพื่อ Push Tag ที่สร้างโดย standard-version
git checkout main
git pull origin main
git merge develop --no-edit
git push origin main
git checkout developหรือใช้ GitHub Actions Auto-merge Workflow
gh release create v1.5.0 \
--target main \
--title "v1.5.0" \
--generate-notesหรือใช้ Notes จาก CHANGELOG:
# Extract latest release notes
NOTES=$(sed -n '/^## \[1.5.0\]/,/^## \[/p' CHANGELOG.md | head -n -1)
gh release create v1.5.0 \
--target main \
--title "v1.5.0" \
--notes "$NOTES"สร้างไฟล์ .github/workflows/release.yml:
Workflow ควรมี Safety Checks:
หลัง Release เสร็จ ควรแสดง Summary:
🎉 Release 1.5.0 completed successfully!
📱 App: your_app
📦 Version: 1.4.0 → 1.5.0
📄 Updated files:
- your_app/__init__.py
- frontend/package.json
- package.json
- CHANGELOG.md ✨
🔀 Branch: develop → main
🏷️ Tag: v1.5.0
🔗 Release: https://github.com/username/your_app/releases/tag/v1.5.0
Automated Release Workflow ช่วยให้:
สิ่งที่ต้องมี:
// .versionrc.js
module.exports = {
bumpFiles: [
{
filename: "package.json",
type: "json",
},
{
filename: "frontend/package.json",
type: "json",
},
{
filename: "your_app/__init__.py",
updater: require.resolve("./scripts/python-version-updater.js"),
},
],
tagPrefix: "v",
header: "# Changelog\n\nAll notable changes to this project will be documented in this file.\n",
types: [
{ type: "feat", section: "✨ Features" },
{ type: "fix", section: "🐛 Bug Fixes" },
{ type: "chore", section: "🔧 Maintenance" },
{ type: "docs", section: "📚 Documentation" },
{ type: "style", section: "💄 Styles" },
{ type: "refactor", section: "♻️ Refactoring" },
{ type: "perf", section: "⚡ Performance" },
{ type: "test", section: "🧪 Tests" },
{ type: "ci", section: "👷 CI/CD" },
],
};// scripts/python-version-updater.js
module.exports.readVersion = function (contents) {
const match = contents.match(/__version__\s*=\s*["'](.+)["']/);
return match ? match[1] : null;
};
module.exports.writeVersion = function (contents, version) {
return contents.replace(
/__version__\s*=\s*["'].+["']/,
`__version__ = "${version}"`
);
};# Changelog
All notable changes to this project will be documented in this file.
## [1.5.0](https://github.com/username/your_app/compare/v1.4.0...v1.5.0) (2026-02-03)
### ✨ Features
* add dark mode toggle ([abc1234](https://github.com/username/your_app/commit/abc1234))
* implement user preferences panel ([def5678](https://github.com/username/your_app/commit/def5678))
### 🐛 Bug Fixes
* resolve login timeout issue ([ghi9012](https://github.com/username/your_app/commit/ghi9012))
### 🔧 Maintenance
* update dependencies to latest versions ([jkl3456](https://github.com/username/your_app/commit/jkl3456))name: Release
on:
push:
tags:
- 'v*'
jobs:
release:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
with:
fetch-depth: 0
- name: Create GitHub Release
uses: softprops/action-gh-release@v1
with:
generate_release_notes: true
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}# .github/workflows/auto-merge.yml
name: Auto-merge to Main
on:
push:
branches:
- develop
jobs:
merge:
runs-on: ubuntu-latest
if: contains(github.event.head_commit.message, 'chore(release)')
steps:
- uses: actions/checkout@v4
with:
fetch-depth: 0
- name: Merge to main
run: |
git config user.name github-actions
git config user.email [email protected]
git checkout main
git merge origin/develop --no-edit
git push origin main