我有一个项目,我想为其进行基于标签的发布,为此,我定义了以下 yml 文件:
name: publish open-electrons-templates
on:
push:
# Sequence of patterns matched against refs/tags
tags:
- 'v[0-9]+.[0-9]+.[0-9]+-[a-zA-Z]*'
release:
types: [ created ]
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
jobs:
publish:
runs-on: ubuntu-latest
if: startsWith(github.ref, 'refs/tags/v')
steps:
- name: checkout
uses: actions/checkout@v3
- name: capture changelog
id: changelog
uses: metcalfc/[email protected]
with:
myToken: ${{ secrets.GITHUB_TOKEN }}
- name: sbt ci-publish-github
run: sbt compile publish
- name: ci-release-github
id: create-release
uses: actions/create-release@latest
with:
allowUpdates: true
tag_name: ${{ github.ref }}
release_name: Release ${{ github.ref }}
body: |
## What's Changed
${{ steps.changelog.outputs.changelog }}
draft: false
prerelease: false
然后我进行带注释的标记;
git tag -a v2.2.2 -m "Your comments" // Create annotated tag
git push origin --tags // Push annotated tag
我原以为 GitHub Actions 会被触发,但似乎没有,而且我也不知道如何调试它以找出原因。
编辑:更改正则表达式后,
v[0-9]+.[0-9]+.[0-9](?:[+-[a-zA-Z]*])?
管道似乎已触发,但现在失败了:
push event contained invalid tags patterns: the following globs were invalid: v[0-9]+.[0-9]+.[0-9](?:[+-[a-zA-Z]*])?
但是我的新正则表达式有什么问题吗?它似乎是有效的,并且似乎与以下内容相匹配,这正是我想要的:
v0.0.1
v0.0.1-SNAPSHOT
v0.0.1-BETA
v0.0.1-RC
采取了解决方法来解决此问题:
tags:
- 'v[0-9]+.[0-9]+.[0-9]+-[a-zA-Z]*'
- 'v[0-9]+.[0-9]+.[0-9]'
我也遇到同样的问题。当我创建新标签并推送它时,该操作未激活。
在我的操作 yaml 文件中,我有以下内容:
on:
push:
tags:
- 'v[0-9]+.[0-9]+.[0-9]+-[a-zA-Z]*'
- 'v[0-9]+.[0-9]+.[0-9]'
我使用以下命令创建标签:
git tag -a v1.0.0 -m "Your comments"
git push origin --tags
我还需要在构建步骤中获取标签名称,以将图像推送到 docker hub 中。
您是否有一个示例来说明如何配置操作 yaml 文件才能实现这一目标?