如何通过GitHub Actions在推送develop分支时自动捕获并存储最新标签
问题:向私有仓库的develop分支推送变更时,自动捕获最新标签并存储到变量
我需要实现:向私有仓库的develop分支推送变更时,自动捕获最新标签并将其存储到变量中。
我曾尝试以下配置但未成功:
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"
感谢!
内容的提问来源于stack exchange,提问作者Victor Antunes B.
相关产品推荐
相关产品推荐

