Semantic-Release 创建的标签的 SHA

SHA of Tag Created by Semantic-Release

我们正在更新我们的发布工作流程以使用语义发布,我需要能够获取最新标签的 SHA,用它创建一个新分支,构建我们的资产,将它们提交到那个新分支.

我用来创建分支的操作​​需要父分支的 SHA,如果您基于运行工作流的分支以外的其他内容构建分支。

所以我有几个动作来确定版本是主要的、次要的还是补丁,然后会找到最新的 semver 标签名称。但是我不知道如何得到这个Ref.

的SHA

到目前为止我有这个:

jobs:
  release:
    name: Release
    runs-on: ubuntu-latest
    steps:
      - name: Checkout
        uses: actions/checkout@v2
        with:
          fetch-depth: 0
      - name: Setup Node.js
        uses: actions/setup-node@v2
        with:
          node-version: 'lts/*'
      - name: Install dependencies
        run: npm ci
      - name: Release
        env:
          GITHUB_TOKEN: ${{ $secrets.GH_TOKEN }}
        run: npx semantic-release

      # Search for latest tag
      - name: Find latest tag label
        uses: actions-ecosystem/action-release-label@v1
        id: release-label

      - name: Find latest tag 
        uses: actions-ecosystem/action-get-latest-tag@v1
        id: get-latest-tag
        if: ${{ steps.release-label.outputs.level != null }}

      # lastest tag is now stored in 
      # ${{ steps.get-latest-tag.outputs.tag }}
      # but this only returns a string, I need the SHA for: 
        
      - name: Create release branch
        uses: peterjgrainger/action-create-branch@v2.1.0
        env:
          GITHUB_TOKEN: ${{ secrets.GH_TOKEN }}
        with:
          branch: release 
          sha: ${{ github.sha }} # Need the TAG SHA here as base for release branch

我找不到任何文档告诉我如何获取特定参考的信息,在这种情况下是我的标签。

回答你的问题:

git log -1 --format="%H" REF-NAME

REF-NAME 这里可以是标签、分支或提交 ID,命令将 return 提交 ID。

请注意,您应该能够通过提供没有提交 ID 的标签名称来创建分支。