-
Notifications
You must be signed in to change notification settings - Fork 76
68 lines (59 loc) · 2.35 KB
/
initiate_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
name: Create release PR
on:
workflow_dispatch:
inputs:
version:
description: "The new version number with 'v' prefix. Example: v1.40.1"
required: true
jobs:
init_release:
name: 🚀 Create release PR
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v3
with:
fetch-depth: 0 # gives the changelog generator access to all previous commits
- name: Get current tag
id: previoustag
uses: WyriHaximus/github-action-get-previous-tag@v1
- name: Ensure version number higher than current
uses: actions/github-script@v6
env:
PREVIOUS_TAG: ${{ steps.previoustag.outputs.tag }}
DESTINATION_TAG: ${{ github.event.inputs.version }}
with:
script: |
const { PREVIOUS_TAG, DESTINATION_TAG } = process.env;
const result = DESTINATION_TAG.localeCompare(PREVIOUS_TAG, undefined, { numeric: true, sensitivity: 'base' })
if (result != 1) {
throw new Error('The new version number must be greater than the previous one.')
}
- name: Restore dependencies
uses: ./.github/actions/setup-node
- name: Update CHANGELOG.md, package.json and push release branch
env:
VERSION: ${{ github.event.inputs.version }}
run: |
npm run changelog
git config --global user.name 'github-actions'
git config --global user.email 'release@getstream.io'
git checkout -q -b "release-$VERSION"
git commit -am "chore(release): $VERSION"
git push -q -u origin "release-$VERSION"
- name: Get changelog diff
uses: actions/github-script@v6
with:
script: |
const get_change_log_diff = require('./scripts/get_changelog_diff.js')
core.exportVariable('CHANGELOG', get_change_log_diff())
- name: Open pull request
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
run: |
gh pr create \
-t "chore: release ${{ github.event.inputs.version }}" \
-b "# :rocket: ${{ github.event.inputs.version }}
Make sure to use squash & merge when merging!
Once this is merged, another job will kick off automatically and publish the package.
# :memo: Changelog
${{ env.CHANGELOG }}"