Skip to content

Commit cb9d278

Browse files
committed
ci: introduction of conventional commits, husky, and Lerna (for release management and changelogs)
1 parent 011dbb7 commit cb9d278

File tree

9 files changed

+5312
-191
lines changed

9 files changed

+5312
-191
lines changed
Lines changed: 79 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,79 @@
1+
name: Prepare Release
2+
3+
on:
4+
workflow_run:
5+
workflows: ["CI"]
6+
types:
7+
- completed
8+
9+
jobs:
10+
version:
11+
if: >
12+
github.event.workflow_run.conclusion == 'success' &&
13+
github.event.workflow_run.head_branch == 'master' &&
14+
!startsWith(github.event.workflow_run.head_commit.message, 'chore(release)')
15+
runs-on: ubuntu-latest
16+
permissions:
17+
contents: write
18+
steps:
19+
- name: Checkout
20+
uses: actions/checkout@v4
21+
with:
22+
repository: ${{ github.event.workflow_run.head_repository.full_name }}
23+
ref: ${{ github.event.workflow_run.head_commit.id }}
24+
fetch-depth: 0
25+
26+
- name: Setup pnpm
27+
uses: pnpm/action-setup@v4
28+
29+
- name: Setup Node.js
30+
uses: actions/setup-node@v4
31+
with:
32+
node-version: 20.x
33+
cache: pnpm
34+
35+
- name: Install dependencies
36+
env:
37+
LAME_SKIP_DOWNLOAD: "1"
38+
run: pnpm install --frozen-lockfile
39+
40+
- name: Lint
41+
run: pnpm run lint
42+
43+
- name: Typecheck
44+
run: pnpm run typecheck
45+
46+
- name: Unit tests
47+
run: pnpm run test:unit
48+
49+
- name: Integration tests
50+
run: pnpm run test:integration
51+
52+
- name: Configure git
53+
run: |
54+
git config user.name "github-actions[bot]"
55+
git config user.email "github-actions[bot]@users.noreply.github.com"
56+
57+
- name: Bump version and changelog
58+
id: version
59+
env:
60+
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
61+
run: |
62+
set -eo pipefail
63+
pnpm run release:version > version.log 2>&1 || STATUS=$?
64+
cat version.log
65+
if [ -n "$STATUS" ]; then
66+
if grep -q "No changed packages" version.log; then
67+
echo "skip=true" >> "$GITHUB_OUTPUT"
68+
exit 0
69+
fi
70+
exit "$STATUS"
71+
fi
72+
NEW_VERSION=$(node -p "require('./package.json').version")
73+
echo "version=$NEW_VERSION" >> "$GITHUB_OUTPUT"
74+
75+
- name: Push release commit and tags
76+
if: steps.version.outputs.skip != 'true'
77+
env:
78+
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
79+
run: git push --follow-tags

.github/workflows/release.yml

Lines changed: 39 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,8 @@ jobs:
1010
build-binaries:
1111
if: >
1212
github.event.workflow_run.conclusion == 'success' &&
13-
github.event.workflow_run.head_branch == 'master'
13+
github.event.workflow_run.head_branch == 'master' &&
14+
startsWith(github.event.workflow_run.head_commit.message, 'chore(release)')
1415
runs-on: ubuntu-latest
1516
strategy:
1617
fail-fast: false
@@ -31,6 +32,7 @@ jobs:
3132
with:
3233
repository: ${{ github.event.workflow_run.head_repository.full_name }}
3334
ref: ${{ github.event.workflow_run.head_commit.id }}
35+
fetch-depth: 0
3436

3537
- name: Setup pnpm
3638
uses: pnpm/action-setup@v4
@@ -66,7 +68,8 @@ jobs:
6668
needs: build-binaries
6769
if: >
6870
github.event.workflow_run.conclusion == 'success' &&
69-
github.event.workflow_run.head_branch == 'master'
71+
github.event.workflow_run.head_branch == 'master' &&
72+
startsWith(github.event.workflow_run.head_commit.message, 'chore(release)')
7073
runs-on: ubuntu-latest
7174
permissions:
7275
contents: write
@@ -77,6 +80,7 @@ jobs:
7780
with:
7881
repository: ${{ github.event.workflow_run.head_repository.full_name }}
7982
ref: ${{ github.event.workflow_run.head_commit.id }}
83+
fetch-depth: 0
8084

8185
- name: Setup pnpm
8286
uses: pnpm/action-setup@v4
@@ -102,7 +106,38 @@ jobs:
102106
- name: Build package
103107
run: pnpm run build
104108

105-
- name: Publish to npm
109+
- name: Prepare release assets
110+
run: |
111+
set -eo pipefail
112+
VERSION=$(node -p "require('./package.json').version")
113+
ASSET_DIR="$PWD/release-assets"
114+
mkdir -p "$ASSET_DIR"
115+
while IFS= read -r manifest; do
116+
base=$(basename "$manifest" .json)
117+
src_dir="vendor/lame/$base"
118+
if [ ! -d "$src_dir" ]; then
119+
echo "Skipping $base - no vendor directory"
120+
continue
121+
fi
122+
tmp_dir=$(mktemp -d)
123+
cp "$src_dir"/* "$tmp_dir/"
124+
cp "$manifest" "$tmp_dir/manifest.json"
125+
(cd "$tmp_dir" && zip -qr "$ASSET_DIR/node-lame-v${VERSION}-${base}.zip" .)
126+
rm -rf "$tmp_dir"
127+
done < <(find artifacts -maxdepth 3 -name '*.json')
128+
zip -qr "$ASSET_DIR/node-lame-v${VERSION}-dist.zip" dist
129+
130+
- name: Publish release
106131
env:
107132
NODE_AUTH_TOKEN: ${{ secrets.NPM_TOKEN }}
108-
run: pnpm publish --access public
133+
NPM_TOKEN: ${{ secrets.NPM_TOKEN }}
134+
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
135+
run: pnpm run release:publish
136+
137+
- name: Upload assets to GitHub release
138+
env:
139+
GH_TOKEN: ${{ secrets.GITHUB_TOKEN }}
140+
run: |
141+
VERSION=$(node -p "require('./package.json').version")
142+
TAG="v${VERSION}"
143+
gh release upload "$TAG" release-assets/*.zip --clobber

.husky/commit-msg

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
#!/usr/bin/env sh
2+
. "$(dirname -- "$0")/_/husky.sh"
3+
4+
pnpm commitlint --edit "$1"

.husky/pre-commit

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
#!/usr/bin/env sh
2+
. "$(dirname -- "$0")/_/husky.sh"
3+
4+
pnpm run lint
5+
pnpm run test:unit

CHANGELOG.md

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
## <small>1.5.1 (2025-10-28)</small>
2+
3+
All releases up to this version were created without a changelog. Please refer to the comment messages for details on changes.

commitlint.config.mjs

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
export default {
2+
extends: ['@commitlint/config-conventional']
3+
};

lerna.json

Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,22 @@
1+
{
2+
"$schema": "https://raw.githubusercontent.com/lerna/lerna/main/schemas/lerna-schema.json",
3+
"packages": [
4+
"."
5+
],
6+
"version": "1.5.1",
7+
"npmClient": "pnpm",
8+
"useNx": false,
9+
"command": {
10+
"version": {
11+
"conventionalCommits": true,
12+
"changelogPreset": "conventionalcommits",
13+
"message": "chore(release): publish",
14+
"allowBranch": "master"
15+
},
16+
"publish": {
17+
"conventionalCommits": true,
18+
"changelogPreset": "conventionalcommits",
19+
"createRelease": "github"
20+
}
21+
}
22+
}

package.json

Lines changed: 87 additions & 77 deletions
Original file line numberDiff line numberDiff line change
@@ -1,80 +1,90 @@
11
{
2-
"name": "node-lame",
3-
"version": "1.5.1",
4-
"description": "LAME MP3 encoder for Node.js",
5-
"homepage": "https://github.com/devowlio/node-lame",
6-
"repository": {
7-
"type": "git",
8-
"url": "git+https://github.com/devowlio/node-lame.git"
9-
},
10-
"bugs": {
11-
"url": "https://github.com/devowlio/node-lame/issues"
12-
},
13-
"author": {
14-
"name": "Jan Karres",
15-
"email": "[email protected]",
16-
"url": "https://jankarres.com/"
17-
},
18-
"license": "ISC",
19-
"type": "module",
20-
"packageManager": "[email protected]",
21-
"engines": {
22-
"node": ">=20"
23-
},
24-
"main": "./dist/index.cjs",
25-
"module": "./dist/index.mjs",
26-
"types": "./dist/index.d.ts",
27-
"exports": {
28-
".": {
29-
"types": "./dist/index.d.ts",
30-
"import": "./dist/index.mjs",
31-
"require": "./dist/index.cjs",
32-
"default": "./dist/index.mjs"
33-
}
34-
},
35-
"files": [
36-
"dist/",
37-
"README.md",
38-
"LICENSE"
39-
],
40-
"scripts": {
41-
"build": "tsup",
42-
"clean": "rm -rf dist",
43-
"lint": "eslint . --ext .ts,.mjs",
44-
"format": "prettier --check .",
45-
"typecheck": "tsup --dts-only --silent",
46-
"test": "pnpm run test:unit && pnpm run test:integration",
47-
"test:unit": "vitest run tests/unit --coverage",
48-
"test:integration": "vitest run tests/integration",
49-
"fix": "pnpm exec eslint . --ext .ts,.mjs --fix && pnpm exec prettier --write .",
50-
"postinstall": "node ./scripts/install-lame.mjs",
51-
"prepublishOnly": "pnpm run build"
52-
},
53-
"keywords": [
54-
"mp3",
55-
"wav",
56-
"LAME",
57-
"MPEG-1",
58-
"MPEG-2",
59-
"encoder",
60-
"audio"
61-
],
62-
"dependencies": {
63-
"extract-zip": "~2.0.1",
64-
"tar": "~7.5.1"
65-
},
66-
"devDependencies": {
67-
"@eslint/js": "~9.38.0",
68-
"@types/node": "~20.14.8",
69-
"@typescript-eslint/eslint-plugin": "~8.46.2",
70-
"@typescript-eslint/parser": "~8.46.2",
71-
"@vitest/coverage-istanbul": "~4.0.4",
72-
"eslint": "~9.38.0",
73-
"eslint-config-prettier": "~10.1.8",
74-
"globals": "~16.4.0",
75-
"prettier": "~3.6.2",
76-
"tsup": "~8.5.0",
77-
"typescript": "~5.9.3",
78-
"vitest": "~4.0.4"
2+
"name": "node-lame",
3+
"version": "1.5.1",
4+
"description": "LAME MP3 encoder for Node.js",
5+
"homepage": "https://github.com/devowlio/node-lame",
6+
"repository": {
7+
"type": "git",
8+
"url": "git+https://github.com/devowlio/node-lame.git"
9+
},
10+
"bugs": {
11+
"url": "https://github.com/devowlio/node-lame/issues"
12+
},
13+
"author": {
14+
"name": "Jan Karres",
15+
"email": "[email protected]",
16+
"url": "https://jankarres.com/"
17+
},
18+
"license": "ISC",
19+
"type": "module",
20+
"packageManager": "[email protected]",
21+
"engines": {
22+
"node": ">=20"
23+
},
24+
"main": "./dist/index.cjs",
25+
"module": "./dist/index.mjs",
26+
"types": "./dist/index.d.ts",
27+
"exports": {
28+
".": {
29+
"types": "./dist/index.d.ts",
30+
"import": "./dist/index.mjs",
31+
"require": "./dist/index.cjs",
32+
"default": "./dist/index.mjs"
7933
}
34+
},
35+
"files": [
36+
"dist/",
37+
"README.md",
38+
"LICENSE"
39+
],
40+
"scripts": {
41+
"build": "tsup",
42+
"clean": "rm -rf dist",
43+
"lint": "eslint . --ext .ts,.mjs",
44+
"format": "prettier --check .",
45+
"typecheck": "tsup --dts-only --silent",
46+
"test": "pnpm run test:unit && pnpm run test:integration",
47+
"test:unit": "vitest run tests/unit --coverage",
48+
"test:integration": "vitest run tests/integration",
49+
"fix": "pnpm exec eslint . --ext .ts,.mjs --fix && pnpm exec prettier --write .",
50+
"postinstall": "node ./scripts/install-lame.mjs",
51+
"prepublishOnly": "pnpm run build",
52+
"prepare": "husky",
53+
"changelog": "conventional-changelog -p conventionalcommits -i CHANGELOG.md -s",
54+
"release:version": "HUSKY=0 pnpm lerna version --yes --no-commit-hooks",
55+
"release:publish": "pnpm lerna publish from-git --yes --create-release github",
56+
"release": "pnpm run release:version && pnpm run release:publish"
57+
},
58+
"keywords": [
59+
"mp3",
60+
"wav",
61+
"LAME",
62+
"MPEG-1",
63+
"MPEG-2",
64+
"encoder",
65+
"audio"
66+
],
67+
"dependencies": {
68+
"extract-zip": "~2.0.1",
69+
"tar": "~7.5.1"
70+
},
71+
"devDependencies": {
72+
"@commitlint/cli": "~20.1.0",
73+
"@commitlint/config-conventional": "~20.0.0",
74+
"@eslint/js": "~9.38.0",
75+
"@types/node": "~20.14.8",
76+
"@typescript-eslint/eslint-plugin": "~8.46.2",
77+
"@typescript-eslint/parser": "~8.46.2",
78+
"@vitest/coverage-istanbul": "~4.0.4",
79+
"conventional-changelog-cli": "^5.0.0",
80+
"eslint": "~9.38.0",
81+
"eslint-config-prettier": "~10.1.8",
82+
"globals": "~16.4.0",
83+
"husky": "~9.1.7",
84+
"lerna": "~9.0.0",
85+
"prettier": "~3.6.2",
86+
"tsup": "~8.5.0",
87+
"typescript": "~5.9.3",
88+
"vitest": "~4.0.4"
89+
}
8090
}

0 commit comments

Comments
 (0)