GitHub Actions 持续集成 - 1. 自动生成 Release 内容

本文地址:blog.lucien.ink/archives/490

0. 摘要

之前挖了一个,慢慢补上。

本文章旨在介绍如何借助 GitHub Actions 来生成 Release 的内容,以避免每次进行 Release 的时候都要写各种各样的变更日志。

1. 原理

通过 github.com/release-drafter/release-drafter,将 .github/release-drafter.yml 作为模版文件,借助 pull reqeust 时标注的 tag 来进行 Release 内容的生成。

效果见:github.com/LucienShui/HelloCI/releases

一些其它更高级的用法见 release-drafter 的项目主页

2. 配置

2.1 GitHub Actions 文件

.github/workflows/release-drafter.yml

name: Release Drafter

on:
  push:
    branches:
      - master # 在 master 分支发生更新时执行此 action

jobs:
  draft_release:
    name: Draft release
    runs-on: ubuntu-latest
    steps:
      - uses: toolmantim/[email protected]
        name: Draft
        env:
          GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}

2020 年 2 月 9 日更新

在我写这篇博客的时候此项目名为 toolmantim/release-drafter,现在已更新为 release-drafter/release-drafter,最新版本号见:这里

2.2. Release Drafter 配置文件

.github/release-drafter.yml

name-template: 'release-v$NEXT_PATCH_VERSION'
tag-template: 'release-v$NEXT_PATCH_VERSION'
categories:
  - title: 'Features'
    labels:
      - 'feature'
      - 'enhancement'
  - title: 'Bug Fixes'
    labels:
      - 'fix'
      - 'bugfix'
      - 'bug'
  - title: 'Maintenance'
    labels:
      - 'chore'
      - 'documentation'
change-template: '- $TITLE (#$NUMBER) @$AUTHOR'
template: |
  # Changes

  $CHANGES
最后修改:2020 年 02 月 09 日
谢谢老板!