From 547a98cf975838f5adc51cb8c4c7697af1910aaf Mon Sep 17 00:00:00 2001 From: Rod Vagg Date: Wed, 13 Oct 2021 11:42:59 +1100 Subject: [PATCH 1/2] chore: add auto-release workflow --- .github/workflows/lint.yml | 23 ------- .github/workflows/test-and-release.yml | 77 +++++++++++++++++++++++ package.json | 84 +++++++++++++++++++++++++- 3 files changed, 160 insertions(+), 24 deletions(-) delete mode 100644 .github/workflows/lint.yml create mode 100644 .github/workflows/test-and-release.yml diff --git a/.github/workflows/lint.yml b/.github/workflows/lint.yml deleted file mode 100644 index 6261e3a..0000000 --- a/.github/workflows/lint.yml +++ /dev/null @@ -1,23 +0,0 @@ -name: Lint - -on: - push: - branches: - - main - pull_request: - branches: - - main - -jobs: - build: - runs-on: macOS-latest - steps: - - uses: actions/checkout@v2 - - name: Use Node.js 14.x - uses: actions/setup-node@v2 - with: - version: 14.x - - name: Lint - run: | - npm i - npm run lint diff --git a/.github/workflows/test-and-release.yml b/.github/workflows/test-and-release.yml new file mode 100644 index 0000000..e42858f --- /dev/null +++ b/.github/workflows/test-and-release.yml @@ -0,0 +1,77 @@ +name: Test & Maybe Release +on: [push, pull_request] +jobs: + test: + name: Node ${{ matrix.node }} on ${{ matrix.os }} + runs-on: ${{ matrix.os }} + + strategy: + fail-fast: false + matrix: + node: [12, 14, 16] + # windows support not quite ready: os: [ubuntu-latest, windows-latest] + os: [ubuntu-latest] + + steps: + - name: Clone repository + uses: actions/checkout@v2 + + - run: git fetch --prune --unshallow + + - name: Set Node.js version + uses: actions/setup-node@v2 + with: + node-version: ${{ matrix.node }} + + - run: node --version + - run: npm --version + - run: git --version + + - name: Install npm dependencies + run: npm ci + + - name: Run tests + run: npm test + + release: + name: Release + needs: test + runs-on: ubuntu-latest + if: github.event_name == 'push' && github.ref == 'refs/heads/main' + + steps: + - name: Checkout + uses: actions/checkout@v2.3.4 + with: + fetch-depth: 0 + + - name: Setup Node.js + uses: actions/setup-node@v2.4.0 + 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 58b291b..59db217 100644 --- a/package.json +++ b/package.json @@ -8,7 +8,8 @@ }, "scripts": { "lint": "standard", - "format": "standard --fix" + "format": "standard --fix", + "test": "npm run lint" }, "author": "Rod (http://r.va.gg/)", "license": "MIT", @@ -33,5 +34,86 @@ "preferGlobal": true, "devDependencies": { "standard": "^16.0.3" + }, + "release": { + "branches": [ + "main" + ], + "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", + "@semantic-release/github", + "@semantic-release/git" + ] } } From 43420ee7bbaccf0e5eb6a9c2d81f8eeeeb1b0880 Mon Sep 17 00:00:00 2001 From: Rod Vagg Date: Thu, 14 Oct 2021 14:33:17 +1100 Subject: [PATCH 2/2] fix: remove build step --- .github/workflows/test-and-release.yml | 4 ---- 1 file changed, 4 deletions(-) diff --git a/.github/workflows/test-and-release.yml b/.github/workflows/test-and-release.yml index e42858f..3e53310 100644 --- a/.github/workflows/test-and-release.yml +++ b/.github/workflows/test-and-release.yml @@ -54,10 +54,6 @@ jobs: run: | npm install --no-progress --no-package-lock --no-save - - name: Build - run: | - npm run build - - name: Install plugins run: | npm install \