踐:配合GitHub Tag Action實(shí)現(xiàn)自動(dòng)化版本管理)
conventional commits實(shí)踐配合GitHub Tag Action實(shí)現(xiàn)自動(dòng)化版本管理【免費(fèi)下載鏈接】github-tag-actionA Github Action to automatically bump and tag master, on merge, with the latest SemVer formatted version. Works on any platform.項(xiàng)目地址: https://gitcode.com/gh_mirrors/git/github-tag-actionGitHub Tag Action是一款強(qiáng)大的工具能在代碼合并時(shí)自動(dòng)為master分支生成符合SemVer規(guī)范的標(biāo)簽實(shí)現(xiàn)自動(dòng)化版本管理。本文將詳細(xì)介紹如何結(jié)合Conventional Commits規(guī)范與GitHub Tag Action輕松搞定項(xiàng)目版本管理。什么是Conventional Commits規(guī)范Conventional Commits規(guī)范是一種基于提交消息的輕量級(jí)約定。它規(guī)定了提交消息的格式使得自動(dòng)化工具能夠據(jù)此確定版本號(hào)變更和生成變更日志。遵循該規(guī)范的提交消息通常包含類型、作用域和描述等部分例如feat(pencil): add graphiteWidth option。GitHub Tag Action簡(jiǎn)介GitHub Tag Action是一個(gè)GitHub Action可在合并代碼到指定分支時(shí)自動(dòng)更新和推送Git標(biāo)簽。它基于SemVer格式化版本號(hào)適用于任何平臺(tái)。該工具通過(guò)分析提交消息來(lái)確定版本變更類型如major、minor、patch等并生成相應(yīng)的標(biāo)簽。GitHub Tag Action的主要功能根據(jù)提交消息自動(dòng)確定版本變更類型生成符合SemVer規(guī)范的標(biāo)簽支持自定義標(biāo)簽前綴、分支規(guī)則等輸出變更日志、新舊版本號(hào)等信息快速開(kāi)始GitHub Tag Action的基本使用要在項(xiàng)目中使用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的完美結(jié)合提交消息格式詳解GitHub Tag Action使用semantic-release conventions來(lái)解析提交消息默認(rèn)采用Angular Commit Message Conventions。以下是不同提交消息對(duì)應(yīng)的版本變更類型提交消息示例版本變更類型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自定義提交規(guī)則如果默認(rèn)的提交規(guī)則不符合項(xiàng)目需求可以通過(guò)custom_release_rules參數(shù)自定義。例如with: custom_release_rules: hotfix:patch,pre-feat:preminor,bug:patch:Bug Fixes,chore:patch:ChoresGitHub Tag Action的高級(jí)配置分支管理GitHub Tag Action允許通過(guò)參數(shù)指定哪些分支生成正式版本標(biāo)簽?zāi)男┥深A(yù)發(fā)布標(biāo)簽release_branches: 生成正式版本標(biāo)簽的分支默認(rèn)值為master,mainpre_release_branches: 生成預(yù)發(fā)布版本標(biāo)簽的分支標(biāo)簽自定義可以通過(guò)以下參數(shù)自定義生成的標(biāo)簽tag_prefix: 標(biāo)簽前綴默認(rèn)值為vappend_to_pre_release_tag: 預(yù)發(fā)布標(biāo)簽后綴默認(rèn)值為分支名create_annotated_tag: 是否創(chuàng)建帶注釋的標(biāo)簽?zāi)J(rèn)值為false其他實(shí)用配置fetch_all_tags: 是否獲取所有標(biāo)簽?zāi)J(rèn)只獲取最近100個(gè)標(biāo)簽dry_run: 僅計(jì)算版本和變更日志不實(shí)際創(chuàng)建標(biāo)簽default_bump: 當(dāng)沒(méi)有明確的提交消息時(shí)使用的默認(rèn)版本變更類型默認(rèn)值為patch常見(jiàn)問(wèn)題與解決方案沒(méi)有提交指定版本變更時(shí)如何處理如果沒(méi)有提交指定版本變更GitHub Tag Action會(huì)輸出No commit specifies the version bump. Skipping the tag creation.。此時(shí)可以通過(guò)設(shè)置default_bump參數(shù)來(lái)指定默認(rèn)的版本變更類型。如何獲取生成的版本信息GitHub Tag Action提供了多個(gè)輸出參數(shù)可以在后續(xù)步驟中使用new_tag: 新生成的標(biāo)簽new_version: 新生成的版本號(hào)不帶前綴previous_tag: 上一個(gè)標(biāo)簽release_type: 版本變更類型changelog: 變更日志總結(jié)通過(guò)Conventional Commits規(guī)范與GitHub Tag Action的結(jié)合我們可以實(shí)現(xiàn)版本管理的自動(dòng)化減少手動(dòng)操作提高開(kāi)發(fā)效率。只需遵循簡(jiǎn)單的提交消息規(guī)范GitHub Tag Action就能自動(dòng)為我們生成版本標(biāo)簽和變更日志讓版本管理變得輕松簡(jiǎn)單。要開(kāi)始使用GitHub Tag Action只需克隆倉(cāng)庫(kù)git clone https://gitcode.com/gh_mirrors/git/github-tag-action然后按照本文介紹的方法進(jìn)行配置即可。希望本文能幫助你更好地理解和使用Conventional Commits與GitHub Tag Action實(shí)現(xiàn)高效的版本管理【免費(fèi)下載鏈接】github-tag-actionA Github Action to automatically bump and tag master, on merge, with the latest SemVer formatted version. Works on any platform.項(xiàng)目地址: https://gitcode.com/gh_mirrors/git/github-tag-action創(chuàng)作聲明:本文部分內(nèi)容由AI輔助生成(AIGC),僅供參考