Skip to content

Commit a206bab

Browse files
authored
Devel (#36)
<!-- SPDX-License-Identifier: CC-BY-4.0 OR GPL-3.0-or-later --> <!-- This file is part of Network Pro --> ## Types of changes <!--- What types of changes does your code introduce? Put an `x` in all the boxes that apply: --> - [x] Bug fix (non-breaking change which fixes an issue) - [x] New feature (non-breaking change which adds functionality) - [ ] Breaking change (fix or feature that would cause existing functionality to change) ## Checklist <!--- Go over all the following points, and put an `x` in all the boxes that apply. --> <!--- If you're unsure about any of these, don't hesitate to ask. We're here to help! --> - [x] My code follows the code style of this project. - [ ] My change requires a change to the documentation. - [ ] I have updated the documentation accordingly. - [x] I have read the **[CONTRIBUTING](https://github.com/netwk-pro/netwk-pro.github.io/blob/master/.github/CONTRIBUTING.md)** document. - [x] I have added tests to cover my changes. - [x] All new and existing tests passed. Pull requests should be thought of as a conversation. There will be some back and forth when trying to get code merged into this or any other project. With all but the simplest changes you can and should expect that the maintainers of the project will request changes to your code. Please be aware of that and check in after you open your PR in order to get your code merged in cleanly. Thank you!
2 parents 1a84fed + 898f763 commit a206bab

28 files changed

+801
-166
lines changed

.github/workflows/webpack-gpr.yml

+201
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,201 @@
1+
# SPDX-License-Identifier: CC-BY-4.0 OR GPL-3.0-or-later
2+
# This file is part of Network Pro
3+
#
4+
# When a release is created or this workflow is manually triggered, it will:
5+
# (1) confirm the CodeQL analysis was successful, (2) test JavaScript using
6+
# Mocha and Chai frameworks, (3) check linting with ESLint and formatting with
7+
# Prettier without making changes, (4) build the project using node 22.x on
8+
# ubuntu-24.04, and (5) publish the package to the npmjs and GPR registries.
9+
#
10+
# The workflow to upload static content to GitHub Pages (upload.yml) will
11+
# kick off following successful completion of this workflow.
12+
#
13+
# If needed, the upload-force.yml file can be manually triggered to force an
14+
# upload of static content from ./dist to GitHub Pages.
15+
#
16+
# For more information see: https://docs.github.com/en/actions/publishing-packages/publishing-nodejs-packages
17+
18+
name: Build/Test, Publish to Registries
19+
20+
on:
21+
release:
22+
types: [created]
23+
workflow_dispatch:
24+
25+
jobs:
26+
check-codeql:
27+
name: Check CodeQL Analysis
28+
runs-on: ubuntu-24.04
29+
# Continue workflow even if this job fails due to inability to find and/or check CodeQL workflow
30+
continue-on-error: true
31+
steps:
32+
- name: Checkout repository
33+
uses: actions/[email protected]
34+
35+
- name: Set up GitHub CLI
36+
run: sudo apt-get install gh
37+
38+
- name: Authenticate GitHub CLI
39+
env:
40+
GH_PAT: ${{ secrets.GH_PAT }}
41+
run: echo "${{ secrets.GH_PAT }}" | gh auth login --with-token
42+
43+
- name: Check CodeQL Workflow
44+
env:
45+
GH_PAT: ${{ secrets.GH_PAT }}
46+
run: |
47+
gh run list --workflow "CodeQL" --json conclusion --jq '.[0].conclusion' > codeql_status.txt
48+
CODEQL_STATUS=$(cat codeql_status.txt)
49+
if [[ "$CODEQL_STATUS" != "success" ]]; then
50+
echo "CodeQL Analysis did not succeed. Exiting..."
51+
exit 1
52+
fi
53+
rm codeql_status.txt
54+
55+
build:
56+
needs: check-codeql
57+
runs-on: ubuntu-24.04
58+
steps:
59+
- name: Checkout repository
60+
uses: actions/[email protected]
61+
62+
- name: Set up Node.js
63+
uses: actions/[email protected]
64+
with:
65+
node-version: 22.x
66+
67+
- name: Cache Node.js modules
68+
uses: actions/[email protected]
69+
with:
70+
path: ~/.npm
71+
key: ${{ runner.os }}-node-22.x-build-${{ hashFiles('package-lock.json') }}
72+
restore-keys: |
73+
${{ runner.os }}-node-22.x-build-
74+
${{ runner.os }}-node-22.x-
75+
${{ runner.os }}-node-
76+
77+
- name: Install dependencies
78+
run: npm ci
79+
80+
- name: Run tests using Mocha and Chai frameworks
81+
run: npm run test
82+
continue-on-error: true
83+
84+
- name: Check linting and formatting
85+
run: npm run lint
86+
continue-on-error: true
87+
88+
- name: Build project
89+
run: npm run build
90+
91+
- name: Ensure dist directory exists
92+
run: mkdir -p dist
93+
94+
- name: Copy package.json to dist directory
95+
run: cp package.json dist/
96+
97+
publish-npm:
98+
needs: [check-codeql, build]
99+
runs-on: ubuntu-24.04
100+
permissions:
101+
contents: read
102+
packages: write
103+
steps:
104+
- name: Set up .npmrc file for npmjs
105+
run: |
106+
echo "@neteng-pro:registry=https://registry.npmjs.org/" > ~/.npmrc
107+
echo "//registry.npmjs.org/:_authToken=${{ secrets.NPM_TOKEN }}" >> ~/.npmrc
108+
109+
- name: Login to npmjs registry
110+
run: npm login --registry=https://registry.npmjs.org/ --scope=@neteng-pro --always-auth --username "sundevil311" --authToken ${{secrets.NPM_TOKEN }}
111+
112+
- name: Checkout repository
113+
uses: actions/[email protected]
114+
115+
- name: Set up Node.js
116+
uses: actions/[email protected]
117+
with:
118+
node-version: 22.x
119+
registry-url: https://registry.npmjs.org/
120+
121+
- name: Cache Node.js modules
122+
uses: actions/[email protected]
123+
with:
124+
path: ~/.npm
125+
key: ${{ runner.os }}-node-22.x-publish-${{ hashFiles('package-lock.json') }}
126+
restore-keys: |
127+
${{ runner.os }}-node-22.x-publish-
128+
${{ runner.os }}-node-22.x-
129+
${{ runner.os }}-node-
130+
131+
- name: Install dependencies
132+
run: npm ci
133+
134+
- name: Set up Git user
135+
run: |
136+
git config --global user.email "[email protected]"
137+
git config --global user.name "SunDevil311"
138+
139+
- name: Ensure dist directory exists
140+
run: mkdir -p dist
141+
142+
- name: Copy package.json to dist directory
143+
run: cp package.json dist/
144+
145+
- name: Update package name for GPR
146+
run: |
147+
sed -i 's/"name": ".*"/"name": "@neteng-pro\/netwk-pro-web"/' dist/package.json
148+
149+
- name: Publish package
150+
working-directory: ./dist
151+
run: npm publish --access public
152+
env:
153+
NODE_AUTH_TOKEN: ${{ secrets.NPM_TOKEN }}
154+
155+
publish-gpr:
156+
needs: [check-codeql, build]
157+
runs-on: ubuntu-24.04
158+
# Complete workflow even if this job fails
159+
continue-on-error: true
160+
permissions:
161+
contents: read
162+
packages: write
163+
steps:
164+
- name: Checkout repository
165+
uses: actions/[email protected]
166+
167+
- name: Set up Node.js
168+
uses: actions/[email protected]
169+
with:
170+
node-version: 22.x
171+
registry-url: https://npm.pkg.github.com/
172+
173+
- name: Cache Node.js modules
174+
uses: actions/[email protected]
175+
with:
176+
path: ~/.npm
177+
key: ${{ runner.os }}-node-22.x-publish-${{ hashFiles('package-lock.json') }}
178+
restore-keys: |
179+
${{ runner.os }}-node-22.x-publish-
180+
${{ runner.os }}-node-22.x-
181+
${{ runner.os }}-node-
182+
183+
- name: Install dependencies
184+
run: npm ci
185+
186+
- name: Set up Git user
187+
run: |
188+
git config --global user.email "[email protected]"
189+
git config --global user.name "SunDevil311"
190+
191+
- name: Ensure dist directory exists
192+
run: mkdir -p dist
193+
194+
- name: Copy package.json to dist directory
195+
run: cp package.json dist/
196+
197+
- name: Publish package
198+
working-directory: ./dist
199+
run: npm publish
200+
env:
201+
NODE_AUTH_TOKEN: ${{ secrets.GH_PAT }}

0 commit comments

Comments
 (0)