Skip to content

Commit e5d098e

Browse files
committed
chore: Add GitHub Action to publish typescript package to NPM
1 parent 4957185 commit e5d098e

File tree

4 files changed

+107
-2
lines changed

4 files changed

+107
-2
lines changed
Lines changed: 55 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,55 @@
1+
name: Publish nightly to NPM
2+
3+
on:
4+
# Allows you to run this workflow manually from the Actions tab
5+
workflow_dispatch:
6+
7+
permissions:
8+
id-token: write # Required for OIDC
9+
contents: read
10+
11+
jobs:
12+
Publish:
13+
name: Publish to NPM
14+
runs-on: ubuntu-latest
15+
timeout-minutes: 15
16+
defaults:
17+
run:
18+
working-directory: ./v1/typescript-definitions
19+
steps:
20+
- uses: actions/checkout@v5
21+
- uses: actions/setup-node@v5
22+
with:
23+
node-version: 24
24+
package-manager-cache: false
25+
registry-url: "https://registry.npmjs.org"
26+
27+
# Ensure npm 11.5.1 or later is installed:
28+
# - name: Update npm
29+
# run: npm install -g npm@latest
30+
31+
- name: Prepare Environment
32+
# Install from package-lock.json:
33+
run: npm ci
34+
env:
35+
CI: true
36+
37+
- name: Bump version to prerelease
38+
run: |
39+
PRERELEASE_TAG=nightly-$(echo "${{ github.ref_name }}" | sed -r 's/[^a-z0-9]+/-/gi')
40+
npm version prerelease --preid $PRERELEASE_TAG-$COMMIT_DATE-$GIT_HASH
41+
42+
- name: Generate types
43+
run: npm run generate-types
44+
env:
45+
CI: true
46+
47+
- name: Build
48+
run: npm run build
49+
env:
50+
CI: true
51+
52+
- name: Publish to NPM
53+
run: npm publish --tag nightly
54+
env:
55+
CI: true

.github/workflows/publish-npm.yml

Lines changed: 35 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -13,3 +13,38 @@ jobs:
1313
name: Publish to NPM
1414
runs-on: ubuntu-latest
1515
timeout-minutes: 15
16+
defaults:
17+
run:
18+
working-directory: ./v1/typescript-definitions
19+
steps:
20+
- uses: actions/checkout@v5
21+
- uses: actions/setup-node@v5
22+
with:
23+
node-version: 24
24+
package-manager-cache: false
25+
registry-url: "https://registry.npmjs.org"
26+
27+
# Ensure npm 11.5.1 or later is installed:
28+
# - name: Update npm
29+
# run: npm install -g npm@latest
30+
31+
- name: Prepare Environment
32+
# Install from package-lock.json:
33+
run: npm ci
34+
env:
35+
CI: true
36+
37+
- name: Generate types
38+
run: npm run generate-types
39+
env:
40+
CI: true
41+
42+
- name: Build
43+
run: npm run build
44+
env:
45+
CI: true
46+
47+
- name: Publish to NPM
48+
run: npm publish --tag latest
49+
env:
50+
CI: true

v1/typescript-definitions/README.md

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -66,8 +66,21 @@ The instructions below are for developers who want to work on the Typescript def
6666
```bash
6767

6868
npm install
69+
npm run generate-types # If any of the specification has changed
6970
npm run build
7071
# or
7172
npm run watch
7273

7374
```
75+
76+
### Publish to NPM
77+
78+
To publish a new version to NPM:
79+
80+
1. Bump the version `npm version major|minor|patch`
81+
2. Commit and push to GitHub
82+
3. Go to the Actions tab and trigger the "Publish to NPM" workflow
83+
84+
To publish a nightly build to NPM:
85+
86+
1. Go to the Actions tab and trigger the "Publish nightly to NPM" workflow

v1/typescript-definitions/package.json

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,9 @@
55
"types": "dist/main.d.ts",
66
"license": "MIT",
77
"description": "TypeScript definitions for Ograf graphics",
8+
"repository": {
9+
"url": "https://github.com/ebu/ograf"
10+
},
811
"homepage": "https://ograf.ebu.io",
912
"keywords": [
1013
"ograf",
@@ -17,8 +20,7 @@
1720
"scripts": {
1821
"build": "tsc --build",
1922
"watch": "tsc --watch",
20-
"generate-types": "node scripts/generate-types.js",
21-
"do:publish": "npm run generate-types && npm run build && npm publish --access public"
23+
"generate-types": "node scripts/generate-types.js"
2224
},
2325
"devDependencies": {
2426
"typescript": "^5.6.3",

0 commit comments

Comments
 (0)