Skip to content

Commit ee19aa1

Browse files
committed
Publish TypeScript package to npmjs
1 parent 89454aa commit ee19aa1

5 files changed

Lines changed: 31 additions & 54 deletions

File tree

.github/workflows/release.yml

Lines changed: 14 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -6,13 +6,14 @@ on:
66
- '[0-9]*.[0-9]*.[0-9]*'
77

88
permissions:
9-
contents: write
10-
packages: write
9+
contents: read
1110

1211
jobs:
1312
release:
1413
name: Build and publish release artifacts
1514
runs-on: ubuntu-latest
15+
permissions:
16+
contents: write
1617

1718
steps:
1819
- name: Check out repository
@@ -126,17 +127,19 @@ jobs:
126127
name: Publish TypeScript package
127128
runs-on: ubuntu-latest
128129
needs: release
130+
permissions:
131+
contents: read
132+
id-token: write
129133

130134
steps:
131135
- name: Check out repository
132136
uses: actions/checkout@v4
133137

134-
- name: Set up Node.js for GitHub Packages
138+
- name: Set up Node.js for npmjs
135139
uses: actions/setup-node@v4
136140
with:
137141
node-version: '24'
138-
registry-url: https://npm.pkg.github.com
139-
scope: '@terion-name'
142+
registry-url: https://registry.npmjs.org
140143
cache: npm
141144
cache-dependency-path: packages/ts/package-lock.json
142145

@@ -152,12 +155,11 @@ jobs:
152155
id: npm_version
153156
working-directory: packages/ts
154157
env:
155-
NODE_AUTH_TOKEN: ${{ secrets.GITHUB_TOKEN }}
156158
TAG_NAME: ${{ github.ref_name }}
157159
run: |
158160
set -euo pipefail
159161
package_name="$(node -p "require('./package.json').name")"
160-
if npm view "${package_name}@${TAG_NAME}" version --registry=https://npm.pkg.github.com >/dev/null 2>&1; then
162+
if npm view "${package_name}@${TAG_NAME}" version --registry=https://registry.npmjs.org >/dev/null 2>&1; then
161163
echo "exists=true" >> "${GITHUB_OUTPUT}"
162164
echo "${package_name}@${TAG_NAME} already exists; skipping publish."
163165
else
@@ -171,17 +173,18 @@ jobs:
171173
TAG_NAME: ${{ github.ref_name }}
172174
run: npm version "${TAG_NAME}" --no-git-tag-version
173175

174-
- name: Publish TypeScript package to GitHub Packages
176+
- name: Publish TypeScript package to npmjs
175177
if: steps.npm_version.outputs.exists != 'true'
176178
working-directory: packages/ts
177-
env:
178-
NODE_AUTH_TOKEN: ${{ secrets.GITHUB_TOKEN }}
179-
run: npm publish
179+
run: npm publish --access public --registry=https://registry.npmjs.org
180180

181181
docker-images:
182182
name: Build and publish ${{ matrix.app }} image
183183
runs-on: ubuntu-latest
184184
needs: release
185+
permissions:
186+
contents: read
187+
packages: write
185188
strategy:
186189
fail-fast: false
187190
matrix:

README.md

Lines changed: 4 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -116,24 +116,10 @@ The smoke tests (`make smoke`) automatically verify that signed `GET`/`HEAD` req
116116

117117
To allow users to download files, your backend application must generate an **edge signed URL**. These use a standard HMAC signature. Since the gateway verifies the signature before generating a ticket, bogus requests are dropped at the edge—saving your private network from dealing with malicious traffic.
118118

119-
We provide drop-in packages for Go, TypeScript, and Python under the `packages/` directory. The TypeScript package is published to GitHub Packages as the public package `@terion-name/air3-edgesign`. Configure npm for the GitHub Packages scope before installing:
119+
We provide drop-in packages for Go, TypeScript, and Python under the `packages/` directory. The TypeScript package is published to the public npm registry as `@terion/air3-edgesign`:
120120

121121
```sh
122-
# One-time user config; alternatively put this line in your project .npmrc.
123-
npm config set @terion-name:registry https://npm.pkg.github.com
124-
125-
# GitHub's npm registry may require auth for install/metadata access even
126-
# when package visibility is public. Use a classic PAT with read:packages.
127-
npm login --scope=@terion-name --registry=https://npm.pkg.github.com
128-
129-
npm install @terion-name/air3-edgesign
130-
```
131-
132-
For CI, set `NODE_AUTH_TOKEN` (for example from `${GITHUB_TOKEN}` in GitHub Actions, or another token with package read access) and add a project `.npmrc` like:
133-
134-
```ini
135-
@terion-name:registry=https://npm.pkg.github.com
136-
//npm.pkg.github.com/:_authToken=${NODE_AUTH_TOKEN}
122+
npm install @terion/air3-edgesign
137123
```
138124

139125
### Go Example
@@ -153,7 +139,7 @@ raw, err := edgesign.SignURL(edgesign.SignInput{
153139
### TypeScript Example
154140

155141
```ts
156-
import { signUrl, verifyUrl } from '@terion-name/air3-edgesign';
142+
import { signUrl, verifyUrl } from '@terion/air3-edgesign';
157143

158144
const raw = signUrl({
159145
method: 'GET',
@@ -203,7 +189,7 @@ go test ./... -race # run race-enabled Go tests
203189

204190
## Releases & Docker Images
205191

206-
We publish multi-architecture Docker images (Linux on `amd64` and `arm64`) to the GitHub Container Registry on every release. Cross-compiled binaries for macOS, Windows, and Linux are also attached to GitHub releases. The same tag workflow publishes the public npm package `@terion-name/air3-edgesign` to GitHub Packages with the tag as the npm version. GitHub's npm registry can require a token for install and metadata requests even when a package is public; use the `@terion-name` registry and authentication setup shown above before running `npm install @terion-name/air3-edgesign`.
192+
We publish multi-architecture Docker images (Linux on `amd64` and `arm64`) to the GitHub Container Registry on every release. Cross-compiled binaries for macOS, Windows, and Linux are also attached to GitHub releases. The same tag workflow publishes the public npm package `@terion/air3-edgesign` to npmjs with the tag as the npm version. Publishing uses npm Trusted Publishing from `.github/workflows/release.yml`, so the GitHub Actions job authenticates to npm through OIDC instead of an npm token.
207193

208194
- `ghcr.io/terion-name/air3/edge-gateway:<tag>`
209195
- `ghcr.io/terion-name/air3/private-connector:<tag>`

packages/ts/README.md

Lines changed: 5 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -1,28 +1,15 @@
1-
# @terion-name/air3-edgesign
1+
# @terion/air3-edgesign
22

33
TypeScript helpers for signing and verifying air3 edge gateway URLs.
44

5-
This package is published publicly to GitHub Packages as `@terion-name/air3-edgesign`. Configure npm for the `@terion-name` scope, authenticate if GitHub's npm registry requires it, then install:
5+
This package is published publicly to npmjs as `@terion/air3-edgesign`:
66

77
```sh
8-
# One-time user config; alternatively put this line in your project .npmrc.
9-
npm config set @terion-name:registry https://npm.pkg.github.com
10-
11-
# Use a classic PAT with read:packages when prompted.
12-
npm login --scope=@terion-name --registry=https://npm.pkg.github.com
13-
14-
npm install @terion-name/air3-edgesign
15-
```
16-
17-
For CI, set `NODE_AUTH_TOKEN` (for example from `${GITHUB_TOKEN}` in GitHub Actions, or another token with package read access) and add a project `.npmrc` like:
18-
19-
```ini
20-
@terion-name:registry=https://npm.pkg.github.com
21-
//npm.pkg.github.com/:_authToken=${NODE_AUTH_TOKEN}
8+
npm install @terion/air3-edgesign
229
```
2310

2411
```ts
25-
import { signUrl, verifyUrl } from '@terion-name/air3-edgesign';
12+
import { signUrl, verifyUrl } from '@terion/air3-edgesign';
2613
```
2714

28-
This package is published to GitHub Packages by the tag release workflow. The published runtime entry point is built JavaScript in `dist/` with TypeScript declarations.
15+
This package is published by the tag release workflow using npm Trusted Publishing from `.github/workflows/release.yml`. The GitHub Actions job authenticates to npm through OIDC instead of an npm token. The published runtime entry point is built JavaScript in `dist/` with TypeScript declarations.

packages/ts/package-lock.json

Lines changed: 5 additions & 5 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

packages/ts/package.json

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,8 @@
55
"description": "TypeScript helpers for signing and verifying air3 edge gateway URLs.",
66
"license": "MIT",
77
"publishConfig": {
8-
"access": "public"
8+
"access": "public",
9+
"registry": "https://registry.npmjs.org"
910
},
1011
"type": "module",
1112
"main": "./dist/index.js",
@@ -36,4 +37,4 @@
3637
"@types/node": "^24.0.0",
3738
"typescript": "^5.8.0"
3839
}
39-
}
40+
}

0 commit comments

Comments
 (0)