diff --git a/.github/dependabot.yml b/.github/dependabot.yml new file mode 100644 index 0000000..f468993 --- /dev/null +++ b/.github/dependabot.yml @@ -0,0 +1,16 @@ +version: 2 +updates: + - package-ecosystem: 'github-actions' + directory: '/' + schedule: + interval: 'daily' + commit-message: + prefix: 'chore' + include: 'scope' + - package-ecosystem: 'npm' + directory: '/' + schedule: + interval: 'daily' + commit-message: + prefix: 'chore' + include: 'scope' diff --git a/.github/workflows/test-and-release.yml b/.github/workflows/test-and-release.yml new file mode 100644 index 0000000..c379ea8 --- /dev/null +++ b/.github/workflows/test-and-release.yml @@ -0,0 +1,61 @@ +name: Test & Maybe Release +on: [push, pull_request] +jobs: + test: + strategy: + fail-fast: false + matrix: + node: [16.x, 18.x, lts/*, current] + os: [macos-latest, ubuntu-latest, windows-latest] + runs-on: ${{ matrix.os }} + steps: + - name: Checkout Repository + uses: actions/checkout@v3 + - name: Use Node.js ${{ matrix.node }} + uses: actions/setup-node@v3.5.1 + with: + node-version: ${{ matrix.node }} + - name: Install Dependencies + run: | + npm install --no-progress + - name: Run tests + run: | + npm config set script-shell bash + npm run test:ci + 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@v3 + with: + fetch-depth: 0 + - name: Setup Node.js + uses: actions/setup-node@v3.5.1 + with: + node-version: lts/* + - 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 d1b31a5..546fc10 100644 --- a/package.json +++ b/package.json @@ -4,6 +4,8 @@ "description": "Turn a `git log` into a stream of commit objects", "main": "commit-stream.js", "scripts": { + "build": "true", + "test:ci": "npm run test", "test": "node test.js" }, "repository": { @@ -19,10 +21,91 @@ "devDependencies": { "list-stream": "~1.0.0", "split2": "~1.0.0", - "tape": "~4.0.1" + "tape": "^5.6.3" }, "dependencies": { "strip-ansi": "^6.0.1", "through2": "~2.0.0" + }, + "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" + ] } } diff --git a/test.js b/test.js index be1b9bf..7c3392d 100644 --- a/test.js +++ b/test.js @@ -1,6 +1,7 @@ const through2 = require('through2') , commitStream = require('./') , spawn = require('child_process').spawn + , exec = require('child_process').exec , test = require('tape') , split2 = require('split2') , listStream = require('list-stream') @@ -11,6 +12,19 @@ function gitToList (gitCmd, callback) { child.stdout.pipe(split2()).pipe(commitStream()).pipe(listStream.obj(callback)) } +test('git is runnable', function (t) { + exec('git version', (error, stdout, stderr) => { + if (error) { + t.fail(`command failed: ${error}`) + } else if (stderr) { + t.fail(`command output to stderr: ${stderr}`) + } else { + t.match(stdout, /^git version 2/) + } + t.end() + }) +}) + test('current plain commit log', function (t) { gitToList('git log', function (err, list) {