-
Notifications
You must be signed in to change notification settings - Fork 2
64 lines (57 loc) · 2 KB
/
Copy pathversion-bump.yml
File metadata and controls
64 lines (57 loc) · 2 KB
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
name: Version Bump
on:
pull_request:
types: [closed]
branches:
- main
jobs:
bump:
if: github.event.pull_request.merged == true
runs-on: ubuntu-latest
permissions:
contents: write
steps:
- name: Determine bump type from PR labels
id: bump-type
env:
PR_LABELS: ${{ toJson(github.event.pull_request.labels.*.name) }}
run: |
if echo "$PR_LABELS" | grep -q "release:major"; then
echo "type=major" >> $GITHUB_OUTPUT
elif echo "$PR_LABELS" | grep -q "release:minor"; then
echo "type=minor" >> $GITHUB_OUTPUT
elif echo "$PR_LABELS" | grep -q "release:patch"; then
echo "type=patch" >> $GITHUB_OUTPUT
else
echo "type=none" >> $GITHUB_OUTPUT
fi
- name: Checkout main
if: steps.bump-type.outputs.type != 'none'
uses: actions/checkout@v4
with:
ref: main
token: ${{ secrets.RELEASE_TOKEN }}
fetch-depth: 0
- name: Setup Node.js
if: steps.bump-type.outputs.type != 'none'
uses: actions/setup-node@v4
with:
node-version: '20'
- name: Bump version and commit
if: steps.bump-type.outputs.type != 'none'
run: |
git config user.name "github-actions[bot]"
git config user.email "github-actions[bot]@users.noreply.github.com"
npm version ${{ steps.bump-type.outputs.type }} --no-git-tag-version
NEW_VERSION=$(jq -r .version package.json)
git add package.json package-lock.json
git commit -m "chore: bump version to v${NEW_VERSION}"
git push origin main
- name: Sync version bump to dev
if: steps.bump-type.outputs.type != 'none'
run: |
NEW_VERSION=$(jq -r .version package.json)
git fetch origin dev
git checkout dev
git merge origin/main --no-ff -m "chore: sync version bump v${NEW_VERSION} from main"
git push origin dev