From 155de4c06e00bfbbeb397f0b31142dc6a609c742 Mon Sep 17 00:00:00 2001 From: Rod Vagg Date: Fri, 28 May 2021 11:51:17 +1000 Subject: [PATCH] chore: add semantic-release for auto-releases --- .github/workflows/main.yml | 43 -------------- .github/workflows/test-and-release.yml | 80 ++++++++++++++++++++++++++ package.json | 38 ++++++++++++ 3 files changed, 118 insertions(+), 43 deletions(-) delete mode 100644 .github/workflows/main.yml create mode 100644 .github/workflows/test-and-release.yml diff --git a/.github/workflows/main.yml b/.github/workflows/main.yml deleted file mode 100644 index 0ed973b..0000000 --- a/.github/workflows/main.yml +++ /dev/null @@ -1,43 +0,0 @@ -name: Tests -on: [push, pull_request] -jobs: - Tests: - strategy: - fail-fast: false - matrix: - node: [14.x, 16.x] - os: [macos-latest, ubuntu-latest] - runs-on: ${{ matrix.os }} - steps: - - name: Checkout Repository - uses: actions/checkout@v2.3.4 - - name: Use Node.js ${{ matrix.node }} - uses: actions/setup-node@v2.1.5 - with: - node-version: ${{ matrix.node }} - - name: Install Dependencies - run: | - npm install --no-progress - - name: Run tests - run: | - npm test - Tests-Windows: - strategy: - fail-fast: false - matrix: - node: [14.x, 15.x] - os: [windows-latest] - runs-on: ${{ matrix.os }} - steps: - - name: Checkout Repository - uses: actions/checkout@v2.3.4 - - name: Use Node.js ${{ matrix.node }} - uses: actions/setup-node@v2.1.5 - with: - node-version: ${{ matrix.node }} - - name: Install Dependencies - run: | - npm install --no-progress - - name: Run tests - run: | - npm run test:node diff --git a/.github/workflows/test-and-release.yml b/.github/workflows/test-and-release.yml new file mode 100644 index 0000000..dc4603f --- /dev/null +++ b/.github/workflows/test-and-release.yml @@ -0,0 +1,80 @@ +name: Test & Maybe Release +on: [push, pull_request] +jobs: + test: + strategy: + fail-fast: false + matrix: + node: [14.x, 16.x] + os: [macos-latest, ubuntu-latest] + runs-on: ${{ matrix.os }} + steps: + - name: Checkout Repository + uses: actions/checkout@v2.3.4 + - name: Use Node.js ${{ matrix.node }} + uses: actions/setup-node@v2.1.5 + with: + node-version: ${{ matrix.node }} + - name: Install Dependencies + run: | + npm install --no-progress + - name: Run tests + run: | + npm test + test-windows: + strategy: + fail-fast: false + matrix: + node: [14.x, 16.x] + os: [windows-latest] + runs-on: ${{ matrix.os }} + steps: + - name: Checkout Repository + uses: actions/checkout@v2.3.4 + - name: Use Node.js ${{ matrix.node }} + uses: actions/setup-node@v2.1.5 + with: + node-version: ${{ matrix.node }} + - name: Install Dependencies + run: | + npm install --no-progress + - name: Run tests + run: | + npm run test:node + release: + name: Release + needs: [test, test-windows] + runs-on: ubuntu-latest + if: github.event_name == 'push' && github.ref == 'refs/heads/master' + steps: + - name: Checkout + uses: actions/checkout@v2.3.4 + with: + fetch-depth: 0 + - name: Setup Node.js + uses: actions/setup-node@v2.1.5 + with: + node-version: 14 + - name: Install dependencies + run: | + npm install --no-progress --no-package-lock --no-save + - name: Build + run: | + npm run build + - name: Install plugins + run: | + npm install \ + @semantic-release/commit-analyzer \ + conventional-changelog-conventionalcommits \ + @semantic-release/release-notes-generator \ + @semantic-release/npm \ + @semantic-release/github \ + @semantic-release/git \ + @semantic-release/changelog \ + --no-progress --no-package-lock --no-save + - name: Release + env: + GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} + NPM_TOKEN: ${{ secrets.NPM_TOKEN }} + run: npx semantic-release + diff --git a/package.json b/package.json index 985a261..fa6f9ab 100644 --- a/package.json +++ b/package.json @@ -62,5 +62,43 @@ "types/*" ] } + }, + "release": { + "branches": [ + "master" + ], + "plugins": [ + ["@semantic-release/commit-analyzer", { + "preset": "conventionalcommits", + "releaseRules": [ + {"breaking": true, "release": "major"}, + {"revert": true, "release": "patch"}, + {"type": "feat", "release": "minor"}, + {"type": "fix", "release": "patch"}, + {"type": "chore", "release": "patch"}, + {"type": "docs", "release": "patch"}, + {"type": "test", "release": "patch"}, + {"scope": "no-release", "release": false} + ] + }], + ["@semantic-release/release-notes-generator", { + "preset": "conventionalcommits", + "presetConfig": { + "types": [ + {"type": "feat", "section": "Features"}, + {"type": "fix", "section": "Bug Fixes"}, + {"type": "chore", "section": "Trivial Changes"}, + {"type": "docs", "section": "Trivial Changes"}, + {"type": "test", "section": "Tests"} + ] + } + }], + "@semantic-release/changelog", + ["@semantic-release/npm", { + "pkgRoot": "dist" + }], + "@semantic-release/github", + "@semantic-release/git" + ] } }