-
-
Notifications
You must be signed in to change notification settings - Fork 107
55 lines (50 loc) · 1.74 KB
/
bump-version-web.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
name: Verify and Bump Version
on:
pull_request:
types: [opened, reopened]
branches:
- main # Trigger the action on PRs targeting the main branch
jobs:
verify-and-bump:
runs-on: ubuntu-latest
steps:
- name: Checkout the PR branch
uses: actions/checkout@v3
with:
ref: ${{ github.head_ref }}
- name: Get version from PR branch
id: pr-version
run: |
PR_VERSION=$(jq -r '.version' apps/web/package.json)
echo "::set-output name=pr_version::${PR_VERSION}"
- name: Checkout the main branch
uses: actions/checkout@v3
with:
ref: main
- name: Get version from main branch
id: main-version
run: |
MAIN_VERSION=$(jq -r '.version' apps/web/package.json)
echo "::set-output name=main_version::${MAIN_VERSION}"
- name: Compare versions
id: compare-versions
run: |
if [ "${{ steps.pr-version.outputs.pr_version }}" != "${{ steps.main-version.outputs.main_version }}" ]; then
echo "::set-output name=need_bump::'false'"
echo "The versions are different."
else
echo "::set-output name=need_bump::'true'"
echo "The versions are the same. Bump required."
fi
- name: Bump version and commit
if: contains(steps.compare-versions.outputs.need_bump, 'true')
run: |
git checkout ${{ github.head_ref }}
cd apps/web
npm version patch
git config --local user.name "github-actions[bot]"
git config --local user.email "github-actions[bot]@users.noreply.github.com"
git add package.json
git add ../../yarn.lock
git commit -m "chore: bump version in web project"
git push origin ${{ github.head_ref }}