1

我正在使用 Azure Pipelines 在我的公共 GitHub 存储库中构建 Python 轮子。我成功地将这些作为构建工件添加到我的 .yml 中:

- task: PublishBuildArtifacts@1
  inputs:
    pathtoPublish: '$(Build.ArtifactStagingDirectory)'
    artifactName: drop

我现在想用这些轮子生成一个 GitHub 版本。


尝试#1:创建

我试图通过将GitHub Release 任务添加到我的 .yml来创建一个新版本

- task: GithubRelease@0
  inputs:
    gitHubConnection: 'my-connection'
    repositoryName: 'my-repo'
    action: 'create'
    target: '$(build.sourceVersion)'
    tagSource: 'auto'
    assets: '$(Build.ArtifactStagingDirectory)/*'
    assetUploadMode: 'replace'

当它在新提交上运行时,这给了我一个错误:

2019-01-30T10:54:13.4154988Z ##[section]Starting: GitHubRelease
2019-01-30T10:54:13.4159417Z ==============================================================================
2019-01-30T10:54:13.4159489Z Task         : GitHub Release
2019-01-30T10:54:13.4159535Z Description  : Create, edit, or delete a GitHub release.
2019-01-30T10:54:13.4159592Z Version      : 0.0.2
2019-01-30T10:54:13.4159631Z Author       : Microsoft Corporation
2019-01-30T10:54:13.4159688Z Help         : [More Information](https://aka.ms/AA3aeiw)
2019-01-30T10:54:13.4159733Z ==============================================================================
2019-01-30T10:54:13.8077592Z 4482b84d-9af2-47ea-ba55-e92f0e856217 exists true
2019-01-30T10:54:13.8078191Z Fetching the tag for target: cd14aa02e85823d52f61d1e5e2fccc307e1504f8
2019-01-30T10:54:14.1969398Z ##[error]An unexpected error occurred while fetching tags.
2019-01-30T10:54:14.1978761Z ##[error]Error: Not Found
2019-01-30T10:54:14.1982593Z ##[section]Finishing: GitHubRelease

我这样做是一个非主分支,但我认为这不是上述错误的原因吗?

尝试#2:编辑

因为我真的不希望在每次提交或 GitHub PR 上都发布,所以我想在每次推送标签时触发它。

所以,我想,好吧,让我们看看是否可能将动作更改为“编辑”效果更好......所以我将 .yml 更改为:

- task: GithubRelease@0
inputs:
    gitHubConnection: 'my-connection'
    repositoryName: 'my-repo'
    action: 'edit'
    target: '$(build.sourceVersion)'
    tagSource: 'auto'
    tag: '1.0'
    assets: '$(Build.ArtifactStagingDirectory)/*'
    assetUploadMode: 'replace'

然后运行以下命令(签出我的 'github-release' 分支):

git commit -am "Try 1.0"
git tag -am "Adding tag 1.0" 1.0
git push origin 1.0 HEAD:refs/heads/github-release

但是现在当我检查 CI 时,我在 GitHub 发布任务上看到了这个:

2019-01-30T11:28:52.8639389Z ##[section]Starting: GitHubRelease
2019-01-30T11:28:52.8643449Z ==============================================================================
2019-01-30T11:28:52.8643522Z Task         : GitHub Release
2019-01-30T11:28:52.8643585Z Description  : Create, edit, or delete a GitHub release.
2019-01-30T11:28:52.8643632Z Version      : 0.0.2
2019-01-30T11:28:52.8643688Z Author       : Microsoft Corporation
2019-01-30T11:28:52.8643752Z Help         : [More Information](https://aka.ms/AA3aeiw)
2019-01-30T11:28:52.8643802Z ==============================================================================
2019-01-30T11:28:53.2645821Z 4482b84d-9af2-47ea-ba55-e92f0e856217 exists true
2019-01-30T11:28:53.2646587Z Computing changes made in this release...
2019-01-30T11:28:53.2646657Z Fetching the latest published release...
2019-01-30T11:28:53.7121952Z No releases are published yet in the repository.
2019-01-30T11:28:53.7122209Z Fetching the initial commit...
2019-01-30T11:28:53.8614586Z ##[error]An unexpected error occurred while fetching the initial commit.
2019-01-30T11:28:53.8616507Z ##[error]Error: Not Found
2019-01-30T11:28:53.8654236Z ##[section]Finishing: GitHubRelease

我究竟做错了什么?

4

1 回答 1

1

文档tagSource可以设置为or 'auto''manual'但我遇到一个网站说'Git tag'是一个值,所以我尝试了。事实证明效果更好:

- task: GithubRelease@0
  inputs:
    gitHubConnection: 'my-connection'
    repositoryName: 'username/my-repo'
    action: 'edit'
    target: '$(build.sourceVersion)'
    tagSource: 'Git tag'
    tag: '1.0'
    assetUploadMode: 'replace'

我之前也只输入了我的仓库名称,而不是用户名/仓库。

于 2019-02-02T00:58:02.657 回答