Skip to content

Commit 7ed9271

Browse files
committed
Add release GitHub Action
1 parent f193b3d commit 7ed9271

File tree

5 files changed

+82
-8
lines changed

5 files changed

+82
-8
lines changed

.github/workflows/release.yml

Lines changed: 45 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,45 @@
1+
name: Release
2+
3+
on:
4+
workflow_dispatch:
5+
inputs:
6+
tag:
7+
description: 'Release tag (x.x.x)'
8+
required: true
9+
10+
env:
11+
HUSKY: 0
12+
13+
jobs:
14+
release:
15+
timeout-minutes: 60
16+
runs-on: ubuntu-latest
17+
steps:
18+
- uses: actions/checkout@v4
19+
- uses: actions/setup-node@v4
20+
with:
21+
node-version-file: '.nvmrc'
22+
- name: Setup pnpm
23+
uses: pnpm/action-setup@v4
24+
with:
25+
version: latest
26+
run_install: true
27+
- name: Update all package.json versions
28+
run: |
29+
node scripts/update_version.js ${{ inputs.tag }}
30+
- name: Commit and push version changes
31+
run: |
32+
git config --global user.name "github-actions[bot]"
33+
git config --global user.email "github-actions[bot]@users.noreply.github.com"
34+
35+
git add package.json
36+
git commit -m "chore: release ${{ inputs.tag }}"
37+
git push
38+
- name: Build
39+
run: pnpm run build
40+
- name: Create GitHub release
41+
uses: softprops/action-gh-release@v2
42+
with:
43+
tag_name: ${{ inputs.tag }}
44+
files: dist/*
45+
generate_release_notes: true

eslint.config.mjs

Lines changed: 11 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -22,14 +22,6 @@ export default tsEslint.config(
2222
files: ['**/*.js'],
2323
...tsEslint.configs.disableTypeChecked,
2424
},
25-
{
26-
files: ['scripts/*.js', '**/*.config.mjs'],
27-
languageOptions: {
28-
globals: {
29-
...globals.nodeBuiltin,
30-
},
31-
},
32-
},
3325
{
3426
rules: {
3527
semi: 'error',
@@ -71,4 +63,15 @@ export default tsEslint.config(
7163
'no-console': ['warn'],
7264
},
7365
},
66+
{
67+
files: ['scripts/*.js', '**/*.config.mjs'],
68+
languageOptions: {
69+
globals: {
70+
...globals.nodeBuiltin,
71+
},
72+
},
73+
rules: {
74+
'no-console': 'off',
75+
},
76+
},
7477
);

package.json

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -25,6 +25,7 @@
2525
"@types/jest": "^28.1.8",
2626
"@types/jquery": "^3.5.32",
2727
"eslint": "^9.17.0",
28+
"fast-glob": "^3.3.3",
2829
"globals": "^15.14.0",
2930
"husky": "^9.1.7",
3031
"jest": "^29.7.0",

pnpm-lock.yaml

Lines changed: 3 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

scripts/update_version.js

Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,22 @@
1+
// @ts-check
2+
import { readFile, writeFile } from 'fs/promises';
3+
import fg from 'fast-glob';
4+
5+
const NEW_VERSION = process.argv[2];
6+
if (!NEW_VERSION) {
7+
console.error('Error: no version provided!');
8+
process.exit(1);
9+
}
10+
11+
const packageJsonPaths = await fg(['package.json'], { onlyFiles: true });
12+
13+
for (const filePath of packageJsonPaths) {
14+
try {
15+
const packageJson = JSON.parse(await readFile(filePath, 'utf8'));
16+
packageJson.version = NEW_VERSION;
17+
18+
await writeFile(filePath, `${JSON.stringify(packageJson, null, 2)}\n`, 'utf8');
19+
} catch (error) {
20+
console.error(`Error updating ${filePath}: ${error}`);
21+
}
22+
}

0 commit comments

Comments
 (0)