We're updating our release workflow to use semantic-release, and I need to be able to grab the SHA of the latest tag, create a new branch with it, build our assets, commit them to that new branch.
The action I'm using to create the branch, requires the SHA of the parent branch if you're building a branch based on something other than the branch the runs the workflow.
So I have a couple actions to determine if the release is major, minor, or patch, and then will find the latest semver tag name. But I don't know how to get the SHA of this Ref.
So far I have this:
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
I can't find any docs to tell me how to get info for a specific ref, my tag in this case.