javascript - 在自定义的 release.yml 文件中获取针对版本号的 git 更改

标签 javascript github release github-actions autorelease

我的目标是创建一个 GitHub 操作,当 release.yml 文件更改时,它要么更新现有版本,要么在检查该版本是否是新版本后创建一个新版本,检查之前的提交。最终想将此添加到我想添加操作和 release.yml 的其他项目中。
我目前遇到的问题是很难解决如何检测 release.yml 文件中针对版本的更改。
对于添加新版本的非常基本的用例,创建 action.yml 并添加一个简单的方法

version_1_0: # id of input
description: '1.0'
required: true
default: 'The most important changes are downgrading the artifact to java7 (from 8) and switching to gmavenplus plugin to compile groovy.
      Besides that, there is a lot of restructuring inside of the pom.xml file

      # Misc

      * Polishing (f2ec0bb, 9e2ae89 and 8654493)

      _Reviewed by_: @user' 
稍后在 index.js 文件中
const version = core.getInput('version_1_0');
core.setOutput("ver", version);
给出稍后在 GitHub 操作文件中可以获取和清理的输出,然后转发到发布步骤以用于创建发布
  push:
    paths:
      - release.yml
    branches:
      - file_change_trigger
jobs:
  hello_world_job:
    runs-on: ubuntu-latest
    name: release notes
    outputs:
      output1: ${{ steps.step1.outputs.test }}
    steps:
      - uses: actions/checkout@v2
        with:
          fetch-depth: 0
      - run: 
            description=${{ steps.hello.outputs.ver }}
            echo $description
            description="${description//'%'/'%25'}" 
            description="${description//$'\n'/'%0A'}"
            description="${description//$'\r'/'%0D'}" 
            echo $description
            echo "::set-output name=test::$description"
  
  release_note:
        name: Create Release
        runs-on: ubuntu-latest
        needs: hello_world_job
        steps:
          - name: Checkout code
            uses: actions/checkout@v2
             # Use the output from the `hello` step
          - name: Get the output time
            run: echo "${{needs.hello_world_job.outputs.output1}}"
          - name: Create Release
            id: create_release
            uses: actions/create-release@v1
            env:
              GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} # This token is provided by Actions, you do not need to create your own token
            with:
              tag_name: ${{ github.ref }}
              release_name: Release ${{ github.ref }}
              body: |
                ${{needs.hello_world_job.outputs.output1}}
              draft: false
              prerelease: false  
不幸的是,当我尝试基于差异的基于文件的触发器时,这种方法被证明是不够的。
样本发布.yml
    v1.0:
     body:
          'The most important changes are downgrading the artifact to java7 (from 8) and switching to gmavenplus plugin to compile groovy.
          Besides that, there is a lot of restructuring inside of the pom.xml file

          # Misc

          * Polishing (f2ec0bb, 9e2ae89 and 8654493)

          _Reviewed by_: @user'
    v2.0:
     body:
          'The most important changes are downgrading the artifact to java7 (from 8) and switching to gmavenplus plugin to compile groovy.
          

          # Misc

          * Polishing (f2ec0bb, 9e2ae89 and 8654493)

          _Reviewed by_: @user'           

最佳答案

与其在 release.yml 文件中跟踪更改,不如使用 Github 发布来跟踪和触发 Github 操作。
https://docs.github.com/en/actions/reference/events-that-trigger-workflows#release

on:
  release:
    types: [published]
在这里,您可以选择正确维护版本和更改日志,如果需要,也可以在操作中访问。

关于javascript - 在自定义的 release.yml 文件中获取针对版本号的 git 更改,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/67431624/

相关文章:

javascript - FileReader.onload 如何工作?

Git 钩子(Hook)预提交错误 : "command not found"

git - 您如何将特定分支镜像到另一个存储库中的分支?

android - 无法获取 facebook sdk 哈希 key 。

javascript - JSON 与存储设置的对象

javascript - nodemon 内部监视失败 : watch/Users/admin/Library/Application Support/Code/1. 26.1-shared.sock 未知系统错误 -102

javascript - jquery.menu 针对 href 'Syntax error, unrecognized expression' 触发 ="#..."

github - 如何使用 Jenkins 配置 SonarQube GitHub 插件

xcode - AVAudioPlayer 在播放前释放?

ios - CloudKit:部署到AppStore后访问开发环境吗?