Skip to content

Commit

Permalink
fix: correctly detect breaking changes (#19)
Browse files Browse the repository at this point in the history
* fix: correctly detect breaking changes

Fixes #18

* fix: correctly detect breaking changes in header

* chore: move to github actions

* chore: update minimum node version

BREAKING CHANGE: this drops support for node 8

* ci: correct job name

* ci: add release workflow
  • Loading branch information
elliotttf committed Dec 29, 2021
1 parent 48ac4ef commit f336ad6
Show file tree
Hide file tree
Showing 7 changed files with 3,838 additions and 508 deletions.
24 changes: 24 additions & 0 deletions .github/workflows/release.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
name: Release

on:
push:
branches:
- master
jobs:
release:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v2
with:
token: ${{ secrets.GH_TOKEN || github.token }}
- uses: actions/setup-node@v1
with:
node-version: 16
- run: npm config set //registry.npmjs.org/:_authToken=$NPM_TOKEN
env:
NPM_TOKEN: ${{ secrets.NPM_TOKEN }}
- run: yarn install
- run: yarn semantic-release
env:
GH_TOKEN: ${{ secrets.GH_TOKEN }}
NPM_TOKEN: ${{ secrets.NPM_TOKEN }}
29 changes: 29 additions & 0 deletions .github/workflows/test.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@
name: Node CI

on: [push]

jobs:
test:

runs-on: ubuntu-latest

strategy:
matrix:
node-version:
- 10.x
- 12.x
- 14.x
- 16.x

steps:
- uses: actions/checkout@v1
- name: Use Node.js ${{ matrix.node-version }}
uses: actions/setup-node@v1
with:
node-version: ${{ matrix.node-version }}
- name: yarn install and test
run: |
yarn install
yarn test
env:
CI: true
17 changes: 0 additions & 17 deletions .travis.yml

This file was deleted.

1 change: 1 addition & 0 deletions index.js
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,7 @@ async function conventionalCommitsAnalyzer(config, { commits }) {

if (
majorTypes.indexOf(commit.type) !== -1 ||
commit.header.match(/^[^!:]+!:/) ||
commit.notes.find(note => note.title.toUpperCase().match(/BREAKING CHANGE/))
) {
type = 'major';
Expand Down
4 changes: 2 additions & 2 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@
"conventional-commits-parser": "^3.0.0"
},
"engines": {
"node": ">=8"
"node": ">=10"
},
"devDependencies": {
"coveralls": "^3.0.0",
Expand All @@ -42,4 +42,4 @@
"type": "git",
"url": "https://github.com/elliotttf/semantic-release-conventional-commits.git"
}
}
}
23 changes: 16 additions & 7 deletions test/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -4,20 +4,29 @@ const analyzer = require('../');

module.exports = {
noConfig: {
major(test) {
test.expect(1);
analyzer(
async major(test) {
test.expect(2);
const type = await analyzer(
{},
{
commits: [{
hash: '',
message: 'feat(thing): Added the thing\nBREAKING CHANGE: api change',
}],
})
.then((type) => {
test.equal(type, 'major', 'Unexpected type for `BREAKING CHANGE:`.');
test.done();
});
test.equal(type, 'major', 'Unexpected type for `BREAKING CHANGE:`.');

const type2 = await analyzer(
{},
{
commits: [{
hash: '',
message: 'feat(thing)!: Added the thing',
}],
});
test.equal(type2, 'major', 'Unexpected type for `BREAKING CHANGE:`.');

test.done();
},
minor(test) {
test.expect(1);
Expand Down

0 comments on commit f336ad6

Please sign in to comment.