Skip to content

Commit 5a3f796

Browse files
authored
ci: add GitHub Actions workflow for package publishing (#16)
1 parent 08c86b0 commit 5a3f796

File tree

4 files changed

+51
-4
lines changed

4 files changed

+51
-4
lines changed

.github/workflows/publish.yaml

Lines changed: 34 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,34 @@
1+
name: Publish package to GitHub Packages
2+
on:
3+
release:
4+
types: [published]
5+
jobs:
6+
build:
7+
runs-on: ubuntu-latest
8+
permissions:
9+
contents: read
10+
packages: write
11+
steps:
12+
- uses: actions/checkout@v4
13+
with:
14+
fetch-depth: 0
15+
16+
- name: Install Node
17+
uses: actions/setup-node@v4
18+
with:
19+
node-version-file: .nvmrc
20+
cache: yarn
21+
22+
- name: Install JavaScript dependencies
23+
shell: bash
24+
run: yarn install
25+
26+
- name: Build clients
27+
shell: bash
28+
run: yarn build
29+
30+
- name: Publish to NPM
31+
shell: bash
32+
run: yarn release:publish
33+
env:
34+
NPM_AUTH_TOKEN: ${{ secrets.CLINIA_CI_GITHUB_TOKEN }}

package.json

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@
88
"scripts": {
99
"build": "lerna run build --skip-nx-cache --include-dependencies",
1010
"clean": "lerna run clean --include-dependencies",
11-
"release:publish": "tsc --project tsconfig.script.json && node dist/scripts/publish.js",
11+
"release:publish": "tsc --project scripts/tsconfig.json && node scripts/dist/publish.js",
1212
"test": "lerna run test $*",
1313
"test:size": "bundlewatch"
1414
},
@@ -25,4 +25,4 @@
2525
"yarn": "^4.0.0"
2626
},
2727
"packageManager": "[email protected]"
28-
}
28+
}

scripts/publish.ts

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,13 @@
1+
import { execaCommand } from 'execa';
2+
3+
async function publish(): Promise<void> {
4+
// publish the stable public packages
5+
await execaCommand(
6+
`yarn lerna exec --no-bail -- npm_config_registry=https://npm.pkg.github.com/ npm publish --access public`,
7+
{
8+
shell: 'bash',
9+
},
10+
);
11+
}
12+
13+
publish();
Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,8 @@
11
{
2-
"extends": "./tsconfig.json",
2+
"extends": "../tsconfig.json",
33
"compilerOptions": {
44
"resolveJsonModule": true,
55
"outDir": "dist"
66
},
7-
"include": ["scripts"]
7+
"include": ["*.ts"]
88
}

0 commit comments

Comments
 (0)