Skip to content

Commit 2fc6a86

Browse files
feat(workflows): Add Node CI and NPM workflows (#551)
1 parent 5d4f0f3 commit 2fc6a86

5 files changed

Lines changed: 248 additions & 0 deletions

File tree

Lines changed: 112 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,112 @@
1+
---
2+
# This workflow is intended to work with all our organization Node projects.
3+
4+
# This workflow will run tests using node and then create a draft release on GitHub for push events to master.
5+
6+
name: CI-Node (called)
7+
permissions:
8+
contents: read
9+
10+
on:
11+
workflow_call:
12+
secrets:
13+
CODECOV_TOKEN:
14+
description: 'Codecov token to use for the workflow.'
15+
required: false
16+
GH_BOT_TOKEN:
17+
description: 'GitHub bot token to use for the workflow.'
18+
required: false
19+
20+
jobs:
21+
setup_release:
22+
name: Setup Release
23+
outputs:
24+
publish_release: ${{ steps.setup_release.outputs.publish_release }}
25+
release_body: ${{ steps.setup_release.outputs.release_body }}
26+
release_generate_release_notes: ${{ steps.setup_release.outputs.release_generate_release_notes }}
27+
release_tag: ${{ steps.setup_release.outputs.release_tag }}
28+
permissions:
29+
contents: write
30+
runs-on: ubuntu-latest
31+
steps:
32+
- name: Checkout
33+
uses: actions/checkout@v5
34+
35+
- name: Setup Release
36+
id: setup_release
37+
uses: LizardByte/actions/actions/release_setup@v2025.1011.184228
38+
with:
39+
github_token: ${{ secrets.GITHUB_TOKEN }}
40+
41+
build:
42+
runs-on: ubuntu-latest
43+
steps:
44+
- name: Checkout
45+
uses: actions/checkout@v5
46+
47+
- name: Setup node
48+
uses: actions/setup-node@v6
49+
with:
50+
node-version: latest
51+
52+
- name: Install dependencies
53+
run: npm install
54+
55+
- name: Test
56+
id: test
57+
env:
58+
FORCE_COLOR: true
59+
run: npm test
60+
61+
- name: Build
62+
env:
63+
CODECOV_TOKEN: ${{ secrets.CODECOV_TOKEN }}
64+
run: npm run build
65+
66+
- name: Upload test results to Codecov
67+
# any except canceled or skipped
68+
if: >-
69+
always() &&
70+
(steps.test.outcome == 'success' || steps.test.outcome == 'failure') &&
71+
startsWith(github.repository, 'LizardByte/')
72+
uses: codecov/test-results-action@47f89e9acb64b76debcd5ea40642d25a4adced9f # v1.1.1
73+
with:
74+
fail_ci_if_error: true
75+
files: ./junit.xml,!./cache
76+
token: ${{ secrets.CODECOV_TOKEN }}
77+
verbose: true
78+
79+
- name: Upload test coverage to Codecov
80+
# any except canceled or skipped
81+
if: >-
82+
always() &&
83+
(steps.test.outcome == 'success' || steps.test.outcome == 'failure') &&
84+
startsWith(github.repository, 'LizardByte/')
85+
uses: codecov/codecov-action@5a1091511ad55cbe89839c7260b706298ca349f7 # v5.5.1
86+
with:
87+
disable_search: true
88+
fail_ci_if_error: true
89+
files: ./coverage/coverage-final.json
90+
token: ${{ secrets.CODECOV_TOKEN }}
91+
verbose: true
92+
93+
release:
94+
if: needs.setup_release.outputs.publish_release == 'true'
95+
needs:
96+
- setup_release
97+
- build
98+
runs-on: ubuntu-latest
99+
steps:
100+
- name: Create Release
101+
id: action
102+
uses: LizardByte/actions/actions/release_create@v2025.1011.184228
103+
with:
104+
allowUpdates: false
105+
artifacts: ''
106+
body: ${{ needs.setup_release.outputs.release_body }}
107+
draft: true
108+
generateReleaseNotes: ${{ needs.setup_release.outputs.release_generate_release_notes }}
109+
name: ${{ needs.setup_release.outputs.release_tag }}
110+
prerelease: true
111+
tag: ${{ needs.setup_release.outputs.release_tag }}
112+
token: ${{ secrets.GH_BOT_TOKEN }}
Lines changed: 56 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,56 @@
1+
---
2+
name: Update NPM (called)
3+
permissions:
4+
contents: read
5+
id-token: write # required for provenance and OIDC
6+
packages: write
7+
8+
on:
9+
workflow_call:
10+
inputs:
11+
release_version:
12+
description: 'Version to publish (v prefix will be stripped automatically).'
13+
required: true
14+
type: string
15+
16+
jobs:
17+
publish-npm:
18+
runs-on: ubuntu-latest
19+
strategy:
20+
fail-fast: false
21+
matrix:
22+
include:
23+
- registry-url: "https://npm.pkg.github.com"
24+
extra-args: ""
25+
- registry-url: "https://registry.npmjs.org"
26+
extra-args: "--provenance --access public"
27+
steps:
28+
- name: Checkout
29+
uses: actions/checkout@v5
30+
31+
- name: Setup node
32+
uses: actions/setup-node@v6
33+
with:
34+
node-version: latest
35+
registry-url: ${{ matrix.registry-url }}
36+
scope: '@lizardbyte'
37+
38+
- name: Strip version prefix
39+
id: version
40+
env:
41+
INPUT_RELEASE_VERSION: ${{ inputs.release_version }}
42+
run: echo "version=${INPUT_RELEASE_VERSION#v}" >> "${GITHUB_OUTPUT}"
43+
44+
- name: Update package.json
45+
env:
46+
RELEASE_VERSION: ${{ steps.version.outputs.version }}
47+
run: npm version "${RELEASE_VERSION}" --no-git-tag-version
48+
49+
- name: Install dependencies
50+
run: npm install
51+
52+
- name: Build
53+
run: npm run build
54+
55+
- name: Publish
56+
run: npm publish ${{ matrix.extra-args }}

.github/workflows/__global-replicator.yml

Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -211,6 +211,27 @@ jobs:
211211
- name: Checkout repository
212212
uses: actions/checkout@v5
213213

214+
- name: Replicating files (node)
215+
uses: derberg/manage-files-in-multiple-repositories@v2.1.0
216+
with:
217+
bot_branch_name: ${{ env.BOT_BRANCH_NAME }}
218+
commit_message: ${{ env.COMMIT_MESSAGE }}
219+
exclude_private: ${{ env.EXCLUDE_PRIVATE }}
220+
repos_to_ignore: ${{ env.REPOS_TO_IGNORE }}
221+
github_token: ${{ secrets.GH_BOT_TOKEN }}
222+
committer_username: ${{ secrets.GH_BOT_NAME }}
223+
committer_email: ${{ secrets.GH_BOT_EMAIL }}
224+
patterns_to_ignore: ''
225+
patterns_to_include: >-
226+
.github/workflows/_ci_node.yml,
227+
.github/workflows/_update-npm.yml
228+
topics_to_include: 'npm-pkg'
229+
exclude_forked: false
230+
destination: ''
231+
232+
- name: Checkout repository
233+
uses: actions/checkout@v5
234+
214235
- name: Replicating files (python)
215236
uses: derberg/manage-files-in-multiple-repositories@v2.1.0
216237
with:

.github/workflows/_ci-node.yml

Lines changed: 28 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,28 @@
1+
---
2+
# This workflow is centrally managed in https://github.com/LizardByte/.github/
3+
# Don't make changes to this file in this repo as they will be overwritten with changes made to the same file in
4+
# the above-mentioned repo.
5+
6+
name: CI-Node
7+
permissions:
8+
contents: read
9+
10+
on:
11+
push:
12+
branches:
13+
- master
14+
pull_request:
15+
branches:
16+
- master
17+
18+
concurrency:
19+
group: "${{ github.workflow }}-${{ github.ref }}"
20+
cancel-in-progress: true
21+
22+
jobs:
23+
call-ci-node:
24+
name: CI-Node
25+
uses: LizardByte/.github/.github/workflows/__call-ci-node.yml@master
26+
if: ${{ github.repository != 'LizardByte/.github' }}
27+
secrets:
28+
CODECOV_TOKEN: ${{ secrets.CODECOV_TOKEN }}

.github/workflows/_update-npm.yml

Lines changed: 31 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,31 @@
1+
---
2+
# This workflow is centrally managed in https://github.com/LizardByte/.github/
3+
# Don't make changes to this file in this repo as they will be overwritten with changes made to the same file in
4+
# the above-mentioned repo.
5+
6+
# To use, add the `npm-pkg` repository label to identify repositories that should trigger this workflow.
7+
8+
# Update NPM packages on release events.
9+
10+
name: Update NPM
11+
permissions:
12+
contents: read
13+
id-token: write # required for provenance and OIDC
14+
packages: write
15+
16+
on:
17+
release:
18+
types:
19+
- released
20+
21+
concurrency:
22+
group: "${{ github.workflow }}-${{ github.event.release.tag_name }}"
23+
cancel-in-progress: true
24+
25+
jobs:
26+
update-npm:
27+
name: Update NPM
28+
uses: LizardByte/.github/.github/workflows/__call-update-npm.yml@master
29+
if: github.repository_owner == 'LizardByte'
30+
with:
31+
release_version: ${{ github.event.release.tag_name }}

0 commit comments

Comments
 (0)