Skip to content

Commit 5ca9a54

Browse files
committed
chore(ci): add auto-release
1 parent b232087 commit 5ca9a54

File tree

4 files changed

+175
-1
lines changed

4 files changed

+175
-1
lines changed

.github/dependabot.yml

+16
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,16 @@
1+
version: 2
2+
updates:
3+
- package-ecosystem: 'github-actions'
4+
directory: '/'
5+
schedule:
6+
interval: 'daily'
7+
commit-message:
8+
prefix: 'chore'
9+
include: 'scope'
10+
- package-ecosystem: 'npm'
11+
directory: '/'
12+
schedule:
13+
interval: 'daily'
14+
commit-message:
15+
prefix: 'chore'
16+
include: 'scope'
+61
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,61 @@
1+
name: Test & Maybe Release
2+
on: [push, pull_request]
3+
jobs:
4+
test:
5+
strategy:
6+
fail-fast: false
7+
matrix:
8+
node: [16.x, 18.x, lts/*, current]
9+
os: [macos-latest, ubuntu-latest, windows-latest]
10+
runs-on: ${{ matrix.os }}
11+
steps:
12+
- name: Checkout Repository
13+
uses: actions/checkout@v3
14+
- name: Use Node.js ${{ matrix.node }}
15+
uses: actions/[email protected]
16+
with:
17+
node-version: ${{ matrix.node }}
18+
- name: Install Dependencies
19+
run: |
20+
npm install --no-progress
21+
- name: Run tests
22+
run: |
23+
npm config set script-shell bash
24+
npm run test:ci
25+
release:
26+
name: Release
27+
needs: test
28+
runs-on: ubuntu-latest
29+
if: github.event_name == 'push' && github.ref == 'refs/heads/master'
30+
steps:
31+
- name: Checkout
32+
uses: actions/checkout@v3
33+
with:
34+
fetch-depth: 0
35+
- name: Setup Node.js
36+
uses: actions/[email protected]
37+
with:
38+
node-version: lts/*
39+
- name: Install dependencies
40+
run: |
41+
npm install --no-progress --no-package-lock --no-save
42+
- name: Build
43+
run: |
44+
npm run build
45+
- name: Install plugins
46+
run: |
47+
npm install \
48+
@semantic-release/commit-analyzer \
49+
conventional-changelog-conventionalcommits \
50+
@semantic-release/release-notes-generator \
51+
@semantic-release/npm \
52+
@semantic-release/github \
53+
@semantic-release/git \
54+
@semantic-release/changelog \
55+
--no-progress --no-package-lock --no-save
56+
- name: Release
57+
env:
58+
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
59+
NPM_TOKEN: ${{ secrets.NPM_TOKEN }}
60+
run: npx semantic-release
61+

package.json

+84-1
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,8 @@
44
"description": "Turn a `git log` into a stream of commit objects",
55
"main": "commit-stream.js",
66
"scripts": {
7+
"build": "true",
8+
"test:ci": "npm run test",
79
"test": "node test.js"
810
},
911
"repository": {
@@ -19,10 +21,91 @@
1921
"devDependencies": {
2022
"list-stream": "~1.0.0",
2123
"split2": "~1.0.0",
22-
"tape": "~4.0.1"
24+
"tape": "^5.6.3"
2325
},
2426
"dependencies": {
2527
"strip-ansi": "^6.0.1",
2628
"through2": "~2.0.0"
29+
},
30+
"release": {
31+
"branches": [
32+
"main"
33+
],
34+
"plugins": [
35+
[
36+
"@semantic-release/commit-analyzer",
37+
{
38+
"preset": "conventionalcommits",
39+
"releaseRules": [
40+
{
41+
"breaking": true,
42+
"release": "major"
43+
},
44+
{
45+
"revert": true,
46+
"release": "patch"
47+
},
48+
{
49+
"type": "feat",
50+
"release": "minor"
51+
},
52+
{
53+
"type": "fix",
54+
"release": "patch"
55+
},
56+
{
57+
"type": "chore",
58+
"release": "patch"
59+
},
60+
{
61+
"type": "docs",
62+
"release": "patch"
63+
},
64+
{
65+
"type": "test",
66+
"release": "patch"
67+
},
68+
{
69+
"scope": "no-release",
70+
"release": false
71+
}
72+
]
73+
}
74+
],
75+
[
76+
"@semantic-release/release-notes-generator",
77+
{
78+
"preset": "conventionalcommits",
79+
"presetConfig": {
80+
"types": [
81+
{
82+
"type": "feat",
83+
"section": "Features"
84+
},
85+
{
86+
"type": "fix",
87+
"section": "Bug Fixes"
88+
},
89+
{
90+
"type": "chore",
91+
"section": "Trivial Changes"
92+
},
93+
{
94+
"type": "docs",
95+
"section": "Trivial Changes"
96+
},
97+
{
98+
"type": "test",
99+
"section": "Tests"
100+
}
101+
]
102+
}
103+
}
104+
],
105+
"@semantic-release/changelog",
106+
"@semantic-release/npm",
107+
"@semantic-release/github",
108+
"@semantic-release/git"
109+
]
27110
}
28111
}

test.js

+14
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
const through2 = require('through2')
22
, commitStream = require('./')
33
, spawn = require('child_process').spawn
4+
, exec = require('child_process').exec
45
, test = require('tape')
56
, split2 = require('split2')
67
, listStream = require('list-stream')
@@ -11,6 +12,19 @@ function gitToList (gitCmd, callback) {
1112
child.stdout.pipe(split2()).pipe(commitStream()).pipe(listStream.obj(callback))
1213
}
1314

15+
test('git is runnable', function (t) {
16+
exec('git version', (error, stdout, stderr) => {
17+
if (error) {
18+
t.fail(`command failed: ${error}`)
19+
} else if (stderr) {
20+
t.fail(`command output to stderr: ${stderr}`)
21+
} else {
22+
t.match(stdout, /^git version 2/)
23+
}
24+
t.end()
25+
})
26+
})
27+
1428

1529
test('current plain commit log', function (t) {
1630
gitToList('git log', function (err, list) {

0 commit comments

Comments
 (0)