-
Notifications
You must be signed in to change notification settings - Fork 3
80 lines (58 loc) · 1.99 KB
/
Copy pathcd.yml
File metadata and controls
80 lines (58 loc) · 1.99 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
name: Generate TypeScript from SHACL
on:
workflow_dispatch:
release:
types: [published]
jobs:
generate-and-publish:
runs-on: ubuntu-latest
permissions:
contents: read
id-token: write
steps:
- name: Checkout repository
uses: actions/checkout@v6
- name: Setup Node.js
uses: actions/setup-node@v6
with:
node-version-file: .nvmrc
registry-url: https://registry.npmjs.org/
- name: Ensure output folder exists
run: mkdir -p objects
- name: Generate TypeScript classes
run: npx @theodi/shacl-converter shapes objects
- name: Prepare npm package
run: |
cp package.template.json objects/package.json
cp tsconfig.template.json objects/tsconfig.json
cp README.md objects/ || true
node <<EOF
const fs = require('fs');
let ref = process.env.GITHUB_REF || '';
let version = process.env.GITHUB_REF_NAME || '';
// fallback safety
if (!version && ref.startsWith('refs/tags/')) {
version = ref.replace('refs/tags/', '');
}
version = version.replace(/^v/, '');
if (!version) {
throw new Error('No version found from GitHub context');
}
const pkgPath = './objects/package.json';
const pkg = JSON.parse(fs.readFileSync(pkgPath, 'utf8'));
pkg.version = version;
fs.writeFileSync(pkgPath, JSON.stringify(pkg, null, 2));
EOF
- name: Check generated entry exists
run: test -f objects/index.ts
- name: Verify package.json exists
run: test -f objects/package.json
- name: Install dependencies
working-directory: objects
run: npm install
- name: Compile TypeScript
working-directory: objects
run: npx tsc
- name: Publish to npm
working-directory: objects
run: npm publish --access public --provenance