创建新标签后运行github操作

问题描述

 on:
     push:
       tags:
        - '*' # Push events to every tag
我从Trigger Github Action only on new tags?那里得到的

我创建了这个github动作,以为它会在新创建的标签之后运行。

因此,我将其作为.github/workflows/onnewtag.yml文件推送到了分支上。

然后,在同一分支上,我创建了一个标签git tag -a 0.0.1 -m "first attempt"

然后我推送了这个新标签git push <remote> <branch> --tags

但是什么也没发生。 显然我这边一定有一些思维上的错误吗?

我也尝试过添加标签本身:

git checkout tags/0.0.1 -b tags-test 然后编辑git addgit commit,然后 git push <remote> <tag> 为此,我什至得到了“一切都是最新的”

我们真正想要的是一个动作,它将在每次创建新版本时运行。 我们以为创建标签会发出新的信号。 也许标签错误方法

解决方法

release事件在这里很有用。

由于您希望每次发布新版本时都运行该事件,因此可以使用published活动类型来过滤出编辑/删除/等...

on:
  release:
    types: [published]

您可能还希望根据您的特定用例考虑添加prereleased标签。