diff --git a/.github/workflows/test.yml b/.github/workflows/test-and-release.yml similarity index 52% rename from .github/workflows/test.yml rename to .github/workflows/test-and-release.yml index 3fe543f..dba3d20 100644 --- a/.github/workflows/test.yml +++ b/.github/workflows/test-and-release.yml @@ -1,9 +1,7 @@ -name: Tests - +name: Test & Maybe Release on: [push, pull_request] - jobs: - run: + test: name: Node ${{ matrix.node }} on ${{ matrix.os }} runs-on: ${{ matrix.os }} @@ -47,3 +45,46 @@ jobs: - name: Run tests run: npm test + + release: + name: Release + needs: test + 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.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 986fd8a..c057368 100644 --- a/package.json +++ b/package.json @@ -44,5 +44,86 @@ "lint": "standard", "unit": "tap --no-check-coverage test.js", "test": "npm run lint && npm run unit" + }, + "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" + ] } }