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(输出) |