GitHub Actions 实现 Release 自动发版

2023-05-13· 25min

#一、配置Tokens、Secrets

#新增 Personal access tokens

  1. Open:
    Settings
    ->
    Developer Settings
    ->
    Personal access tokens
  2. Create:
    Tokens(classic)
    ->
    Generate new token

#配置 Project Actions secrets

  1. Open:
    ${Your Repository}
    ->
    Settings
    ->
    Secrets and variables
  2. Create:
    Secrets
    ->
    New repository secret

#二、配置workflows

  • 具体配置文件
    .github/workflows/release-please.yml
name: Create Release

permissions:
  contents: write
  pull-requests: write

on:
  push:
    tags:
      - v*

jobs:
  release-please:
    runs-on: ubuntu-latest
    steps:
      - name: ->actions/checkout@v4
        uses: actions/checkout@v4
        with:
          fetch-depth: 0

      - name: ->actions/setup-node@v4
        uses: actions/setup-node@v4
        with:
          node-version: lts/*
          cache: npm

      - run: npm install

      - name: ->npx changelogithub
        run: npx changelogithub
        continue-on-error: true
        env:
          GITHUB_TOKEN: ${{secrets.NUXT_QUICK_RELEASE_TOKEN}}

      - name: ->googleapis/release-please-action@v4
        uses: googleapis/release-please-action@v4
        with:
          token: ${{ secrets.NUXT_QUICK_RELEASE_TOKEN }}
          release-type: node
      # - run: npm ci
      #   if: ${{ steps.release.outputs.release_created }}
      # - run: npm publish
      #   env:
      #     NODE_AUTH_TOKEN: ${{secrets.NPM_TOKEN}}
      #   if: ${{ steps.release.outputs.release_created }}

#三、执行流程

  1. Repository
    下提交
    tag
$ git tag v1.0.0
$ git push origin v1.0.0
  1. Github会自动执行相关Action
  • 执行过程:自动生成changelog、发版release
  • 执行结果
快速开始
基本框架
功能模块
UI设计
代码规范
开发环境
部署
待办规划
</> Hello!Good day to you.
Powered by NuxtQuick.