From aae0827af084acfce10ca0fba2e85a394ebab6f7 Mon Sep 17 00:00:00 2001 From: Jimmy Date: Mon, 15 Jan 2024 14:15:25 -0800 Subject: [PATCH 1/4] add auto versioning --- .github/workflows/versioning.yml | 70 ++++++++++++++++++++++++++++++++ .gitignore | 26 +++++++++++- package-lock.json | 13 +++--- 3 files changed, 101 insertions(+), 8 deletions(-) create mode 100644 .github/workflows/versioning.yml diff --git a/.github/workflows/versioning.yml b/.github/workflows/versioning.yml new file mode 100644 index 00000000..56d40e51 --- /dev/null +++ b/.github/workflows/versioning.yml @@ -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), 'major') }} == true ]]; then + echo "VERSION_TYPE=major" >> $GITHUB_OUTPUT + elif [[ ${{ contains(toJSON(github.event.head_commit.message), '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 diff --git a/.gitignore b/.gitignore index 30bc1627..aed2039c 100644 --- a/.gitignore +++ b/.gitignore @@ -1 +1,25 @@ -/node_modules \ No newline at end of file +# See https://help.github.com/articles/ignoring-files/ for more about ignoring files. + +# 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* diff --git a/package-lock.json b/package-lock.json index e6ce6bbc..92624c95 100644 --- a/package-lock.json +++ b/package-lock.json @@ -348,6 +348,7 @@ "version": "8.8.2", "resolved": "https://registry.npmjs.org/acorn/-/acorn-8.8.2.tgz", "integrity": "sha512-xjIYgE8HBrkpd/sJqOGNspf8uHG+NOHGOw6a/Urj8taM2EXfdNAH2oFcPeIFfsv3+kz/mJrS5VuMqbNLjCa2vw==", + "dev": true, "bin": { "acorn": "bin/acorn" }, @@ -4575,13 +4576,13 @@ "acorn": { "version": "8.8.2", "resolved": "https://registry.npmjs.org/acorn/-/acorn-8.8.2.tgz", - "integrity": "sha512-xjIYgE8HBrkpd/sJqOGNspf8uHG+NOHGOw6a/Urj8taM2EXfdNAH2oFcPeIFfsv3+kz/mJrS5VuMqbNLjCa2vw==" + "integrity": "sha512-xjIYgE8HBrkpd/sJqOGNspf8uHG+NOHGOw6a/Urj8taM2EXfdNAH2oFcPeIFfsv3+kz/mJrS5VuMqbNLjCa2vw==", + "dev": true }, "acorn-jsx": { "version": "5.3.2", "resolved": "https://registry.npmjs.org/acorn-jsx/-/acorn-jsx-5.3.2.tgz", - "integrity": "sha512-rq9s+JNhf0IChjtDXxllJ7g41oZk5SlXtp0LHwyA5cejwn7vKmKp4pPri6YEePv2PU65sAsegbXtIinmDFDXgQ==", - "requires": {} + "integrity": "sha512-rq9s+JNhf0IChjtDXxllJ7g41oZk5SlXtp0LHwyA5cejwn7vKmKp4pPri6YEePv2PU65sAsegbXtIinmDFDXgQ==" }, "acorn-walk": { "version": "8.2.0", @@ -6088,8 +6089,7 @@ "markdown-it-anchor": { "version": "8.6.7", "resolved": "https://registry.npmjs.org/markdown-it-anchor/-/markdown-it-anchor-8.6.7.tgz", - "integrity": "sha512-FlCHFwNnutLgVTflOYHPW2pPcl2AACqVzExlkGQNsi4CJgqOHN7YTgDd4LuhgN1BFO3TS0vLAruV1Td6dwWPJA==", - "requires": {} + "integrity": "sha512-FlCHFwNnutLgVTflOYHPW2pPcl2AACqVzExlkGQNsi4CJgqOHN7YTgDd4LuhgN1BFO3TS0vLAruV1Td6dwWPJA==" }, "marked": { "version": "4.3.0", @@ -7465,8 +7465,7 @@ "version": "7.5.6", "resolved": "https://registry.npmjs.org/ws/-/ws-7.5.6.tgz", "integrity": "sha512-6GLgCqo2cy2A2rjCNFlxQS6ZljG/coZfZXclldI8FB/1G3CCI36Zd8xy2HrFVACi8tfk5XrgLQEk+P0Tnz9UcA==", - "dev": true, - "requires": {} + "dev": true }, "xml2js": { "version": "0.6.2", From 3b623a5035f17482c6c0cb10824e7bbfbbf13337 Mon Sep 17 00:00:00 2001 From: Jimmy Date: Mon, 15 Jan 2024 14:51:17 -0800 Subject: [PATCH 2/4] update versioning trigger message --- .github/workflows/versioning.yml | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/.github/workflows/versioning.yml b/.github/workflows/versioning.yml index 56d40e51..2687aae1 100644 --- a/.github/workflows/versioning.yml +++ b/.github/workflows/versioning.yml @@ -13,9 +13,9 @@ jobs: - name: Get version type id: version_type run: | - if [[ ${{ contains(toJSON(github.event.head_commit.message), 'major') }} == true ]]; then + 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), 'minor') }} == true ]]; then + 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 From 25d43b9090dfb5a79e911e3aeae63e12b7986376 Mon Sep 17 00:00:00 2001 From: bot-edgepi <120603722+bot-edgepi@users.noreply.github.com> Date: Mon, 15 Jan 2024 23:14:40 +0000 Subject: [PATCH 3/4] 1.0.1 --- package-lock.json | 2 +- package.json | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/package-lock.json b/package-lock.json index 92624c95..ac59c021 100644 --- a/package-lock.json +++ b/package-lock.json @@ -1,6 +1,6 @@ { "name": "@edgepi-cloud/node-red-edgepi-pwm", - "version": "1.0.0", + "version": "1.0.1", "lockfileVersion": 2, "requires": true, "packages": { diff --git a/package.json b/package.json index 1d3ff72f..6881c4f5 100644 --- a/package.json +++ b/package.json @@ -5,7 +5,7 @@ "edgepi-pwm": "edgepi-pwm.js" } }, - "version": "1.0.0", + "version": "1.0.1", "description": "Node-RED node for EdgePi PWM Module", "main": "index.js", "scripts": {}, From 1582af5f14846a00c1bcc405e61f695a56810e48 Mon Sep 17 00:00:00 2001 From: bot-edgepi <120603722+bot-edgepi@users.noreply.github.com> Date: Mon, 15 Jan 2024 23:14:40 +0000 Subject: [PATCH 4/4] Bump version to 1.0.1 --- branch-name.txt | 1 + 1 file changed, 1 insertion(+) create mode 100644 branch-name.txt diff --git a/branch-name.txt b/branch-name.txt new file mode 100644 index 00000000..ceef033d --- /dev/null +++ b/branch-name.txt @@ -0,0 +1 @@ +version-20240115231439-b931e2c5