Fixed several issues with create-release-branch job

- uses the `semver` bash tool so we don't have to deal with NPM
  dependencies
- also cleans up the env variables
This commit is contained in:
Daniel Lockyer 2022-09-01 20:59:24 +01:00
parent 4e85343a94
commit 82c3e6b6a4
No known key found for this signature in database
GPG Key ID: D21186F0B47295AD

View File

@ -25,22 +25,22 @@ jobs:
fetch-depth: 0 fetch-depth: 0
submodules: true submodules: true
- run: npm install -g semver - uses: asdf-vm/actions/install@v1
- run: | with:
echo "current_sha=$(git rev-parse HEAD)" >> $GITHUB_ENV tool_versions: |
echo "current_version=$(git describe --tags --abbrev=0)" >> $GITHUB_ENV semver 3.3.0
- uses: actions/github-script@v6 - run: |
env: echo "CURRENT_SHA=$(git rev-parse HEAD)" >> $GITHUB_ENV
CURRENT_SHA: '${{ env.current_sha }}' echo "NEW_VERSION=$(semver bump ${{ inputs.bump-type }} $(git describe --tags --abbrev=0))" >> $GITHUB_ENV
CURRENT_VERSION: '${{ env.current_version }}'
BUMP_TYPE: '${{ inputs.bump-type }}' - name: Create branch
uses: actions/github-script@v6
with: with:
script: | script: |
const semver = require('semver'); const branchName = `v${process.env.NEW_VERSION}`;
const branchName = `v${semver.inc(process.env.CURRENT_VERSION, process.env.BUMP_TYPE)}`;
console.log(`Creating branch: ${branchName}`); console.log(`Creating branch: ${branchName}`);
await octokit.request('POST /repos/{owner}/{repo}/git/refs', { await github.request('POST /repos/{owner}/{repo}/git/refs', {
owner: context.repo.owner, owner: context.repo.owner,
repo: context.repo.repo, repo: context.repo.repo,
ref: `refs/heads/${branchName}`, ref: `refs/heads/${branchName}`,