Skip to content

Commit cd32a8b

Browse files
committed
feat: autorelease with github actions
1 parent 485c5e5 commit cd32a8b

File tree

7 files changed

+95
-10
lines changed

7 files changed

+95
-10
lines changed

.github/workflows/release.yml

Lines changed: 29 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,29 @@
1+
name: Release
2+
3+
on:
4+
push:
5+
branches: [master]
6+
7+
jobs:
8+
release:
9+
name: Release
10+
runs-on: ubuntu-latest
11+
12+
steps:
13+
- name: Checkout
14+
uses: actions/checkout@v2
15+
- name: Setup Node.js
16+
uses: actions/setup-node@v1
17+
with:
18+
node-version: 18.x
19+
- name: Install pkg globally
20+
run: npm install -g pkg
21+
- name: Install dependencies
22+
run: npx ci
23+
- name: Install semantic-release extra plugins
24+
run: npm install -D [email protected] @semantic-release/exec @semantic-release/changelog @semantic-release/git @semantic-release/github
25+
- name: Release
26+
env:
27+
GH_TOKEN: ${{ secrets.GH_TOKEN }}
28+
run: npx semantic-release
29+

.gitignore

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,7 @@
55
TODO.md
66
/musicbee-navidrome-sync.exe
77
/dist/
8+
/.dist/
89
/MusicBee_Export.csv
910
/navidrome.db
1011
/backups/

index.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -51,7 +51,7 @@ program
5151
program
5252
.name('musicbee-navidrome-sync')
5353
.description(
54-
'MusicBee to Navidrome Sync (MBNDS) : Tools to sync MusicBee DB to Navidrome DB\nhttps://github.com/rombat/musicbee-navidrome-sync'
54+
`MusicBee to Navidrome Sync (MBNDS) : Tools to sync MusicBee DB to Navidrome DB (v${packageJson.version})\nhttps://github.com/rombat/musicbee-navidrome-sync`
5555
)
5656
.version(packageJson.version, '-v, --version', 'output the current version');
5757

package-lock.json

Lines changed: 1 addition & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

package.json

Lines changed: 7 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@
88
"fullSync": "node index.js fullSync",
99
"albumsSync": "node index.js albumsSync",
1010
"artistsSync": "node index.js artistsSync",
11-
"build": "pkg ."
11+
"build": "sh ./release.sh"
1212
},
1313
"author": "rombat",
1414
"license": "GNU GPL V3.0",
@@ -22,21 +22,20 @@
2222
"sequelize": "^6.37.3",
2323
"sqlite3": "^5.1.7"
2424
},
25+
"devDependencies": {
26+
"prettier": "^3.3.3"
27+
},
2528
"engines": {
26-
"node": ">=16.0.0"
29+
"node": ">=18.0.0"
2730
},
31+
"private": true,
2832
"bin": "index.js",
2933
"pkg": {
3034
"assets": [
3135
"node_modules/**/*"
3236
],
3337
"targets": [
3438
"node18-win-x64"
35-
],
36-
"outputPath": "dist",
37-
"outputName": "musicbee-navidrome-sync"
38-
},
39-
"devDependencies": {
40-
"prettier": "^3.3.3"
39+
]
4140
}
4241
}

release.config.js

Lines changed: 46 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,46 @@
1+
module.exports = {
2+
branches: ['master'],
3+
plugins: [
4+
'@semantic-release/commit-analyzer',
5+
{
6+
preset: 'eslint',
7+
releaseRules: [
8+
{ scope: 'no-release', release: false },
9+
{ type: 'chore', release: 'patch' },
10+
{ type: '', release: 'patch' }
11+
]
12+
},
13+
[
14+
'@semantic-release/release-notes-generator',
15+
{
16+
changelogTitle: 'MBNDS CHANGELOG'
17+
}
18+
],
19+
'@semantic-release/changelog',
20+
[
21+
'@semantic-release/npm',
22+
{
23+
npmPublish: false
24+
}
25+
],
26+
[
27+
'@semantic-release/exec',
28+
{
29+
publishCmd: 'npm run build ${nextRelease.version}'
30+
}
31+
],
32+
[
33+
'@semantic-release/github',
34+
{
35+
assets: [{ path: '.dist/musicbee-navidrome-sync_${nextRelease.version}.exe', label: 'MBNDS v${nextRelease.version}' }]
36+
}
37+
],
38+
[
39+
'@semantic-release/git',
40+
{
41+
message: 'chore(release): set `package.json` to ${nextRelease.version} [skip ci]\n\n${nextRelease.notes}',
42+
assets: ['package.json', 'CHANGELOG.md']
43+
}
44+
]
45+
]
46+
};

release.sh

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,10 @@
1+
set -e
2+
VERSION=${1:-$(node -p "require('./package.json').version")}
3+
4+
rm -rf .dist
5+
mkdir -p .dist
6+
cp -r index.js package*.json lib .dist
7+
cd .dist
8+
npm install --omit=dev
9+
10+
pkg -c package.json index.js -o musicbee-navidrome-sync_${VERSION}.exe

0 commit comments

Comments
 (0)