2022-09-01 22:43:07 +03:00
|
|
|
name: Create release branch
|
|
|
|
on:
|
|
|
|
workflow_dispatch:
|
|
|
|
inputs:
|
|
|
|
base-ref:
|
2022-09-06 17:39:10 +03:00
|
|
|
description: 'Git ref to base from (defaults to latest tag)'
|
2022-09-01 22:43:07 +03:00
|
|
|
type: string
|
2022-09-06 17:39:10 +03:00
|
|
|
default: 'latest'
|
2022-09-01 22:43:07 +03:00
|
|
|
required: false
|
|
|
|
bump-type:
|
2022-09-06 17:39:10 +03:00
|
|
|
description: 'Version bump type (patch, minor)'
|
2022-09-01 22:43:07 +03:00
|
|
|
type: string
|
|
|
|
required: false
|
|
|
|
default: 'patch'
|
|
|
|
env:
|
|
|
|
FORCE_COLOR: 1
|
|
|
|
permissions:
|
|
|
|
contents: write
|
|
|
|
jobs:
|
|
|
|
create-branch:
|
|
|
|
runs-on: ubuntu-latest
|
|
|
|
steps:
|
2022-09-06 17:46:49 +03:00
|
|
|
- run: echo "BASE_REF=main" >> $GITHUB_ENV
|
2022-09-06 17:39:10 +03:00
|
|
|
if: inputs.base-ref == 'latest'
|
|
|
|
|
|
|
|
- run: echo "BASE_REF=${{ inputs.base-ref }}" >> $GITHUB_ENV
|
|
|
|
if: inputs.base-ref != 'latest'
|
|
|
|
|
2022-09-01 22:43:07 +03:00
|
|
|
- uses: actions/checkout@v3
|
|
|
|
with:
|
2022-09-06 17:39:10 +03:00
|
|
|
ref: ${{ env.BASE_REF }}
|
2022-09-01 22:43:07 +03:00
|
|
|
fetch-depth: 0
|
|
|
|
submodules: true
|
|
|
|
|
2022-09-06 17:46:49 +03:00
|
|
|
- name: Checkout most recent tag
|
|
|
|
run: git checkout $(git describe --tags --abbrev=0)
|
|
|
|
if: inputs.base-ref == 'latest'
|
|
|
|
|
2022-09-01 22:59:24 +03:00
|
|
|
- uses: asdf-vm/actions/install@v1
|
|
|
|
with:
|
|
|
|
tool_versions: |
|
|
|
|
semver 3.3.0
|
|
|
|
|
2022-09-01 22:43:07 +03:00
|
|
|
- run: |
|
2022-09-01 22:59:24 +03:00
|
|
|
echo "CURRENT_SHA=$(git rev-parse HEAD)" >> $GITHUB_ENV
|
2022-11-04 06:52:06 +03:00
|
|
|
echo "NEW_VERSION=$(semver bump ${{ inputs.bump-type }} $(git describe --tags --abbrev=0 --match=v*))" >> $GITHUB_ENV
|
2022-09-01 22:43:07 +03:00
|
|
|
|
2022-09-01 22:59:24 +03:00
|
|
|
- name: Create branch
|
|
|
|
uses: actions/github-script@v6
|
2022-09-01 22:43:07 +03:00
|
|
|
with:
|
|
|
|
script: |
|
2022-09-01 22:59:24 +03:00
|
|
|
const branchName = `v${process.env.NEW_VERSION}`;
|
2022-09-01 22:43:07 +03:00
|
|
|
console.log(`Creating branch: ${branchName}`);
|
2022-09-01 22:59:24 +03:00
|
|
|
await github.request('POST /repos/{owner}/{repo}/git/refs', {
|
2022-09-01 22:43:07 +03:00
|
|
|
owner: context.repo.owner,
|
|
|
|
repo: context.repo.repo,
|
|
|
|
ref: `refs/heads/${branchName}`,
|
|
|
|
sha: process.env.CURRENT_SHA
|
|
|
|
});
|