Skip to content

Commit

Permalink
feat: autorelease with github actions
Browse files Browse the repository at this point in the history
  • Loading branch information
rombat committed Jul 26, 2024
1 parent 485c5e5 commit cd32a8b
Show file tree
Hide file tree
Showing 7 changed files with 95 additions and 10 deletions.
29 changes: 29 additions & 0 deletions .github/workflows/release.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@
name: Release

on:
push:
branches: [master]

jobs:
release:
name: Release
runs-on: ubuntu-latest

steps:
- name: Checkout
uses: actions/checkout@v2
- name: Setup Node.js
uses: actions/setup-node@v1
with:
node-version: 18.x
- name: Install pkg globally
run: npm install -g pkg
- name: Install dependencies
run: npx ci
- name: Install semantic-release extra plugins
run: npm install -D semantic-release@22.0.12 @semantic-release/exec @semantic-release/changelog @semantic-release/git @semantic-release/github
- name: Release
env:
GH_TOKEN: ${{ secrets.GH_TOKEN }}
run: npx semantic-release

1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@
TODO.md
/musicbee-navidrome-sync.exe
/dist/
/.dist/
/MusicBee_Export.csv
/navidrome.db
/backups/
2 changes: 1 addition & 1 deletion index.js
Original file line number Diff line number Diff line change
Expand Up @@ -51,7 +51,7 @@ program
program
.name('musicbee-navidrome-sync')
.description(
'MusicBee to Navidrome Sync (MBNDS) : Tools to sync MusicBee DB to Navidrome DB\nhttps://github.com/rombat/musicbee-navidrome-sync'
`MusicBee to Navidrome Sync (MBNDS) : Tools to sync MusicBee DB to Navidrome DB (v${packageJson.version})\nhttps://github.com/rombat/musicbee-navidrome-sync`
)
.version(packageJson.version, '-v, --version', 'output the current version');

Expand Down
2 changes: 1 addition & 1 deletion package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

15 changes: 7 additions & 8 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@
"fullSync": "node index.js fullSync",
"albumsSync": "node index.js albumsSync",
"artistsSync": "node index.js artistsSync",
"build": "pkg ."
"build": "sh ./release.sh"
},
"author": "rombat",
"license": "GNU GPL V3.0",
Expand All @@ -22,21 +22,20 @@
"sequelize": "^6.37.3",
"sqlite3": "^5.1.7"
},
"devDependencies": {
"prettier": "^3.3.3"
},
"engines": {
"node": ">=16.0.0"
"node": ">=18.0.0"
},
"private": true,
"bin": "index.js",
"pkg": {
"assets": [
"node_modules/**/*"
],
"targets": [
"node18-win-x64"
],
"outputPath": "dist",
"outputName": "musicbee-navidrome-sync"
},
"devDependencies": {
"prettier": "^3.3.3"
]
}
}
46 changes: 46 additions & 0 deletions release.config.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,46 @@
module.exports = {
branches: ['master'],
plugins: [
'@semantic-release/commit-analyzer',
{
preset: 'eslint',
releaseRules: [
{ scope: 'no-release', release: false },
{ type: 'chore', release: 'patch' },
{ type: '', release: 'patch' }
]
},
[
'@semantic-release/release-notes-generator',
{
changelogTitle: 'MBNDS CHANGELOG'
}
],
'@semantic-release/changelog',
[
'@semantic-release/npm',
{
npmPublish: false
}
],
[
'@semantic-release/exec',
{
publishCmd: 'npm run build ${nextRelease.version}'
}
],
[
'@semantic-release/github',
{
assets: [{ path: '.dist/musicbee-navidrome-sync_${nextRelease.version}.exe', label: 'MBNDS v${nextRelease.version}' }]
}
],
[
'@semantic-release/git',
{
message: 'chore(release): set `package.json` to ${nextRelease.version} [skip ci]\n\n${nextRelease.notes}',
assets: ['package.json', 'CHANGELOG.md']
}
]
]
};
10 changes: 10 additions & 0 deletions release.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
set -e
VERSION=${1:-$(node -p "require('./package.json').version")}

rm -rf .dist
mkdir -p .dist
cp -r index.js package*.json lib .dist
cd .dist
npm install --omit=dev

pkg -c package.json index.js -o musicbee-navidrome-sync_${VERSION}.exe

0 comments on commit cd32a8b

Please sign in to comment.