Skip to content
Merged

Dev #14

Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
46 changes: 45 additions & 1 deletion .github/workflows/publish.yml
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
name: Publish to npm
name: Publish packages

on:
push:
Expand All @@ -9,6 +9,7 @@ permissions:
contents: write
issues: write
pull-requests: write
packages: write

jobs:
publish:
Expand Down Expand Up @@ -47,3 +48,46 @@ jobs:
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
NODE_AUTH_TOKEN: ${{ secrets.NPM_TOKEN }}

- name: Setup Node for GitHub Packages
uses: actions/setup-node@v4
with:
node-version: 22
registry-url: "https://npm.pkg.github.com"
scope: "@${{ github.repository_owner }}"

- name: Publish to GitHub Packages
env:
NODE_AUTH_TOKEN: ${{ secrets.GITHUB_TOKEN }}
GITHUB_REPOSITORY_OWNER: ${{ github.repository_owner }}
run: |
PKG_NAME="$(node -p "require('./package.json').name")"
OWNER_LC="$(printf '%s' "$GITHUB_REPOSITORY_OWNER" | tr '[:upper:]' '[:lower:]')"
BASE_NAME="${PKG_NAME#@*/}"
GH_PKG_NAME="@$OWNER_LC/$BASE_NAME"
PACK_JSON="$(npm pack --json)"
TARBALL="$(node -e "const data = JSON.parse(process.argv[1]); console.log(data[0].filename);" "$PACK_JSON")"
WORK_DIR="$(mktemp -d)"
trap 'rm -rf "$WORK_DIR" "$TARBALL"' EXIT

tar -xzf "$TARBALL" -C "$WORK_DIR"
GH_PKG_DIR="$WORK_DIR/package"

node -e "
const fs = require('node:fs');
const path = process.argv[1];
const nextName = process.argv[2];
const pkg = JSON.parse(fs.readFileSync(path, 'utf8'));
pkg.name = nextName;
pkg.publishConfig = { ...(pkg.publishConfig || {}), registry: 'https://npm.pkg.github.com' };
fs.writeFileSync(path, JSON.stringify(pkg, null, 2) + '\n');
" "$GH_PKG_DIR/package.json" "$GH_PKG_NAME"

GH_PKG_VERSION="$(node -e "console.log(require(process.argv[1]).version)" "$GH_PKG_DIR/package.json")"

if npm view "$GH_PKG_NAME@$GH_PKG_VERSION" version --registry=https://npm.pkg.github.com >/dev/null 2>&1; then
echo "Version $GH_PKG_VERSION is already published to GitHub Packages as $GH_PKG_NAME. Skipping."
exit 0
fi

npm publish "$GH_PKG_DIR" --registry=https://npm.pkg.github.com
17 changes: 17 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -22,10 +22,27 @@ It is dev-first and production-safe by default (`includeInProduction: false`).

## Install

From npm (recommended):

```bash
npm install @rayan_hn/render-inspector
```

From GitHub Packages:

```bash
npm install @rayanhnide/render-inspector --registry=https://npm.pkg.github.com
```

If you use GitHub Packages, add this to your user `.npmrc`:

```ini
@rayanhnide:registry=https://npm.pkg.github.com
//npm.pkg.github.com/:_authToken=${GITHUB_TOKEN}
```

Then set `GITHUB_TOKEN` in your shell to a GitHub token with `read:packages`.

## 20-Second Outcome Demo

```tsx
Expand Down
Loading