Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

merge dev to main: auto versioning #29

Merged
merged 5 commits into from
Jan 15, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
70 changes: 70 additions & 0 deletions .github/workflows/versioning.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,70 @@
name: Update Version on Dev Push
on:
push:
branches:
- dev

jobs:
update-version:
if: ${{contains(toJSON(github.event.head_commit.message), 'Bump version') == false}}
runs-on: ubuntu-latest

steps:
- name: Get version type
id: version_type
run: |
if [[ ${{ contains(toJSON(github.event.head_commit.message), 'bump_major') }} == true ]]; then
echo "VERSION_TYPE=major" >> $GITHUB_OUTPUT
elif [[ ${{ contains(toJSON(github.event.head_commit.message), 'bump_minor') }} == true ]]; then
echo "VERSION_TYPE=minor" >> $GITHUB_OUTPUT
else
echo "VERSION_TYPE=patch" >> $GITHUB_OUTPUT
fi
shell: bash

- name: Checkout code
uses: actions/checkout@v3
with:
token: ${{ secrets.ACTIONS_BOT_TOKEN }}

- name: Set up Node.js
uses: actions/setup-node@v2
with:
node-version: 14 # Adjust this to your desired Node.js version

- name: Set Git user information
run: |
git config --local user.name "bot-edgepi"
git config --local user.email "120603722+bot-edgepi@users.noreply.github.com"

- name: Set versioned branch name
id: branch-name
run: |
echo "version-$(date +'%Y%m%d%H%M%S')-$(openssl rand -hex 4)" > branch-name.txt
echo "BRANCH_NAME=$(cat branch-name.txt)" >> $GITHUB_ENV

- name: Checkout new branch
run: |
branch_name=$(cat branch-name.txt)
git checkout -b $branch_name
git push --set-upstream origin $branch_name

- name: Bump version
run: |
npm version ${{ steps.version_type.outputs.VERSION_TYPE }} --force

- name: Push to the dev branch
run: |
branch_name=$(cat branch-name.txt)
version=$(cat package.json | jq -r '.version')
git add .
git commit -m "Bump version to $version"
git push --follow-tags
git push --force origin "$branch_name":dev

- name: Delete versioned branch
run: |
branch_name=$(cat branch-name.txt)
git checkout dev
git branch -D $branch_name
git push origin --delete $branch_name
27 changes: 23 additions & 4 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -1,6 +1,25 @@
#venv
venv/
# See https://help.github.com/articles/ignoring-files/ for more about ignoring files.

# node modules
node_modules/
# dependencies
/node_modules
/.pnp
.pnp.js

# testing
/coverage

# production
/build


# misc
.DS_Store
.env.local
.env.development.local
.env.test.local
.env.production.local

/.vscode
npm-debug.log*
yarn-debug.log*
yarn-error.log*
1 change: 1 addition & 0 deletions branch-name.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
version-20240115225852-806da137
2 changes: 1 addition & 1 deletion package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
"edgepi-digital-out": "edgepi-digital-out.js"
}
},
"version": "1.0.9",
"version": "1.0.10",
"description": "node-red node for edgepi digital output module utilizing remote procedure calls",
"main": "index.js",
"scripts": {
Expand Down