为非标记构建排除 Travis.CI 构建矩阵中的作业

Excluding jobs in Travis.CI build matrix for non-tag builds

我有一个看起来很正常的 Travis.CI 构建矩阵,我正在使用部署到 Github 版本。我的矩阵中有一个额外的元素用于构建和打包源包,我只想在推送标签时构建它。

当构建不是标记构建时,是否有任何方法可以跳过构建矩阵中的构建?

我试过类似的方法,但没有用。它仍然每次都构建源代码,这是多余的。

matrix:
 include:
  - os: linux
    env: DEPLOY=binary
  - os: osx
    env: DEPLOY=binary
  - os: linux
    env: DEPLOY=source
    on:
      tags: true       # <- try and skip this job for non-tag builds (doesn't work!)

[...]

deploy:
  provider: releases
  on:
    tags: true

遗憾的是,由于构建矩阵的创建方式,目前无法实现。我能想到的唯一解决方案是在您想要跳过的作业中检查 TRAVIS_TAG 环境变量,而不是在那里进行 运行 测试。我知道这有一些缺点,因为我们仍然会创建和 运行 构建,但至少它会很快。

我知道这是很久以前的事了,但为了将来参考,它对我有用的是:if: tag IS present。所以你的矩阵是:

matrix:
 include:
  - os: linux
    env: DEPLOY=binary
  - os: osx
    env: DEPLOY=binary
  - os: linux
    env: DEPLOY=source
    if: tag IS present