-
Notifications
You must be signed in to change notification settings - Fork 0
57 lines (50 loc) · 1.69 KB
/
push-github-registry.yml
File metadata and controls
57 lines (50 loc) · 1.69 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
# Pushes the root CLI package to GitHub Packages (npm-compatible registry at npm.pkg.github.com).
# Package scope (@OWNER) must match github.repository_owner. Consumers authenticate once via PAT — see README.
# Runs only on the canonical upstream repo (aligned with npm Trusted Publisher gate).
name: Push CLI to GitHub registry
on:
push:
branches: ["main"]
paths:
- "package.json"
- "package-lock.json"
- "src/**"
- "templates/**"
- "tsconfig.json"
workflow_dispatch:
permissions:
contents: read
packages: write
jobs:
push:
runs-on: ubuntu-latest
if: github.repository == 'deb-adarsh/ai-stack-kit'
steps:
- name: Checkout
uses: actions/checkout@v4
- name: Setup Node.js for GitHub npm registry
uses: actions/setup-node@v4
with:
node-version: "20"
registry-url: "https://npm.pkg.github.com"
scope: "@${{ github.repository_owner }}"
cache: npm
cache-dependency-path: package-lock.json
- name: Install dependencies
run: npm ci
- name: Push to GitHub registry if version is new
run: |
PKG="$(node -p "require('./package.json').name")"
VER="$(node -p "require('./package.json').version")"
REG="https://npm.pkg.github.com"
set +e
npm view "${PKG}@${VER}" version --registry="${REG}" >/dev/null 2>&1
HAS_RC=$?
set -e
if [ "$HAS_RC" -eq 0 ]; then
echo "Skip push — ${PKG}@${VER} already exists on GitHub registry."
exit 0
fi
npm publish --registry="${REG}"
env:
NODE_AUTH_TOKEN: ${{ secrets.GITHUB_TOKEN }}