|
8 | 8 | registry: |
9 | 9 | description: 'Registry to publish to' |
10 | 10 | required: true |
11 | | - default: 'both' |
| 11 | + default: 'github' |
12 | 12 | type: choice |
13 | 13 | options: |
14 | | - - npmjs |
15 | 14 | - github |
16 | | - - both |
| 15 | + - npmjs |
17 | 16 |
|
18 | 17 | jobs: |
19 | 18 | build-and-publish: |
@@ -59,146 +58,21 @@ jobs: |
59 | 58 | with: |
60 | 59 | node-version: '22' |
61 | 60 |
|
62 | | - - name: Build Scala.js |
63 | | - run: sbt --batch riddlLibJS/fullLinkJS |
64 | | - |
65 | | - - name: Get version from sbt |
66 | | - id: version |
67 | | - run: | |
68 | | - VERSION=$(sbt --batch "print riddlLibJS/version" 2>/dev/null | grep -v "\[info\]" | grep -v "loading" | tail -1 | tr -d ' ') |
69 | | - echo "version=$VERSION" >> $GITHUB_OUTPUT |
70 | | - echo "Version: $VERSION" |
71 | | -
|
72 | | - - name: Prepare npm package |
73 | | - run: | |
74 | | - # Find the output directory |
75 | | - OUTPUT_DIR=$(find riddlLib/js/target -type d -name "*-opt" | head -1) |
76 | | - echo "Output directory: $OUTPUT_DIR" |
77 | | -
|
78 | | - # Copy TypeScript definitions |
79 | | - cp riddlLib/js/types/index.d.ts "$OUTPUT_DIR/" |
80 | | -
|
81 | | - # Create package.json from template with version and TypeScript support |
82 | | - cat > "$OUTPUT_DIR/package.json" << EOF |
83 | | - { |
84 | | - "name": "@ossuminc/riddl-lib", |
85 | | - "version": "${{ steps.version.outputs.version }}", |
86 | | - "description": "RIDDL Language Library - JavaScript/TypeScript bindings", |
87 | | - "main": "main.js", |
88 | | - "types": "index.d.ts", |
89 | | - "type": "module", |
90 | | - "exports": { |
91 | | - ".": { |
92 | | - "types": "./index.d.ts", |
93 | | - "import": "./main.js" |
94 | | - } |
95 | | - }, |
96 | | - "files": [ |
97 | | - "main.js", |
98 | | - "main.js.map", |
99 | | - "index.d.ts" |
100 | | - ], |
101 | | - "keywords": [ |
102 | | - "riddl", |
103 | | - "ddd", |
104 | | - "domain-driven-design", |
105 | | - "parser", |
106 | | - "ast", |
107 | | - "typescript" |
108 | | - ], |
109 | | - "author": "Ossum Inc.", |
110 | | - "license": "Apache-2.0", |
111 | | - "repository": { |
112 | | - "type": "git", |
113 | | - "url": "https://github.com/ossuminc/riddl.git" |
114 | | - }, |
115 | | - "bugs": { |
116 | | - "url": "https://github.com/ossuminc/riddl/issues" |
117 | | - }, |
118 | | - "homepage": "https://github.com/ossuminc/riddl#readme", |
119 | | - "publishConfig": { |
120 | | - "access": "public" |
121 | | - } |
122 | | - } |
123 | | - EOF |
124 | | -
|
125 | | - # Create README |
126 | | - cat > "$OUTPUT_DIR/README.md" << 'EOF' |
127 | | - # @ossuminc/riddl-lib |
128 | | -
|
129 | | - RIDDL Language Library - JavaScript/TypeScript bindings for the RIDDL parser. |
130 | | -
|
131 | | - ## Installation |
132 | | -
|
133 | | - ```bash |
134 | | - npm install @ossuminc/riddl-lib |
135 | | - ``` |
136 | | -
|
137 | | - ## Usage |
138 | | -
|
139 | | - ```typescript |
140 | | - import { RiddlAPI } from '@ossuminc/riddl-lib'; |
141 | | -
|
142 | | - // Parse a RIDDL source string |
143 | | - const result = RiddlAPI.parseString(` |
144 | | - domain Banking is { |
145 | | - context Accounts is { |
146 | | - entity Account is { ??? } |
147 | | - } |
148 | | - } |
149 | | - `); |
150 | | -
|
151 | | - if (result.succeeded) { |
152 | | - console.log("Domains:", result.value.domains); |
153 | | - } else { |
154 | | - console.error("Errors:", RiddlAPI.formatErrorArray(result.errors)); |
155 | | - } |
156 | | - ``` |
157 | | -
|
158 | | - ## API |
159 | | -
|
160 | | - - `RiddlAPI.parseString(source, origin?, verbose?)` - Parse RIDDL source to AST |
161 | | - - `RiddlAPI.parseNebula(source, origin?, verbose?)` - Parse arbitrary definitions |
162 | | - - `RiddlAPI.parseToTokens(source, origin?, verbose?)` - Tokenize for syntax highlighting |
163 | | - - `RiddlAPI.validateString(source, origin?, verbose?, noANSI?)` - Full validation |
164 | | - - `RiddlAPI.version` - Library version string |
165 | | - - `RiddlAPI.buildInfo` - Detailed build information |
166 | | - - `RiddlAPI.formatErrorArray(errors)` - Format errors as string |
167 | | - - `RiddlAPI.errorsToStrings(errors)` - Convert errors to string array |
168 | | -
|
169 | | - ## Documentation |
170 | | -
|
171 | | - See [RIDDL Documentation](https://ossum.tech/riddl/) for more information. |
172 | | -
|
173 | | - ## License |
174 | | -
|
175 | | - Apache-2.0 |
176 | | - EOF |
177 | | -
|
178 | | - echo "PACKAGE_DIR=$OUTPUT_DIR" >> $GITHUB_ENV |
| 61 | + - name: Publish to GitHub Packages |
| 62 | + if: github.event_name == 'release' || github.event.inputs.registry == 'github' |
| 63 | + run: sbt --batch riddlLibJS/npmPublishGithub |
179 | 64 |
|
180 | 65 | - name: Publish to npmjs.com |
181 | | - if: github.event_name == 'release' || github.event.inputs.registry == 'npmjs' || github.event.inputs.registry == 'both' |
| 66 | + if: github.event.inputs.registry == 'npmjs' |
182 | 67 | env: |
183 | | - NODE_AUTH_TOKEN: ${{ secrets.NPM_TOKEN }} |
184 | | - run: | |
185 | | - cd "$PACKAGE_DIR" |
186 | | - npm config set //registry.npmjs.org/:_authToken "$NODE_AUTH_TOKEN" |
187 | | - npm publish --access public |
188 | | - continue-on-error: true |
| 68 | + NPM_TOKEN: ${{ secrets.NPM_TOKEN }} |
| 69 | + run: sbt --batch riddlLibJS/npmPublishNpmjs |
189 | 70 |
|
190 | | - - name: Publish to GitHub Packages |
191 | | - if: github.event_name == 'release' || github.event.inputs.registry == 'github' || github.event.inputs.registry == 'both' |
| 71 | + - name: Get version for summary |
| 72 | + id: version |
192 | 73 | run: | |
193 | | - cd "$PACKAGE_DIR" |
194 | | - npm config set //npm.pkg.github.com/:_authToken "$GITHUB_TOKEN" |
195 | | - npm config set @ossuminc:registry https://npm.pkg.github.com |
196 | | -
|
197 | | - # Update package.json for GitHub Packages |
198 | | - jq '.publishConfig.registry = "https://npm.pkg.github.com"' package.json > package.json.tmp |
199 | | - mv package.json.tmp package.json |
200 | | -
|
201 | | - npm publish --access public |
| 74 | + VERSION=$(sbt --batch "print riddlLibJS/version" 2>/dev/null | grep -v "\[info\]" | grep -v "loading" | tail -1 | tr -d ' ') |
| 75 | + echo "version=$VERSION" >> $GITHUB_OUTPUT |
202 | 76 |
|
203 | 77 | - name: Generate summary |
204 | 78 | run: | |
|
0 commit comments