-
Notifications
You must be signed in to change notification settings - Fork 93
80 lines (62 loc) · 2.63 KB
/
cut-release.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
77
78
79
80
name: Cut Release
on:
workflow_dispatch:
inputs:
release-type:
description: Release type (major/minor/patch)
required: true
permissions:
pull-requests: write
contents: write
jobs:
cut-release:
name: Creates release branch and PRs into dev/master
runs-on: ubuntu-latest
steps:
- name: Exit if release type argument is invalid
run: exit 1
if: ${{ github.event.inputs.release-type != 'major' && github.event.inputs.release-type != 'minor' && github.event.inputs.release-type != 'patch' }}
- name: Checkout dev for ${{ github.event.inputs.release-type }} release
uses: actions/checkout@v2
if: ${{ github.event.inputs.release-type == 'major' || github.event.inputs.release-type == 'minor' }}
with:
ref: dev
- name: Checkout master for ${{ github.event.inputs.release-type }} release
uses: actions/checkout@v2
if: ${{ github.event.inputs.release-type == 'patch' }}
with:
ref: master
- uses: actions/checkout@v2
- name: Create release branch and generate PR body
id: create-release
env:
RELEASE_TYPE: ${{ github.event.inputs.release-type }}
run: |
git pull --force
currentVersion=$( jq -r '.version' < package.json )
echo "Current version is $currentVersion"
npm version $RELEASE_TYPE --git-tag-version false
newVersion=$(jq -r .version package.json)
git reset --hard
branchName="release/${newVersion}"
echo "New version is $newVersion"
echo "New branch name is $branchName"
git config user.name github-actions
git config user.email [email protected]
git checkout -b "$branchName"
npm version $RELEASE_TYPE --git-tag-version false
git commit -a -m "Bump version to ${newVersion}"
git push --set-upstream origin "$branchName"
# Use --depth to get commits to add to rev-list
git fetch origin master --depth 100
git fetch origin dev --depth 100
masterPrBody=$(git rev-list --oneline $branchName ^origin/master)
devPrBody=$(git rev-list --oneline $branchName ^origin/dev)
echo 'masterPrBody<<END_OF_OUTPUT' >> $GITHUB_ENV
echo "$masterPrBody" >> $GITHUB_ENV
echo 'END_OF_OUTPUT' >> $GITHUB_ENV
echo 'devPrBody<<END_OF_OUTPUT' >> $GITHUB_ENV
echo "$devPrBody" >> $GITHUB_ENV
echo 'END_OF_OUTPUT' >> $GITHUB_ENV
echo "NEW_VERSION=${newVersion}" >> $GITHUB_ENV
echo "::set-output name=branchName::$branchName"