Skip to content

Commit 148e8f2

Browse files
authored
Merge pull request #4 from EdgePi-Cloud/dev
merge dev to main: auto versioning
2 parents e312b2e + 1582af5 commit 148e8f2

File tree

5 files changed

+104
-10
lines changed

5 files changed

+104
-10
lines changed

.github/workflows/versioning.yml

Lines changed: 70 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,70 @@
1+
name: Update Version on Dev Push
2+
on:
3+
push:
4+
branches:
5+
- dev
6+
7+
jobs:
8+
update-version:
9+
if: ${{contains(toJSON(github.event.head_commit.message), 'Bump version') == false}}
10+
runs-on: ubuntu-latest
11+
12+
steps:
13+
- name: Get version type
14+
id: version_type
15+
run: |
16+
if [[ ${{ contains(toJSON(github.event.head_commit.message), 'bump_major') }} == true ]]; then
17+
echo "VERSION_TYPE=major" >> $GITHUB_OUTPUT
18+
elif [[ ${{ contains(toJSON(github.event.head_commit.message), 'bump_minor') }} == true ]]; then
19+
echo "VERSION_TYPE=minor" >> $GITHUB_OUTPUT
20+
else
21+
echo "VERSION_TYPE=patch" >> $GITHUB_OUTPUT
22+
fi
23+
shell: bash
24+
25+
- name: Checkout code
26+
uses: actions/checkout@v3
27+
with:
28+
token: ${{ secrets.ACTIONS_BOT_TOKEN }}
29+
30+
- name: Set up Node.js
31+
uses: actions/setup-node@v2
32+
with:
33+
node-version: 14 # Adjust this to your desired Node.js version
34+
35+
- name: Set Git user information
36+
run: |
37+
git config --local user.name "bot-edgepi"
38+
git config --local user.email "[email protected]"
39+
40+
- name: Set versioned branch name
41+
id: branch-name
42+
run: |
43+
echo "version-$(date +'%Y%m%d%H%M%S')-$(openssl rand -hex 4)" > branch-name.txt
44+
echo "BRANCH_NAME=$(cat branch-name.txt)" >> $GITHUB_ENV
45+
46+
- name: Checkout new branch
47+
run: |
48+
branch_name=$(cat branch-name.txt)
49+
git checkout -b $branch_name
50+
git push --set-upstream origin $branch_name
51+
52+
- name: Bump version
53+
run: |
54+
npm version ${{ steps.version_type.outputs.VERSION_TYPE }} --force
55+
56+
- name: Push to the dev branch
57+
run: |
58+
branch_name=$(cat branch-name.txt)
59+
version=$(cat package.json | jq -r '.version')
60+
git add .
61+
git commit -m "Bump version to $version"
62+
git push --follow-tags
63+
git push --force origin "$branch_name":dev
64+
65+
- name: Delete versioned branch
66+
run: |
67+
branch_name=$(cat branch-name.txt)
68+
git checkout dev
69+
git branch -D $branch_name
70+
git push origin --delete $branch_name

.gitignore

Lines changed: 25 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1 +1,25 @@
1-
/node_modules
1+
# See https://help.github.com/articles/ignoring-files/ for more about ignoring files.
2+
3+
# dependencies
4+
/node_modules
5+
/.pnp
6+
.pnp.js
7+
8+
# testing
9+
/coverage
10+
11+
# production
12+
/build
13+
14+
15+
# misc
16+
.DS_Store
17+
.env.local
18+
.env.development.local
19+
.env.test.local
20+
.env.production.local
21+
22+
/.vscode
23+
npm-debug.log*
24+
yarn-debug.log*
25+
yarn-error.log*

branch-name.txt

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
version-20240115231439-b931e2c5

package-lock.json

Lines changed: 7 additions & 8 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@
55
"edgepi-pwm": "edgepi-pwm.js"
66
}
77
},
8-
"version": "1.0.0",
8+
"version": "1.0.1",
99
"description": "Node-RED node for EdgePi PWM Module",
1010
"main": "index.js",
1111
"scripts": {},

0 commit comments

Comments
 (0)