Skip to content

Commit 8fbb11e

Browse files
committed
ci: add npm publish workflow and prepare package for publication
* Add publish job to GitHub workflow to automatically publish to npm * Create .npmignore file to exclude development files from package * Update package.json with scoped name, repository info, and publish configuration * Add prepublishOnly script to ensure package is built before publishing
1 parent 553cd97 commit 8fbb11e

File tree

3 files changed

+65
-2
lines changed

3 files changed

+65
-2
lines changed

.github/workflows/build.yml

Lines changed: 34 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -95,3 +95,37 @@ jobs:
9595
gh workflow run release.yml --ref $new_tag
9696
env:
9797
GH_TOKEN: ${{ github.token }}
98+
99+
publish:
100+
name: Publish to npm
101+
needs: build
102+
runs-on: ubuntu-latest
103+
if: github.ref_type != 'tag' && inputs.release_type != null
104+
steps:
105+
- name: Checkout code
106+
uses: actions/checkout@v4
107+
with:
108+
fetch-depth: 0
109+
token: ${{ github.token }}
110+
111+
- name: Setup Node.js
112+
uses: actions/setup-node@v4
113+
with:
114+
node-version: '22'
115+
registry-url: 'https://registry.npmjs.org'
116+
117+
- name: Setup pnpm
118+
uses: pnpm/action-setup@v4
119+
with:
120+
version: 10.4.1
121+
122+
- name: Install dependencies
123+
run: pnpm install --frozen-lockfile
124+
125+
- name: Build package
126+
run: pnpm build
127+
128+
- name: Publish to npm
129+
run: npm publish --access public
130+
env:
131+
NODE_AUTH_TOKEN: ${{ secrets.NPM_TOKEN }}

.npmignore

Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,23 @@
1+
# Source files
2+
src/
3+
tests/
4+
5+
# Config files
6+
.github/
7+
.vscode/
8+
.editorconfig
9+
.eslintrc
10+
.prettierrc
11+
tsconfig.json
12+
jest.config.js
13+
14+
# Git files
15+
.git/
16+
.gitignore
17+
18+
# Build artifacts
19+
node_modules/
20+
21+
# Misc
22+
*.log
23+
.DS_Store

package.json

Lines changed: 8 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,16 +1,21 @@
11
{
2-
"name": "gql-federation-schema-parser",
2+
"name": "@tiagoboeing/gql-federation-schema-parser",
33
"version": "1.1.1",
44
"description": "CLI tool to parse GraphQL schemas and generate TypeScript definitions for use in a GraphQL Federation gateway.",
55
"main": "build/src/index.js",
66
"type": "module",
7+
"private": false,
8+
"publishConfig": {
9+
"access": "public"
10+
},
711
"bin": {
812
"gql-federation-schema-parser": "./dist/index.js"
913
},
1014
"author": {
1115
"name": "Tiago Boeing",
1216
"email": "[email protected]"
1317
},
18+
"repository": "github:tiagoboeing/graphql-federation-schema-parser",
1419
"engines": {
1520
"node": ">=22.0.0",
1621
"bun": ">=1.0.0"
@@ -21,7 +26,8 @@
2126
"build": "bun build ./src/index.ts --target=node --outdir=./dist --minify",
2227
"build:executable": "bun build ./src/index.ts --compile --outfile=./dist/gql-federation-schema-parser",
2328
"postbuild:executable": "chmod +x ./dist/gql-federation-schema-parser",
24-
"execute": "bun src/index.ts"
29+
"execute": "bun src/index.ts",
30+
"prepublishOnly": "pnpm build"
2531
},
2632
"keywords": [
2733
"graphql",

0 commit comments

Comments
 (0)