
conventional commits實踐配合GitHub Tag Action實現自動化版本管理【免費下載鏈接】github-tag-actionA Github Action to automatically bump and tag master, on merge, with the latest SemVer formatted version. Works on any platform.項目地址: https://gitcode.com/gh_mirrors/git/github-tag-actionGitHub Tag Action是一款強大的工具能在代碼合并時自動為master分支生成符合SemVer規范的標簽實現自動化版本管理。本文將詳細介紹如何結合Conventional Commits規范與GitHub Tag Action輕松搞定項目版本管理。什么是Conventional Commits規范Conventional Commits規范是一種基于提交消息的輕量級約定。它規定了提交消息的格式使得自動化工具能夠據此確定版本號變更和生成變更日志。遵循該規范的提交消息通常包含類型、作用域和描述等部分例如feat(pencil): add graphiteWidth option。GitHub Tag Action簡介GitHub Tag Action是一個GitHub Action可在合并代碼到指定分支時自動更新和推送Git標簽。它基于SemVer格式化版本號適用于任何平臺。該工具通過分析提交消息來確定版本變更類型如major、minor、patch等并生成相應的標簽。GitHub Tag Action的主要功能根據提交消息自動確定版本變更類型生成符合SemVer規范的標簽支持自定義標簽前綴、分支規則等輸出變更日志、新舊版本號等信息快速開始GitHub Tag Action的基本使用要在項目中使用GitHub Tag Action只需在工作流文件中添加以下步驟name: Bump version on: push: branches: - master jobs: build: runs-on: ubuntu-latest steps: - uses: actions/checkoutv4 - name: Bump version and push tag id: tag_version uses: mathieudutour/github-tag-actionv6.2 with: github_token: ${{ secrets.GITHUB_TOKEN }} - name: Create a GitHub release uses: ncipollo/release-actionv1 with: tag: ${{ steps.tag_version.outputs.new_tag }} name: Release ${{ steps.tag_version.outputs.new_tag }} body: ${{ steps.tag_version.outputs.changelog }}Conventional Commits與GitHub Tag Action的完美結合提交消息格式詳解GitHub Tag Action使用semantic-release conventions來解析提交消息默認采用Angular Commit Message Conventions。以下是不同提交消息對應的版本變更類型提交消息示例版本變更類型fix(pencil): stop graphite breaking when too much pressure appliedPatch Releasefeat(pencil): add graphiteWidth optionMinor Releaseperf(pencil): remove graphiteWidth optionBREAKING CHANGE: The graphiteWidth option has been removed.Major Release自定義提交規則如果默認的提交規則不符合項目需求可以通過custom_release_rules參數自定義。例如with: custom_release_rules: hotfix:patch,pre-feat:preminor,bug:patch:Bug Fixes,chore:patch:ChoresGitHub Tag Action的高級配置分支管理GitHub Tag Action允許通過參數指定哪些分支生成正式版本標簽哪些生成預發布標簽release_branches: 生成正式版本標簽的分支默認值為master,mainpre_release_branches: 生成預發布版本標簽的分支標簽自定義可以通過以下參數自定義生成的標簽tag_prefix: 標簽前綴默認值為vappend_to_pre_release_tag: 預發布標簽后綴默認值為分支名create_annotated_tag: 是否創建帶注釋的標簽默認值為false其他實用配置fetch_all_tags: 是否獲取所有標簽默認只獲取最近100個標簽dry_run: 僅計算版本和變更日志不實際創建標簽default_bump: 當沒有明確的提交消息時使用的默認版本變更類型默認值為patch常見問題與解決方案沒有提交指定版本變更時如何處理如果沒有提交指定版本變更GitHub Tag Action會輸出No commit specifies the version bump. Skipping the tag creation.。此時可以通過設置default_bump參數來指定默認的版本變更類型。如何獲取生成的版本信息GitHub Tag Action提供了多個輸出參數可以在后續步驟中使用new_tag: 新生成的標簽new_version: 新生成的版本號不帶前綴previous_tag: 上一個標簽release_type: 版本變更類型changelog: 變更日志總結通過Conventional Commits規范與GitHub Tag Action的結合我們可以實現版本管理的自動化減少手動操作提高開發效率。只需遵循簡單的提交消息規范GitHub Tag Action就能自動為我們生成版本標簽和變更日志讓版本管理變得輕松簡單。要開始使用GitHub Tag Action只需克隆倉庫git clone https://gitcode.com/gh_mirrors/git/github-tag-action然后按照本文介紹的方法進行配置即可。希望本文能幫助你更好地理解和使用Conventional Commits與GitHub Tag Action實現高效的版本管理【免費下載鏈接】github-tag-actionA Github Action to automatically bump and tag master, on merge, with the latest SemVer formatted version. Works on any platform.項目地址: https://gitcode.com/gh_mirrors/git/github-tag-action創作聲明:本文部分內容由AI輔助生成(AIGC),僅供參考