Added workflow to create release branches

- right now, we use an internal CI solution to create branches for patch
  releases, but it's difficult to use
- this workflow should allow the team to create release branches from
  the GitHub UI, without delving into our internal tooling
This commit is contained in:
Daniel Lockyer 2022-09-01 20:43:07 +01:00
parent c220c1e288
commit 4ba26364a7
No known key found for this signature in database
GPG Key ID: D21186F0B47295AD

View File

@ -0,0 +1,48 @@
name: Create release branch
on:
workflow_dispatch:
inputs:
base-ref:
description: 'Git ref to base from'
type: string
required: false
bump-type:
description: ''
type: string
required: false
default: 'patch'
env:
FORCE_COLOR: 1
permissions:
contents: write
jobs:
create-branch:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v3
with:
ref: ${{ inputs.base-ref }}
fetch-depth: 0
submodules: true
- run: npm install semver
- run: |
echo "current_sha=$(git rev-parse HEAD)" >> $GITHUB_ENV
echo "current_version=$(git describe --tags --abbrev=0)" >> $GITHUB_ENV
- uses: actions/github-script@v6
env:
CURRENT_SHA: '${{ env.current_sha }}'
CURRENT_VERSION: '${{ env.current_version }}'
BUMP_TYPE: '${{ inputs.bump-type }}'
with:
script: |
const semver = require('semver');
const branchName = `v${semver.inc(process.env.CURRENT_VERSION, process.env.BUMP_TYPE)}`;
console.log(`Creating branch: ${branchName}`);
await octokit.request('POST /repos/{owner}/{repo}/git/refs', {
owner: context.repo.owner,
repo: context.repo.repo,
ref: `refs/heads/${branchName}`,
sha: process.env.CURRENT_SHA
});