-
Notifications
You must be signed in to change notification settings - Fork 2
72 lines (65 loc) · 2.73 KB
/
version.yaml
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
on:
pull_request:
types:
- closed
branches:
- main
name: Update versions and create release PR
jobs:
is_merged:
name: Check that PR was merged and not closed
if: >
github.event.pull_request.merged == true
&& ( contains(github.event.pull_request.labels.*.name, 'major')
|| contains(github.event.pull_request.labels.*.name, 'minor')
|| contains(github.event.pull_request.labels.*.name, 'patch')
)
runs-on: ubuntu-latest
steps:
- run: |
echo "This is a canonical hack to run GitHub Actions on merged PRs"
echo "See: https://docs.github.com/en/actions/using-workflows/events-that-trigger-workflows#running-your-pull_request-workflow-when-a-pull-request-merges"
release:
name: Bump version and create PR
needs: is_merged
runs-on: ubuntu-latest
steps:
- name: Checkout
uses: actions/checkout@v3
- name: Bump version
id: bump_version
env:
is_major: ${{ contains(github.event.pull_request.labels.*.name, 'major') }}
is_minor: ${{ contains(github.event.pull_request.labels.*.name, 'minor') }}
is_patch: ${{ contains(github.event.pull_request.labels.*.name, 'patch') }}
run: |
sudo apt-get install jq
echo "old_version=$(jq '.version' package.json | tr -d '"')" >> "$GITHUB_OUTPUT"
if [[ "$is_major" == "true" ]]; then
npm version major --no-git-tag-version
elif [[ "$is_minor" == "true" ]]; then
npm version minor --no-git-tag-version
elif [[ "$is_patch" == "true" ]]; then
npm version patch --no-git-tag-version
fi
echo "new_version=$(jq '.version' package.json | tr -d '"')" >> "$GITHUB_OUTPUT"
- name: Create release PR
id: release_pr
uses: peter-evans/create-pull-request@v5
with:
token: ${{ secrets.GITHUB_TOKEN }}
branch: release/${{ steps.bump_version.outputs.new_version }}
delete-branch: true
base: main
title: Release version ${{ steps.bump_version.outputs.new_version }}
body: |
Update version to ${{ steps.bump_version.outputs.new_version }}.
Merge this PR to build and publish a new release.
labels: release
- name: Comment on PR with link to release PR
uses: peter-evans/create-or-update-comment@v2
with:
issue-number: ${{ github.event.pull_request.number }}
body: |
A [PR][pr] to release these changes has been created, bumping the version from ${{ steps.bump_version.outputs.old_version }} to ${{ steps.bump_version.outputs.new_version }}.
[pr]: ${{ steps.release_pr.outputs.pull-request-url }}