远方的灯塔 - 专注于服务端技术分享 远方的灯塔 - 专注于服务端技术分享
首页
  • Java SE
  • Struts2
  • Hibernate
  • MyBatis
  • JAX-WS
  • 并发
  • 分布式
  • Git
  • 文章分类
  • 文章标签
  • 文章归档
  • 《C程序设计语言》
心情随笔
友情链接
给我留言 (opens new window)
关于我
GitHub (opens new window)

Terwer Green

一个后端老菜鸟
首页
  • Java SE
  • Struts2
  • Hibernate
  • MyBatis
  • JAX-WS
  • 并发
  • 分布式
  • Git
  • 文章分类
  • 文章标签
  • 文章归档
  • 《C程序设计语言》
心情随笔
友情链接
给我留言 (opens new window)
关于我
GitHub (opens new window)
  • 源代码管理

  • 开发效率

    • 使用vagrant搭建可移植的跨平台的开发环境
    • Vagrant搭建可移植的CentOS7环境
    • 在WSL2的Linux中安装和运行IntelliJ IDEA
    • 在WSL2上安装xfce桌面以及中文开发环境的配置
    • WSL2安装MySQL8.0和redis
    • 将WSL的2204版本的ununtu滚动升级版本升级到到2204
    • git-2_34_1访问服务器报Permission-denied(publickey)
    • 阿里云安装桌面环境及VNC连接
    • Ubuntu2204安装MySQL5_7
    • 终于解决了困扰多天的普通用户不能启动WSL2的ubuntu的xfce4桌面问题
    • WSL2在WSLG下面GUI应用程序的DPI分辨率模糊的问题
    • docker的centos7中IDEA中文
    • 在WSL2的Oracle Linux8_5发行版中安装xfce4
    • 探索一下WSL上Ubuntu的包管理工具
    • 在ubuntu中,升级emacs到最新版本(非源码安装)
    • 使用vnc远程ubuntu.md
    • Parallels Desktop安装Fedora34并切换Xfce Desktop桌面环境
    • Rocky Linux 8.6安装中文输入法
    • Parallels Desktop从零开始安装CentOS7
    • openEuler2203移除旧的lernel
    • Github-Actions使用release-please实现自动发版
      • 上手
      • 注意事项
  • 知识管理

  • 开发流程
  • 开发效率
terwer
2023-03-06
目录

Github-Actions使用release-please实现自动发版

​release please​​ 是一个来自于 Google​​ 的自动发版工具,基于 Github Actions​ 可实现全自动发版。

官网:https://github.com/googleapis/release-please (opens new window)

# 上手

在项目根目录的 .github​ 的 workflows​ 里面新建一个 release-please.yml​ 文件,下面是一个标准的 node​ 项目的标准配置:

on:
  push:
    branches:
      - main
name: release-please
jobs:
  release-please:
    runs-on: ubuntu-latest
    steps:
      - uses: google-github-actions/release-please-action@v3
        id: release
        with:
          release-type: node
          package-name: release-please-action
      # Checkout
      - uses: actions/checkout@v3
        if: ${{ steps.release.outputs.release_created }}
      # Setup node
      - uses: actions/setup-node@v3
        with:
          node-version: 16
          registry-url: 'https://registry.npmjs.org'
        if: ${{ steps.release.outputs.release_created }}
      # Setup pnpm
      - uses: pnpm/action-setup@v2
        if: ${{ steps.release.outputs.release_created }}
      # Install dependencies
      - run: pnpm install
        if: ${{ steps.release.outputs.release_created }}
      # Build output
      - run: pnpm build
        if: ${{ steps.release.outputs.release_created }}
      # Publish to npm
      - run: npm publish
        env:
          NODE_AUTH_TOKEN: ${{secrets.NPM_TOKEN}}
        if: ${{ steps.release.outputs.release_created }}
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37

提交之后,正常情况就会在 main​​ 分支的 push​​ 事件触发之时,启动自动发版,包括发布到 npm​​ 仓库。

注意 1:任务运行完毕后并不是直接就发版了,而是会新建一个 pr,可以检查 pr 内容,需要发版,就合并。如果暂时不发版,可以直接关闭这个 pr。

​​

注意 2:pr 会自动递增版本号,所以不要提前手动更改版本号。node 项目的版本号是 package.json 里面的 version 字段,格式是:x.x.x 。

版本号规则是:

feat:->大版本,例如:1.0.0->1.1.0

fix:->小版本,例如:1.0.0->1.0.1

feat!:, fix!:, refactor!:->主要版本,例如:1.0.0->2.0.0

如果从未发过版本,那么初始是 1.0.0​ 。

​​

‍

另外,如果不需要发布到 npm​ ,可以使用下面的配置:

on:
  push:
    branches:
      - main
name: release-please
jobs:
  release-please:
    runs-on: ubuntu-latest
    steps:
      - uses: google-github-actions/release-please-action@v3
        id: release
        with:
          release-type: node
          package-name: release-please-action
1
2
3
4
5
6
7
8
9
10
11
12
13
14

‍

# 注意事项

  • 配置 npm token (可选,如果不需要发布到 npm 可忽略)

    去 https://www.npmjs.com/settings/terwer/tokens (opens new window) 申请一个 token​ ,然后再项目里面设置:

    Settings -> Secrets and variables -> Actions -> New repository secret​ ,新建一个即可。

  • ​Github​ 仓库权限设置

    注意:默认的 Github 仓库不允许拉取,需要开启权限才行。方法如下:

    转到 https://github.com/OWNER/REPO/settings/actions​ 页面向下划到 Workflow Permissions 然后切换到 Read and Write permissions 。

    ​​

文章更新历史 2023-03-06 feat:初稿

‍

编辑 (opens new window)
#自动#发版#release#release-please#google
上次更新: 2023/03/08, 09:56:32
openEuler2203移除旧的lernel
使用Next.js部署WordPress

← openEuler2203移除旧的lernel 使用Next.js部署WordPress→

最近更新
01
解决css部分border被圆角切掉之后圆角的边框消失问题
03-18
02
使用TypeScript开发一个自定义的Node-js前端开发脚手架
03-08
03
IDEA自定义Maven的archetype
02-22
更多文章>
Theme by Vdoing | Copyright © 2011-2023 Terwer Green | MIT License | 粤ICP备2022020721号-1 | 百度统计
  • 跟随系统
  • 浅色模式
  • 深色模式
  • 阅读模式