This commit is contained in:
@@ -0,0 +1,66 @@
|
||||
name: Create release branch
|
||||
on:
|
||||
workflow_dispatch:
|
||||
inputs:
|
||||
base-ref:
|
||||
description: 'Git ref to base from (defaults to latest tag)'
|
||||
type: string
|
||||
default: 'latest'
|
||||
required: false
|
||||
bump-type:
|
||||
description: 'Version bump type (patch, minor)'
|
||||
type: string
|
||||
required: false
|
||||
default: 'patch'
|
||||
env:
|
||||
FORCE_COLOR: 1
|
||||
permissions:
|
||||
contents: write
|
||||
jobs:
|
||||
create-branch:
|
||||
if: github.repository == 'TryGhost/Ghost'
|
||||
runs-on: ubuntu-latest
|
||||
steps:
|
||||
- uses: actions/checkout@de0fac2e4500dabe0009e67214ff5f5447ce83dd # v6.0.2
|
||||
if: inputs.base-ref == 'latest'
|
||||
with:
|
||||
ref: main
|
||||
fetch-depth: 0
|
||||
submodules: true
|
||||
|
||||
- uses: actions/checkout@de0fac2e4500dabe0009e67214ff5f5447ce83dd # v6.0.2
|
||||
if: inputs.base-ref != 'latest'
|
||||
with:
|
||||
ref: ${{ inputs.base-ref }}
|
||||
fetch-depth: 0
|
||||
submodules: true
|
||||
|
||||
- name: Checkout most recent tag
|
||||
run: git checkout "$(git describe --tags --abbrev=0 --match=v*)"
|
||||
if: inputs.base-ref == 'latest'
|
||||
|
||||
- uses: asdf-vm/actions/install@b7bcd026f18772e44fe1026d729e1611cc435d47 # v4
|
||||
with:
|
||||
tool_versions: |
|
||||
semver 3.3.0
|
||||
|
||||
- run: |
|
||||
CURRENT_TAG=$(git describe --tags --abbrev=0 --match=v*)
|
||||
NEW_VERSION=$(semver bump "$BUMP_TYPE_INPUT" "$CURRENT_TAG")
|
||||
printf 'CURRENT_SHA=%s\n' "$(git rev-parse HEAD)" >> "$GITHUB_ENV"
|
||||
printf 'NEW_VERSION=%s\n' "$NEW_VERSION" >> "$GITHUB_ENV"
|
||||
env:
|
||||
BUMP_TYPE_INPUT: ${{ inputs.bump-type }}
|
||||
|
||||
- name: Create branch
|
||||
uses: actions/github-script@ed597411d8f924073f98dfc5c65a23a2325f34cd # v8
|
||||
with:
|
||||
script: |
|
||||
const branchName = `v${process.env.NEW_VERSION}`;
|
||||
console.log(`Creating branch: ${branchName}`);
|
||||
await github.request('POST /repos/{owner}/{repo}/git/refs', {
|
||||
owner: context.repo.owner,
|
||||
repo: context.repo.repo,
|
||||
ref: `refs/heads/${branchName}`,
|
||||
sha: process.env.CURRENT_SHA
|
||||
});
|
||||
Reference in New Issue
Block a user