如何使用 azure-pipelines 将当前的 git 标签暴露给 windows 上的 electron-builder?

How to expose the current git tag to electron-builder on windows using azure-pipelines?

我的 windows-fu 在过去十年里变弱了,我对 azure-pipelines 很陌生。

电子构建器希望在执行发布步骤之前在环境变量 CI_BUILD_TAG(或其他几个环境变量)中看到 git 标记。

在 Mac 和 Linux 上 中描述的方法工作得很好:

steps:
    - script: CI_BUILD_TAG=`git describe --tags` && echo "##vso[task.setvariable variable=CI_BUILD_TAG]$CI_BUILD_TAG"
      displayName: Set the tag name as an environment variable

如何为 Windows 构建执行此操作?

您可以使用 PowerShell 来完成:

steps:
- powershell: |
   $CI_BUILD_TAG = git describe --tags
   Write-Host "##vso[task.setvariable variable=CI_BUILD_TAG]$CI_BUILD_TAG"
  displayName: 'Set the tag name as an environment variable'