Skip to content

Commit 47c3a97

Browse files
committed
wire up CI, release and dependabot workflows
based on the layout used in nerjs/batchloader and nerjs/nlogs, adapted to the fact this repo ships a GitHub Action (not an npm package). - ci.yml runs lint/tests on node 20/22/24 and a separate check-dist job that rebuilds dist/ and fails when it diverges from what is committed. - bump-version.yml triggers a manual semver bump. the new "version" script in package.json runs npm run build and stages dist/, so the bump commit carries a fresh bundle atomically. - create-release.yml runs on v* tags: re-verifies lint/tests/dist, then creates a GitHub Release and force-updates the major alias tag (v0 for v0.x.y, v1 for v1.x.y, etc) - the convention marketplace consumers rely on. - sync-dependencies.yml fast-forwards the dependencies branch with master after each merge, opening a PR on conflict. - dependabot.yml: target-branch dependencies, groups rewritten around the actual deps of this repo (@actions/*, js-yaml, ncc, typescript, eslint, jest).
1 parent e9fd593 commit 47c3a97

6 files changed

Lines changed: 300 additions & 20 deletions

File tree

.github/dependabot.yml

Lines changed: 57 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -1,26 +1,64 @@
11
version: 2
22
updates:
3-
- package-ecosystem: github-actions
4-
directory: /
3+
- package-ecosystem: "npm"
4+
directory: "/"
55
schedule:
6-
interval: weekly
6+
interval: "weekly"
7+
time: "17:00"
8+
assignees:
9+
- "nerjs"
10+
labels:
11+
- "dependencies"
12+
- "bot"
13+
target-branch: "dependencies"
14+
open-pull-requests-limit: 5
715
groups:
8-
actions-minor:
9-
update-types:
10-
- minor
11-
- patch
16+
actions-toolkit:
17+
patterns:
18+
- "@actions/*"
1219

13-
- package-ecosystem: npm
14-
directory: /
20+
yaml:
21+
patterns:
22+
- "js-yaml"
23+
- "@types/js-yaml"
24+
25+
typescript:
26+
patterns:
27+
- "typescript"
28+
- "@types/node"
29+
30+
eslint:
31+
patterns:
32+
- "eslint"
33+
- "@typescript-eslint/*"
34+
- "eslint-config-prettier"
35+
- "eslint-plugin-prettier"
36+
- "prettier"
37+
38+
jest:
39+
patterns:
40+
- "jest"
41+
- "ts-jest"
42+
- "@types/jest"
43+
44+
ncc:
45+
patterns:
46+
- "@vercel/ncc"
47+
48+
- package-ecosystem: "github-actions"
49+
directory: "/"
1550
schedule:
16-
interval: weekly
51+
interval: "weekly"
52+
time: "17:00"
53+
assignees:
54+
- "nerjs"
55+
labels:
56+
- "dependencies"
57+
- "bot"
58+
- "github-actions"
59+
target-branch: "dependencies"
60+
open-pull-requests-limit: 5
1761
groups:
18-
npm-development:
19-
dependency-type: development
20-
update-types:
21-
- minor
22-
- patch
23-
npm-production:
24-
dependency-type: production
25-
update-types:
26-
- patch
62+
actions:
63+
patterns:
64+
- "*"

.github/workflows/bump-version.yml

Lines changed: 43 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,43 @@
1+
name: Bump version
2+
3+
on:
4+
workflow_dispatch:
5+
inputs:
6+
version:
7+
description: 'Semver type of new version (major / minor / patch)'
8+
required: true
9+
type: choice
10+
options:
11+
- patch
12+
- minor
13+
- major
14+
15+
jobs:
16+
bump-version:
17+
runs-on: ubuntu-latest
18+
19+
steps:
20+
- name: Checkout repository
21+
uses: actions/checkout@v6
22+
with:
23+
token: ${{ secrets.PUBLISH_TOKEN }}
24+
25+
- name: Setup Node.js
26+
uses: actions/setup-node@v6
27+
with:
28+
node-version: 22
29+
cache: 'npm'
30+
31+
- name: Install dependencies
32+
run: npm ci
33+
34+
- name: Setup Git
35+
run: |
36+
git config user.name 'nerjs'
37+
git config user.email 'nerjs.stap@gmail.com'
38+
39+
- name: Bump version (runs build via npm "version" script)
40+
run: npm version ${{ github.event.inputs.version }}
41+
42+
- name: Push latest version
43+
run: git push origin master --follow-tags

.github/workflows/ci.yml

Lines changed: 69 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,69 @@
1+
name: "CI: tests, linter and check-dist"
2+
3+
on:
4+
workflow_dispatch:
5+
push:
6+
branches:
7+
- master
8+
- dependencies
9+
- 'dependencies-**'
10+
pull_request:
11+
branches:
12+
- master
13+
- dependencies
14+
15+
jobs:
16+
test:
17+
if: ${{ !contains(github.event.head_commit.message || github.event.pull_request.title || '', '[skip-CI]') }}
18+
runs-on: ubuntu-latest
19+
strategy:
20+
fail-fast: false
21+
matrix:
22+
node-version: [20, 22, 24]
23+
name: "test (node:${{ matrix.node-version }})"
24+
steps:
25+
- name: Checkout repository
26+
uses: actions/checkout@v6
27+
28+
- name: Setup Node.js ${{ matrix.node-version }}
29+
uses: actions/setup-node@v6
30+
with:
31+
node-version: ${{ matrix.node-version }}
32+
cache: 'npm'
33+
34+
- name: Install dependencies
35+
run: npm ci
36+
37+
- name: Run linter
38+
run: npm run lint
39+
40+
- name: Run tests
41+
run: npm test -- --ci --coverage --runInBand --coverageReporters=text
42+
43+
check-dist:
44+
if: ${{ !contains(github.event.head_commit.message || github.event.pull_request.title || '', '[skip-CI]') }}
45+
runs-on: ubuntu-latest
46+
name: check-dist
47+
steps:
48+
- name: Checkout repository
49+
uses: actions/checkout@v6
50+
51+
- name: Setup Node.js
52+
uses: actions/setup-node@v6
53+
with:
54+
node-version: 22
55+
cache: 'npm'
56+
57+
- name: Install dependencies
58+
run: npm ci
59+
60+
- name: Build dist
61+
run: npm run build
62+
63+
- name: Verify dist is up to date
64+
run: |
65+
if ! git diff --quiet --exit-code dist/; then
66+
echo "::error::dist/ is out of sync with src/. Run 'npm run build' locally and commit the dist/ directory."
67+
git --no-pager diff dist/ | head -200
68+
exit 1
69+
fi
Lines changed: 74 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,74 @@
1+
name: Create Release
2+
3+
on:
4+
push:
5+
tags:
6+
- 'v*'
7+
8+
jobs:
9+
lint-tests-and-dist:
10+
name: Verify lint, tests and dist
11+
runs-on: ubuntu-latest
12+
steps:
13+
- name: Checkout repository
14+
uses: actions/checkout@v6
15+
16+
- name: Setup Node.js
17+
uses: actions/setup-node@v6
18+
with:
19+
node-version: 22
20+
cache: 'npm'
21+
22+
- name: Install dependencies
23+
run: npm ci
24+
25+
- name: Run linter
26+
run: npm run lint
27+
28+
- name: Run tests
29+
run: npm test -- --ci
30+
31+
- name: Build dist
32+
run: npm run build
33+
34+
- name: Verify dist is up to date
35+
run: |
36+
if ! git diff --quiet --exit-code dist/; then
37+
echo "::error::Tagged commit has stale dist/. Re-run bump-version or rebuild and re-tag."
38+
exit 1
39+
fi
40+
41+
create-github-release:
42+
name: Create GitHub Release and update major alias
43+
runs-on: ubuntu-latest
44+
needs: lint-tests-and-dist
45+
permissions:
46+
contents: write
47+
steps:
48+
- name: Checkout repository
49+
uses: actions/checkout@v6
50+
with:
51+
token: ${{ secrets.PUBLISH_TOKEN }}
52+
fetch-depth: 0
53+
54+
- name: Configure git
55+
run: |
56+
git config user.name "github-actions[bot]"
57+
git config user.email "github-actions[bot]@users.noreply.github.com"
58+
59+
- name: Update major version alias
60+
run: |
61+
tag="${GITHUB_REF_NAME}"
62+
major=$(echo "$tag" | sed -E 's/^(v[0-9]+).*/\1/')
63+
if [ -z "$major" ] || [ "$major" = "$tag" ]; then
64+
echo "Could not derive major alias from tag '$tag', skipping."
65+
exit 0
66+
fi
67+
git tag -f "$major" "$tag"
68+
git push origin "$major" --force
69+
echo "Moved $major to $tag"
70+
71+
- name: Create GitHub Release
72+
run: gh release create "${GITHUB_REF_NAME}" --generate-notes
73+
env:
74+
GITHUB_TOKEN: ${{ secrets.PUBLISH_TOKEN }}
Lines changed: 55 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,55 @@
1+
name: "SYNC: dependencies with master"
2+
3+
on:
4+
push:
5+
branches:
6+
- master
7+
8+
permissions:
9+
contents: write
10+
pull-requests: write
11+
12+
jobs:
13+
sync:
14+
runs-on: ubuntu-latest
15+
steps:
16+
- name: Check out dependencies
17+
uses: actions/checkout@v6
18+
with:
19+
ref: dependencies
20+
fetch-depth: 0
21+
token: ${{ secrets.PUBLISH_TOKEN }}
22+
23+
- name: Configure git
24+
run: |
25+
git config user.name "github-actions[bot]"
26+
git config user.email "github-actions[bot]@users.noreply.github.com"
27+
28+
- name: Try merge master
29+
id: merge
30+
run: |
31+
git fetch origin master
32+
if git merge origin/master -m "Sync master to dependencies [skip-CI]"; then
33+
echo "result=success" >> $GITHUB_OUTPUT
34+
else
35+
git merge --abort
36+
echo "result=conflict" >> $GITHUB_OUTPUT
37+
fi
38+
39+
- name: Push if no conflicts
40+
if: steps.merge.outputs.result == 'success'
41+
run: git push origin dependencies
42+
43+
- name: Create PR if conflicts
44+
if: steps.merge.outputs.result == 'conflict'
45+
env:
46+
GH_TOKEN: ${{ secrets.PUBLISH_TOKEN }}
47+
run: |
48+
existing=$(gh pr list --base dependencies --head master --json number --jq '.[0].number')
49+
if [ -n "$existing" ]; then
50+
echo "Sync PR #$existing already exists"
51+
else
52+
gh pr create --base dependencies --head master \
53+
--title "Sync: merge master into dependencies (conflicts)" \
54+
--body "Merge conflicts. Resolve manually."
55+
fi

package.json

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -31,7 +31,8 @@
3131
"lint": "eslint .",
3232
"package": "ncc build src/index.ts --license licenses.txt",
3333
"clean": "rimraf dist/",
34-
"build": "npm run clean && npm run package"
34+
"build": "npm run clean && npm run package",
35+
"version": "npm run build && git add -A dist"
3536
},
3637
"license": "MIT",
3738
"dependencies": {

0 commit comments

Comments
 (0)