File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff line change 44 push :
55 branches : [main]
66
7+ permissions :
8+ contents : write
9+
710jobs :
811 update-version :
12+ if : github.actor != 'github-actions[bot]'
913 runs-on : ubuntu-latest
1014
1115 steps :
1216 - name : Checkout code
13- uses : actions/checkout@v2
14-
15- - name : Bump
16- uses : tool3/bump@master
17+ uses : actions/checkout@v4
1718 with :
18- branch : main
19- github_token : ${{ secrets.GITHUB_TOKEN }}
20- user : ' github-actions[bot]'
21- email : ' github-actions[bot]@users.noreply.github.com'
19+ fetch-depth : 0
20+
21+ - name : Bump package version and tag
22+ shell : bash
23+ run : |
24+ set -euo pipefail
25+
26+ git config user.name "github-actions[bot]"
27+ git config user.email "github-actions[bot]@users.noreply.github.com"
28+ git fetch --tags
29+
30+ current_version="$(node -p "require('./package.json').version")"
31+ latest_tag="$(git tag -l 'v[0-9]*.[0-9]*.[0-9]*' --sort=-v:refname | head -n1 || true)"
32+ latest_tag_version="${latest_tag#v}"
33+
34+ if [[ -z "${latest_tag_version}" || "${latest_tag_version}" == "${latest_tag}" ]]; then
35+ base_version="${current_version}"
36+ else
37+ highest_version="$(printf '%s\n%s\n' "${current_version}" "${latest_tag_version}" | sort -V | tail -n1)"
38+ base_version="${highest_version}"
39+ fi
40+
41+ IFS='.' read -r major minor patch <<< "${base_version}"
42+ next_version="${major}.${minor}.$((patch + 1))"
43+ next_tag="v${next_version}"
44+
45+ npm version "${next_version}" --no-git-tag-version
46+ git add package.json
47+ git commit -m "Bump version to ${next_tag}"
48+ git tag "${next_tag}"
49+ git push origin main --follow-tags
You can’t perform that action at this time.
0 commit comments