每当我将更改推送到“开发”分支上的私有存储库并将其存储在变量中时,我需要自动捕获最新标签。我怎样才能实现这个目标?
我尝试使用这些命令来检索标签,但使用这种方法没有成功。
name: get-tag-version
on:
push:
branches:
- develop
jobs:
get-tag:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v3
with:
fetch-depth: "0"
- name: catch tag
run: tags=$(git describe --tags --all)
- name: show tag
run: echo "$tag"
cli 返回此:
`Run echo "$tag"
echo "$tag"
shell: /usr/bin/bash -e {0}`
[已解决]
我设法使用这些命令获取标签。
describe-tags:
runs-on: ubuntu-latest
steps:
- name: Checkout Repository
uses: actions/checkout@v2
- name: Describe Tags
run: |
git fetch --prune --unshallow
latest_tag=$(git describe --tags --abbrev=0 HEAD~)
echo "Latest Tag: $latest_tag"
谢谢!
我相信后续运行步骤之间不会共享变量,您必须为此进行步骤输出。
您可以一步运行多个命令:
run: |
tags=$(git describe --tags --all)
echo "$tag"
对于这样的事情,我强烈建议让您想要的行为在本地工作,以便更快地测试和更轻松地调试。