-
Notifications
You must be signed in to change notification settings - Fork 0
218 lines (174 loc) · 6.02 KB
/
publish-test.yml
File metadata and controls
218 lines (174 loc) · 6.02 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
# .github/workflows/publish-test.yml
#
# Copyright © 2025 Network Pro Strategies (Network Pro™)
# SPDX-License-Identifier: CC-BY-4.0 OR GPL-3.0-or-later
# This file is part of Network Pro
name: Test Publishing to Registries
on:
workflow_dispatch:
# Allow one concurrent deployment
concurrency:
group: 'build-and-publish'
cancel-in-progress: true
permissions:
actions: read
contents: read
jobs:
check-codeql:
uses: ./.github/workflows/check-codeql.yml
build:
needs: check-codeql
runs-on: ubuntu-24.04
env:
ENV_MODE: ci
steps:
- name: Checkout repository
uses: actions/checkout@v4
- name: Set up Node.js
uses: actions/setup-node@v4
with:
node-version: 24
cache: npm
cache-dependency-path: package-lock.json
- name: Show Node.js and npm versions
run: |
echo "Node.js version: $(node -v)"
echo "npm version: $(npm -v)"
- name: Upgrade npm
run: |
corepack enable
npm install -g npm@11.6.0
- name: Install Node.js dependencies
run: npm ci
- name: Install jq
run: sudo apt-get install -y jq
- name: Run JSDoc lint check
id: jsdoc_lint
continue-on-error: true
run: |
set -e
output=$(npm run lint:jsdoc || true)
echo "$output" | tee jsdoc-lint-output.txt
count=$(echo "$output" | wc -l)
echo "jsdoc_count=$count" >> "$GITHUB_OUTPUT"
- name: ✅ Pass
if: steps.jsdoc_lint.outputs.jsdoc_count == '0'
run: echo "JSDoc lint passed successfully!"
- name: ⚠️ JSDoc violations detected (non-blocking)
if: steps.jsdoc_lint.outputs.jsdoc_count != '0'
run: |
echo "⚠️ JSDoc lint check failed with ${{ steps.jsdoc_lint.outputs.jsdoc_count }} violations (non-blocking)"
echo "--- JSDoc Violations ---"
cat jsdoc-lint-output.txt
# Test to ensure the package is working
- name: Build Node.js project
run: npm run build
# Create Git archive of version-controlled files
- name: Create clean source archive
run: git archive --format=tar.gz --output=clean-source.tar.gz HEAD
- name: Upload source archive
uses: actions/upload-artifact@v4
with:
name: clean-source
path: clean-source.tar.gz
publish-npmjs:
needs: build
runs-on: ubuntu-24.04
env:
ENV_MODE: ci
steps:
- name: Download clean source archive
uses: actions/download-artifact@v4
with:
name: clean-source
path: ./
- name: Extract source archive
run: tar -xzf clean-source.tar.gz
- name: Remove extracted source archive
run: rm clean-source.tar.gz
- name: Set up Node.js for npmjs
uses: actions/setup-node@v4
with:
node-version: 24
registry-url: https://registry.npmjs.org/
cache: npm
cache-dependency-path: package-lock.json
- name: Show Node.js and npm versions
run: |
echo "Node.js version: $(node -v)"
echo "npm version: $(npm -v)"
- name: Upgrade npm
run: |
corepack enable
npm install -g npm@11.6.0
- name: Install Node.js dependencies
run: npm ci
- name: Set up Git user
run: |
git config --global user.email "github@sl.neteng.cc"
git config --global user.name "SunDevil311"
- name: Verify version not already published
run: |
PACKAGE_NAME=$(node -p "require('./package.json').name")
PACKAGE_VERSION=$(node -p "require('./package.json').version")
echo "Checking if $PACKAGE_NAME@$PACKAGE_VERSION is already published..."
npm view $PACKAGE_NAME@$PACKAGE_VERSION > /dev/null && {
echo "❌ Version $PACKAGE_VERSION already exists on npm. Exiting..."
exit 1
} || echo "✅ Version is new. Proceeding with publish."
- name: Simulate publish package to npmjs
run: npm publish --dry-run
env:
NODE_AUTH_TOKEN: ${{ secrets.NPM_NETPRO }}
publish-gpr:
needs: build
runs-on: ubuntu-24.04
env:
ENV_MODE: ci
steps:
- name: Download clean source archive
uses: actions/download-artifact@v4
with:
name: clean-source
path: ./
- name: Extract source archive
run: tar -xzf clean-source.tar.gz
- name: Remove extracted source archive
run: rm clean-source.tar.gz
- name: Set up Node.js for GPR
uses: actions/setup-node@v4
with:
node-version: 24
registry-url: https://npm.pkg.github.com/
cache: npm
cache-dependency-path: package-lock.json
- name: Show Node.js and npm versions
run: |
echo "Node.js version: $(node -v)"
echo "npm version: $(npm -v)"
- name: Upgrade npm
run: |
corepack enable
npm install -g npm@11.6.0
- name: Install Node.js dependencies
run: npm ci
- name: Set up Git user
run: |
git config --global user.email "github@sl.neteng.cc"
git config --global user.name "SunDevil311"
- name: Update package name for GPR
run: |
sed -i 's/"name": ".*"/"name": "@netwk-pro\/web"/' package.json
- name: Verify version not already published
run: |
PACKAGE_NAME=$(node -p "require('./package.json').name")
PACKAGE_VERSION=$(node -p "require('./package.json').version")
echo "Checking if $PACKAGE_NAME@$PACKAGE_VERSION is already published..."
npm view $PACKAGE_NAME@$PACKAGE_VERSION > /dev/null && {
echo "❌ Version $PACKAGE_VERSION already exists on npm. Exiting..."
exit 1
} || echo "✅ Version is new. Proceeding with publish."
- name: Simulate publish package to GPR
run: npm publish --dry-run
env:
NODE_AUTH_TOKEN: ${{ secrets.NWPRO_GPR }}