github 操作 : how to check if current push has new tag (is new release)?

标签 git github github-actions

name: test-publish

on: [push]

jobs:
  test:
    strategy:
      ...
    steps:
      ...

  publish:
    needs: test
    if: github.event_name == 'push' && github.ref???
    steps:
      ...  # eg: publish package to PyPI

我应该放什么jobs.publish.if为了检查这个提交是新版本?

可以吗:contains(github.ref, '/tags/') ?

如果我同时推送代码和标签会发生什么?

最佳答案

您可以这样做来检查当前推送事件是否针对以 v 开头的标签。 .

  publish:
    needs: test
    if: startsWith(github.ref, 'refs/tags/v')
不过,正如您所指出的,我认为您不能保证这是一个新版本。我的建议是使用 on: release而不是 on: push .这只会在新标记的版本上触发。
请参阅 on: release 的文档这里:
https://docs.github.com/en/actions/reference/events-that-trigger-workflows#release

关于github 操作 : how to check if current push has new tag (is new release)?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/58475748/

相关文章:

git - 为什么 git 仍在跟踪扩展名已添加到 .gitignore 文件的文件

node.js - npm install 模块的权限被拒绝

git - Git 提交中的表情符号代码与 Unicode 代码点

GIT:仅将一些更改提交到当前分支,并将其余更改提交到新分支

github-actions - 如何在 github 操作中创建随机 uuid

javascript - 是否可以为存储库中的多个项目使用一个 node_module 文件夹?

git - 无法强制添加 Git

git - 切换 Git 以使用 SSH

GitHub Action 定期更新工具链版本?

git - 有没有办法使用逻辑 AND 在 GitHub 操作中组合推送标准?