Skip to content

Commit 37b9cdb

Browse files
generate types json second try (#2178)
# Goal The goal of this PR is to generate a types.json file and publish it with api-augment and the release artifacts. Closes #2062 with @wilwade and @enddynayn Co-authored-by: Wil Wade <[email protected]>
1 parent 9f592f0 commit 37b9cdb

File tree

3 files changed

+30
-6
lines changed

3 files changed

+30
-6
lines changed

.github/workflows/release.yml

Lines changed: 13 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -540,9 +540,9 @@ jobs:
540540
docker run -d --rm --net=net-${{env.RELEASE_BRANCH_NAME}} \
541541
-v `pwd`:/app \
542542
--name test-node \
543-
ubuntu:22.04 \
543+
ubuntu:24.04 \
544544
/bin/sh -c "chmod +x /app/${{env.TEST_BIN_FILENAME}} && /app/${{env.TEST_BIN_FILENAME}} \
545-
--chain=frequency-bench \
545+
--chain=frequency \
546546
--rpc-external \
547547
--rpc-cors=all \
548548
--rpc-methods=Unsafe \
@@ -559,9 +559,9 @@ jobs:
559559
docker run -d --rm --net=net-${{env.RELEASE_BRANCH_NAME}} \
560560
-v `pwd`:/app \
561561
--name ref-node \
562-
ubuntu:22.04 \
562+
ubuntu:24.04 \
563563
/bin/sh -c "chmod +x /app/${{env.REF_BIN_FILENAME}} && /app/${{env.REF_BIN_FILENAME}} \
564-
--chain=frequency-bench \
564+
--chain=frequency \
565565
--rpc-external \
566566
--rpc-cors=all \
567567
--rpc-methods=Unsafe \
@@ -585,7 +585,7 @@ jobs:
585585
- name: Compare Metadata
586586
timeout-minutes: 10
587587
run: |
588-
CMD="docker run --pull always --net=net-${{env.RELEASE_BRANCH_NAME}} jacogr/polkadot-js-tools:0.57.1 metadata ws://ref-node:9944 ws://test-node:9944"
588+
CMD="docker run --pull always --net=net-${{env.RELEASE_BRANCH_NAME}} jacogr/polkadot-js-tools:0.59.1 metadata ws://ref-node:9944 ws://test-node:9944"
589589
echo -e "Running:\n$CMD"
590590
$CMD >> ${{env.OUTPUT_DIR}}/${{env.OUTPUT_FILENAME}}
591591
cat ${{env.OUTPUT_DIR}}/${{env.OUTPUT_FILENAME}} | egrep -n -i ''
@@ -718,6 +718,12 @@ jobs:
718718
pattern: artifacts-*-${{github.run_id}}
719719
path: /tmp
720720
merge-multiple: true
721+
- name: Download api-augment artifacts
722+
id: download-js
723+
uses: actions/download-artifact@v4
724+
with:
725+
name: js-api-augment-${{github.run_id}}
726+
path: /tmp/polkadot-api-types-json
721727
- name: List Downloaded Artifacts
722728
working-directory: /tmp
723729
run: |
@@ -763,6 +769,7 @@ jobs:
763769
files: |
764770
/tmp/frequency*.*
765771
/tmp/metadata-compare-*
772+
/tmp/polkadot-api-types-json/json/types.json
766773
- name: Publish Full Release on GitHub
767774
if: steps.is-full-release.outputs.is-full-release == 'true'
768775
uses: softprops/action-gh-release@9d7c94cfd0a1f3ed45544c887983e9fa900f0564
@@ -772,6 +779,7 @@ jobs:
772779
files: |
773780
/tmp/frequency*.*
774781
/tmp/metadata-compare-*
782+
/tmp/polkadot-api-types-json/json/types.json
775783
- name: Get Latest Commit
776784
id: get-latest-commit
777785
run: |

js/api-augment/package.json

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,8 @@
2121
"prepackage": "cp CONTRIBUTING.md README.md ../../LICENSE ./dist",
2222
"prebuild": "npm run generate",
2323
"build": "tsc -p ./tsconfig.types.json && tsc -p ./tsconfig.cjs.json && tsc -p ./tsconfig.esm.json",
24-
"postbuild": "npm run package",
24+
"build:types-json": "node scripts/generate.mjs",
25+
"postbuild": "npm run package && npm run build:types-json",
2526
"fetch:local": "curl -H \"Content-Type: application/json\" -d '{\"id\":\"1\", \"jsonrpc\":\"2.0\", \"method\": \"state_getMetadata\", \"params\":[]}' http://localhost:9944 -o ./metadata.json",
2627
"generate:defs": "node --import=tsx/esm node_modules/.bin/polkadot-types-from-defs --package @frequency-chain/api-augment --input ./interfaces --endpoint ./metadata.json",
2728
"generate:meta": "node --import=tsx/esm node_modules/.bin/polkadot-types-from-chain --package @frequency-chain/api-augment --endpoint ./metadata.json --output ./interfaces",

js/api-augment/scripts/generate.mjs

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,15 @@
1+
import { types } from '../dist/esm/index.js';
2+
import fs from 'fs';
3+
import path from 'path';
4+
import { fileURLToPath } from 'url';
5+
import { dirname } from 'path';
6+
7+
// Get the filename from the URL
8+
const __filename = fileURLToPath(import.meta.url);
9+
// Get the directory name from the filename
10+
const __dirname = dirname(__filename);
11+
const outdir = path.join(__dirname, '../dist/json/');
12+
13+
fs.mkdirSync(outdir, { recursive: true });
14+
15+
fs.writeFileSync(path.join(outdir, 'types.json'), JSON.stringify(types, null, 4));

0 commit comments

Comments
 (0)