-
-
Notifications
You must be signed in to change notification settings - Fork 1
214 lines (181 loc) · 6.66 KB
/
npm-publish.yml
File metadata and controls
214 lines (181 loc) · 6.66 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
name: Publish npm Package
on:
release:
types: [published]
workflow_dispatch:
inputs:
registry:
description: 'Registry to publish to'
required: true
default: 'both'
type: choice
options:
- npmjs
- github
- both
jobs:
build-and-publish:
runs-on: ubuntu-latest
timeout-minutes: 30
permissions:
contents: read
packages: write
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
steps:
- name: Checkout repository
uses: actions/checkout@v4
- name: Set up JDK 25
uses: actions/setup-java@v4
with:
java-version: '25'
distribution: temurin
cache: sbt
- name: Set up SBT
uses: sbt/setup-sbt@v1
- name: Coursier Caching
uses: coursier/cache-action@v6
- name: Configure sbt GitHub Packages credentials
run: |
mkdir -p ~/.sbt/1.0
cat > ~/.sbt/1.0/github.sbt << 'EOF'
credentials += Credentials(
"GitHub Package Registry",
"maven.pkg.github.com",
"x-access-token",
sys.env.getOrElse("GITHUB_TOKEN", "")
)
EOF
- name: Set up Node.js
uses: actions/setup-node@v4
with:
node-version: '22'
- name: Build Scala.js
run: sbt --batch riddlLibJS/fullLinkJS
- name: Get version from sbt
id: version
run: |
VERSION=$(sbt --batch "print riddlLibJS/version" 2>/dev/null | grep -v "\[info\]" | grep -v "loading" | tail -1 | tr -d ' ')
echo "version=$VERSION" >> $GITHUB_OUTPUT
echo "Version: $VERSION"
- name: Prepare npm package
run: |
# Find the output directory
OUTPUT_DIR=$(find riddlLib/js/target -type d -name "*-opt" | head -1)
echo "Output directory: $OUTPUT_DIR"
# Copy TypeScript definitions
cp riddlLib/js/types/index.d.ts "$OUTPUT_DIR/"
# Create package.json from template with version and TypeScript support
cat > "$OUTPUT_DIR/package.json" << EOF
{
"name": "@ossuminc/riddl-lib",
"version": "${{ steps.version.outputs.version }}",
"description": "RIDDL Language Library - JavaScript/TypeScript bindings",
"main": "main.js",
"types": "index.d.ts",
"type": "module",
"exports": {
".": {
"types": "./index.d.ts",
"import": "./main.js"
}
},
"files": [
"main.js",
"main.js.map",
"index.d.ts"
],
"keywords": [
"riddl",
"ddd",
"domain-driven-design",
"parser",
"ast",
"typescript"
],
"author": "Ossum Inc.",
"license": "Apache-2.0",
"repository": {
"type": "git",
"url": "https://github.com/ossuminc/riddl.git"
},
"bugs": {
"url": "https://github.com/ossuminc/riddl/issues"
},
"homepage": "https://github.com/ossuminc/riddl#readme",
"publishConfig": {
"access": "public"
}
}
EOF
# Create README
cat > "$OUTPUT_DIR/README.md" << 'EOF'
# @ossuminc/riddl-lib
RIDDL Language Library - JavaScript/TypeScript bindings for the RIDDL parser.
## Installation
```bash
npm install @ossuminc/riddl-lib
```
## Usage
```typescript
import { RiddlAPI } from '@ossuminc/riddl-lib';
// Parse a RIDDL source string
const result = RiddlAPI.parseString(`
domain Banking is {
context Accounts is {
entity Account is { ??? }
}
}
`);
if (result.succeeded) {
console.log("Domains:", result.value.domains);
} else {
console.error("Errors:", RiddlAPI.formatErrorArray(result.errors));
}
```
## API
- `RiddlAPI.parseString(source, origin?, verbose?)` - Parse RIDDL source to AST
- `RiddlAPI.parseNebula(source, origin?, verbose?)` - Parse arbitrary definitions
- `RiddlAPI.parseToTokens(source, origin?, verbose?)` - Tokenize for syntax highlighting
- `RiddlAPI.validateString(source, origin?, verbose?, noANSI?)` - Full validation
- `RiddlAPI.version` - Library version string
- `RiddlAPI.buildInfo` - Detailed build information
- `RiddlAPI.formatErrorArray(errors)` - Format errors as string
- `RiddlAPI.errorsToStrings(errors)` - Convert errors to string array
## Documentation
See [RIDDL Documentation](https://ossum.tech/riddl/) for more information.
## License
Apache-2.0
EOF
echo "PACKAGE_DIR=$OUTPUT_DIR" >> $GITHUB_ENV
- name: Publish to npmjs.com
if: github.event_name == 'release' || github.event.inputs.registry == 'npmjs' || github.event.inputs.registry == 'both'
env:
NODE_AUTH_TOKEN: ${{ secrets.NPM_TOKEN }}
run: |
cd "$PACKAGE_DIR"
npm config set //registry.npmjs.org/:_authToken "$NODE_AUTH_TOKEN"
npm publish --access public
continue-on-error: true
- name: Publish to GitHub Packages
if: github.event_name == 'release' || github.event.inputs.registry == 'github' || github.event.inputs.registry == 'both'
run: |
cd "$PACKAGE_DIR"
npm config set //npm.pkg.github.com/:_authToken "$GITHUB_TOKEN"
npm config set @ossuminc:registry https://npm.pkg.github.com
# Update package.json for GitHub Packages
jq '.publishConfig.registry = "https://npm.pkg.github.com"' package.json > package.json.tmp
mv package.json.tmp package.json
npm publish --access public
- name: Generate summary
run: |
echo "## npm Package Published" >> $GITHUB_STEP_SUMMARY
echo "" >> $GITHUB_STEP_SUMMARY
echo "**Package:** \`@ossuminc/riddl-lib\`" >> $GITHUB_STEP_SUMMARY
echo "**Version:** \`${{ steps.version.outputs.version }}\`" >> $GITHUB_STEP_SUMMARY
echo "" >> $GITHUB_STEP_SUMMARY
echo "### Installation" >> $GITHUB_STEP_SUMMARY
echo "" >> $GITHUB_STEP_SUMMARY
echo "\`\`\`bash" >> $GITHUB_STEP_SUMMARY
echo "npm install @ossuminc/riddl-lib" >> $GITHUB_STEP_SUMMARY
echo "\`\`\`" >> $GITHUB_STEP_SUMMARY