-
Notifications
You must be signed in to change notification settings - Fork 0
76 lines (67 loc) · 2.17 KB
/
cut-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
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
name: Cut Release Branch
on:
workflow_dispatch:
inputs:
version:
description: Bump version on main to the next
required: true
type: choice
options:
- minor
- major
default: minor
jobs:
run:
name: Cut Release
runs-on: ubuntu-latest
permissions:
contents: write
steps:
- uses: actions/checkout@v4
with:
ref: main
token: ${{ secrets.TAMANU_RELEASE_PAT }}
- name: Set up committer info
run: |
git config user.name github-actions
git config user.email [email protected]
- uses: actions/setup-node@v4
with:
node-version: 20.x
- name: Compute new release branch name
uses: actions/github-script@v7
id: branchname
with:
github-token: ${{ secrets.TAMANU_RELEASE_PAT }}
result-encoding: string
script: |
const cwd = '${{ github.workspace }}';
const { currentVersion } = await import(`${cwd}/scripts/gha-release-ops.mjs`);
return currentVersion(await import('fs'), cwd).branch;
- name: Check new release branch doesn't already exist
uses: actions/github-script@v7
env:
NEW_BRANCH_NAME: ${{ steps.branchname.outputs.result }}
with:
github-token: ${{ secrets.TAMANU_RELEASE_PAT }}
script: |
const cwd = '${{ github.workspace }}';
const { checkBranchDoesNotExist } = await import(`${cwd}/scripts/gha-release-ops.mjs`);
await checkBranchDoesNotExist(github, context, process.env.NEW_BRANCH_NAME);
- name: Create new release branch
env:
NEW_BRANCH_NAME: ${{ steps.branchname.outputs.result }}
run: |
set -ex
git switch --create "$NEW_BRANCH_NAME"
git commit --allow-empty -m "release: Cut-off for $NEW_BRANCH_NAME"
git push origin "$NEW_BRANCH_NAME"
git switch main
- name: Bump version on main
run: node scripts/version.mjs '${{ inputs.version }}'
- name: Commit and push
run: |
set -ex
version=$(jq -r .version package.json)
git commit -am "release: Bump version to $version"
git push