Skip to content

Commit 15ed7f9

Browse files
committed
Refactor CI/CD workflow and package.json for improved GitHub Packages publishing
1 parent c7da696 commit 15ed7f9

File tree

2 files changed

+44
-50
lines changed

2 files changed

+44
-50
lines changed

.github/workflows/ci-cd.yml

Lines changed: 41 additions & 48 deletions
Original file line numberDiff line numberDiff line change
@@ -1,65 +1,58 @@
11
name: CI/CD
2-
32
on:
43
push:
54
branches: [ master ]
65
pull_request:
76
branches: [ master ]
87

9-
# Add permissions block
108
permissions:
119
contents: write
1210
issues: write
1311
pull-requests: write
1412
packages: write
15-
1613
jobs:
1714
build:
1815
runs-on: ubuntu-latest
1916
environment: prod
2017
steps:
21-
- uses: actions/checkout@v4
22-
with:
23-
fetch-depth: 0
24-
persist-credentials: false
25-
token: ${{ secrets.PAT_TOKEN }}
26-
27-
- name: Setup Node.js for npm
28-
uses: actions/setup-node@v4
29-
with:
30-
node-version: '22.10.0'
31-
registry-url: 'https://registry.npmjs.org'
32-
33-
- name: Install dependencies
34-
run: npm install
35-
36-
- name: Run tests
37-
run: npm test
38-
39-
- name: Run linting
40-
run: npm run lint
41-
42-
- name: Build
43-
run: npm run build
44-
45-
- name: Publish to npm
46-
if: github.event_name == 'push' && github.ref == 'refs/heads/master'
47-
env:
48-
NODE_AUTH_TOKEN: ${{ secrets.NPM_TOKEN }}
49-
GITHUB_TOKEN: ${{ secrets.PAT_TOKEN }}
50-
run: npx semantic-release
51-
52-
- name: Setup Node.js for GitHub Packages
53-
uses: actions/setup-node@v4
54-
with:
55-
node-version: '22.10.0'
56-
registry-url: 'https://npm.pkg.github.com'
57-
58-
- name: Publish to GitHub Packages
59-
if: github.event_name == 'push' && github.ref == 'refs/heads/master'
60-
env:
61-
NODE_AUTH_TOKEN: ${{ secrets.PAT_TOKEN }}
62-
run: |
63-
echo "//npm.pkg.github.com/:_authToken=${NODE_AUTH_TOKEN}" > .npmrc
64-
echo "//registry.npmjs.org/:_authToken=${NPM_TOKEN}" >> .npmrc
65-
npm publish --registry=https://npm.pkg.github.com
18+
- uses: actions/checkout@v4
19+
with:
20+
fetch-depth: 0
21+
persist-credentials: false
22+
token: ${{ secrets.PAT_TOKEN }}
23+
- name: Setup Node.js for npm
24+
uses: actions/setup-node@v4
25+
with:
26+
node-version: '22.10.0'
27+
registry-url: 'https://registry.npmjs.org'
28+
- name: Install dependencies
29+
run: npm install
30+
- name: Run tests
31+
run: npm test
32+
- name: Run linting
33+
run: npm run lint
34+
- name: Build
35+
run: npm run build
36+
- name: Publish to npm
37+
if: github.event_name == 'push' && github.ref == 'refs/heads/master'
38+
env:
39+
NODE_AUTH_TOKEN: ${{ secrets.NPM_TOKEN }}
40+
GITHUB_TOKEN: ${{ secrets.PAT_TOKEN }}
41+
run: npx semantic-release
42+
- name: Setup Node.js for GitHub Packages
43+
uses: actions/setup-node@v4
44+
with:
45+
node-version: '22.10.0'
46+
registry-url: 'https://npm.pkg.github.com'
47+
- name: Publish to GitHub Packages
48+
if: github.event_name == 'push' && github.ref == 'refs/heads/master'
49+
env:
50+
NODE_AUTH_TOKEN: ${{ secrets.PAT_TOKEN }}
51+
run: |
52+
53+
cp package.json package.json.backup
54+
npm pkg set name="@nginH/llmforge"
55+
npm pkg set publishConfig.registry="https://npm.pkg.github.com"
56+
npm publish --registry=https://npm.pkg.github.com
57+
58+
mv package.json.backup package.json

package.json

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -26,7 +26,8 @@
2626
"license": "MIT",
2727
"publishConfig": {
2828
"access": "public",
29-
"registry": "https://registry.npmjs.org/"
29+
"registry": "https://registry.npmjs.org/",
30+
"@nginH:registry": "https://npm.pkg.github.com"
3031
},
3132
"repository": {
3233
"type": "git",
@@ -57,4 +58,4 @@
5758
"ts-jest": "^29.1.2",
5859
"typescript": "^5.3.3"
5960
}
60-
}
61+
}

0 commit comments

Comments
 (0)