我們正在更新我們的發布作業流以使用語意發布,我需要能夠獲取最新標簽的 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/[email protected]
env:
GITHUB_TOKEN: ${{ secrets.GH_TOKEN }}
with:
branch: release
sha: ${{ github.sha }} # Need the TAG SHA here as base for release branch
我找不到任何檔案來告訴我如何獲取特定參考的資訊,在這種情況下是我的標簽。
uj5u.com熱心網友回復:
要回答您的問題:
git log -1 --format="%H" REF-NAME
REF-NAME 這里可以是標簽、分支或提交 ID,其中任何一個命令都將回傳提交 ID。
請注意,您應該能夠通過僅提供不帶提交 ID 的標記名稱來創建分支。
轉載請註明出處,本文鏈接:https://www.uj5u.com/qukuanlian/409106.html
標籤:
