-
Notifications
You must be signed in to change notification settings - Fork 0
53 lines (45 loc) · 1.81 KB
/
publish-github-package.yml
File metadata and controls
53 lines (45 loc) · 1.81 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
name: Publish GitHub Package
on:
workflow_dispatch:
release:
types:
- published
permissions:
contents: read
packages: write
jobs:
publish:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- uses: actions/setup-node@v4
with:
node-version: 22
registry-url: https://npm.pkg.github.com
scope: "@devwebxyn"
- run: npm ci
- run: npm run build
- name: Rewrite package metadata for GitHub Packages
run: |
node -e "const fs=require('node:fs'); const pkg=JSON.parse(fs.readFileSync('package.json','utf8')); pkg.name='@devwebxyn/securemcp-lite'; pkg.publishConfig={registry:'https://npm.pkg.github.com'}; fs.writeFileSync('package.json', JSON.stringify(pkg, null, 2) + '\n');"
- name: Skip if this version already exists on GitHub Packages
id: package_check
run: |
VERSION=$(node -p "require('./package.json').version")
STATUS=$(curl -s -o /tmp/github-package-response.json -w "%{http_code}" \
-H "Authorization: Bearer $NODE_AUTH_TOKEN" \
-H "Accept: application/vnd.github+json" \
"https://npm.pkg.github.com/@devwebxyn%2fsecuremcp-lite")
if [ "$STATUS" = "200" ] && grep -q "\"version\":\"$VERSION\"" /tmp/github-package-response.json; then
echo "exists=true" >> "$GITHUB_OUTPUT"
echo "GitHub Packages already has @devwebxyn/securemcp-lite@$VERSION. Skipping publish."
else
echo "exists=false" >> "$GITHUB_OUTPUT"
fi
env:
NODE_AUTH_TOKEN: ${{ secrets.GITHUB_TOKEN }}
- name: Publish package to GitHub Packages
if: steps.package_check.outputs.exists != 'true'
run: npm publish
env:
NODE_AUTH_TOKEN: ${{ secrets.GITHUB_TOKEN }}