forked from TryGhost/Ghost
-
Notifications
You must be signed in to change notification settings - Fork 0
59 lines (53 loc) · 1.72 KB
/
create-release-branch.yml
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
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:
runs-on: ubuntu-latest
steps:
- run: echo "BASE_REF=main" >> $GITHUB_ENV
if: inputs.base-ref == 'latest'
- run: echo "BASE_REF=${{ inputs.base-ref }}" >> $GITHUB_ENV
if: inputs.base-ref != 'latest'
- uses: actions/checkout@v3
with:
ref: ${{ env.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@v2
with:
tool_versions: |
semver 3.3.0
- run: |
echo "CURRENT_SHA=$(git rev-parse HEAD)" >> $GITHUB_ENV
echo "NEW_VERSION=$(semver bump ${{ inputs.bump-type }} $(git describe --tags --abbrev=0 --match=v*))" >> $GITHUB_ENV
- name: Create branch
uses: actions/github-script@v6
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
});