From f05b804962aa2e98eec05cf47b118a986f65e440 Mon Sep 17 00:00:00 2001 From: Oren Date: Tue, 14 Feb 2023 22:59:05 +0200 Subject: [PATCH] Add GitHub Actions --- .github/release-drafter.yml | 56 +++++++++++++++++++++++++++ .github/workflows/node.js.yml | 27 +++++++++++++ .github/workflows/publish-npm.yml | 36 +++++++++++++++++ .github/workflows/release-drafter.yml | 16 ++++++++ 4 files changed, 135 insertions(+) create mode 100644 .github/release-drafter.yml create mode 100644 .github/workflows/node.js.yml create mode 100644 .github/workflows/publish-npm.yml create mode 100644 .github/workflows/release-drafter.yml diff --git a/.github/release-drafter.yml b/.github/release-drafter.yml new file mode 100644 index 0000000..197fe04 --- /dev/null +++ b/.github/release-drafter.yml @@ -0,0 +1,56 @@ +name-template: 'v$RESOLVED_VERSION' +tag-template: 'v$RESOLVED_VERSION' +categories: + - title: '🚀 Features' + labels: + - 'feature' + - 'enhancement' + - title: '🐛 Bug Fixes' + labels: + - 'fix' + - 'bugfix' + - 'bug' + - title: '🧰 Maintenance' + label: 'chore' +change-template: '- $TITLE @$AUTHOR (#$NUMBER)' +change-title-escapes: '\<*_&' # You can add # and @ to disable mentions, and add ` to disable code blocks. +version-resolver: + major: + labels: + - 'major' + - 'breaking' + minor: + labels: + - 'minor' + - 'enhancement' + patch: + labels: + - 'patch' + - 'bug' + default: patch +template: | + ## Changes + + $CHANGES +autolabeler: + - label: 'chore' + files: + - '*.md' + branch: + - '/docs{0,1}\/.+/' + - label: 'bug' + branch: + - '/fix\/.+/' + title: + - '/fix/i' + - '/bugfix/i' + - label: 'enhancement' + title: + - '/added/i' + - '/add/i' + - '/feature/i' + - '/feat/i' + - '/support/i' + - '/enable/i' + branch: + - '/feature\/.+/' diff --git a/.github/workflows/node.js.yml b/.github/workflows/node.js.yml new file mode 100644 index 0000000..b19dec5 --- /dev/null +++ b/.github/workflows/node.js.yml @@ -0,0 +1,27 @@ +name: Node.js CI + +on: + push: + branches: [ main ] + pull_request: + branches: [ main ] + +jobs: + build: + + runs-on: ubuntu-latest + + strategy: + matrix: + node-version: [12.x, 14.x, 16.14.2] + # See supported Node.js release schedule at https://nodejs.org/en/about/releases/ + + steps: + - uses: actions/checkout@v2 + - name: Use Node.js ${{ matrix.node-version }} + uses: actions/setup-node@v2 + with: + node-version: ${{ matrix.node-version }} + cache: 'npm' + - run: npm ci + - run: npm run build --if-present diff --git a/.github/workflows/publish-npm.yml b/.github/workflows/publish-npm.yml new file mode 100644 index 0000000..72c502d --- /dev/null +++ b/.github/workflows/publish-npm.yml @@ -0,0 +1,36 @@ +name: Publish to NPM +on: + release: + types: [published] +env: + GIT_TERMINAL_PROMPT: 1 +jobs: + publish: + runs-on: ubuntu-latest + steps: + - uses: actions/checkout@v3 + with: + fetch-depth: 0 + - uses: actions/setup-node@v2 + with: + node-version: '16.14.2' + registry-url: 'https://registry.npmjs.org' + - run: npm install + - run: | + initialTag=${{ github.event.release.tag_name }} + tag="${initialTag//[v]/}" + echo $tag + git remote update + git fetch + git checkout --track origin/main + git config --global user.email "github-actions@github.com" + git config --global user.name "Github Actions" + npm --no-git-tag-version --allow-same-version version $tag + npm i -g auto-changelog + auto-changelog --hide-credit -l 100 + git add . + git commit -m "release $tag" + git push + - run: npm publish + env: + NODE_AUTH_TOKEN: ${{ secrets.NPM_TOKEN }} diff --git a/.github/workflows/release-drafter.yml b/.github/workflows/release-drafter.yml new file mode 100644 index 0000000..52fa63b --- /dev/null +++ b/.github/workflows/release-drafter.yml @@ -0,0 +1,16 @@ +name: Release Drafter + +on: + push: + branches: + - main + pull_request: + types: [opened, reopened, synchronize] + +jobs: + update_release_draft: + runs-on: ubuntu-latest + steps: + - uses: release-drafter/release-drafter@v5 + env: + GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}