bump version
v2.3.1
此github操作,獲取標籤的值並傳遞到應用程序,在package.json中替換靜態版本。 json,自動,無需創建新的提交並手動更改版本。
此操作,僅適用於類型標籤的推動事件
例子:
on :
push :
tags :
- ' v[0-9]+.[0-9]+.[0-9]+ '如果您將此操作用於無觸發器運行的巨flow,則此步驟將斷開。
目前,只需支持package.json ,需要在root文件夾中
name : Deploy Package to NPM
on :
push :
tags :
- ' v[0-9]+.[0-9]+.[0-9]+ '
jobs :
publish_npm :
name : Publishing to NPM
runs-on : ubuntu-latest
permissions :
actions : write
contents : write
steps :
- uses : actions/checkout@v3
- name : Setup NodeJs
uses : actions/setup-node@v3
with :
node-version : x.y # Version that you want use here
registry-url : https://registry.npmjs.org/
- name : Install Packages
run : yarn
- name : Bump Version of package.json
uses : ramonpaolo/[email protected]
with :
tag : ${{ github.ref_name }} # Accessing the context and get the reference_name, that in this case, is the tag that you created(ex: v1.0.0)
commit : true
branch_to_push : ' main '
- name : Publish package to NPM
run : npm publish
env :
NODE_AUTH_TOKEN : ${{ secrets.NPM_TOKEN }} # NPM Token necessary to deploy packages on pipelines CI/CD | 姓名 | 描述 | 必需的 | 預設 |
|---|---|---|---|
| 標籤 | 創建的標籤(v。*。*。*) | true | “ V1.0.0” |
| 犯罪 | 提出顛簸 | false | false |
| branch_to_push | 哪個分支 | false | “主要的” |
| 小路 | 包裝的路徑。 | false | “ ./package.json” |
| 姓名 | 描述 |
|---|---|
| 解析標籤 | V1.0.0(輸入)= 1.0.0(輸出) |