Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

refactor: ♻️ Update api-augment ci #2964

Open
wants to merge 16 commits into
base: master
Choose a base branch
from
51 changes: 18 additions & 33 deletions .github/workflows/publish-typescript-api.yml
Original file line number Diff line number Diff line change
Expand Up @@ -2,9 +2,13 @@ name: Publish Typescript API
on:
workflow_dispatch:
inputs:
sha:
description: full sha to build the npm package from
TargetSHA:
description: full sha of commit to publish ApiAugment from
required: true
DryRun:
description: Dry run mode
required: false
default: "false"

jobs:
publish-typescript-api:
Expand All @@ -13,43 +17,24 @@ jobs:
- name: Checkout
uses: actions/checkout@v4
with:
ref: ${{ github.event.inputs.sha }}
- name: Use Node.js
ref: ${{ github.event.inputs.TargetSHA }}
- uses: pnpm/action-setup@v4
name: Install pnpm
with:
version: 9
run_install: false
- name: Install Node.js
uses: actions/setup-node@v4
with:
node-version: 22
- name: Build typescript API
- name: Build Typescript Augment API package
run: |
cd typescript-api
npm install
npm run build
pnpm i
pnpm build
- name: Publish typescript API
uses: JS-DevTools/npm-publish@v3
with:
token: ${{ secrets.NPM_TOKEN }}
package: typescript-api/build/package.json

update-polkadot-js-for-tests-and-tools:
runs-on: ubuntu-latest
needs: ["publish-typescript-api"]
steps:
- name: Checkout
uses: actions/checkout@v4
with:
ref: ${{ github.event.inputs.sha }}
- name: Use pnpm
uses: pnpm/action-setup@v4
with:
version: 9
- name: Use Node.js
uses: actions/setup-node@v4
with:
node-version: 22
- name: Upgrade polkadotjs for tests
run: |
cd test
pnpm install @polkadot/api@latest
- name: Upgrade polkadotjs for tools
run: |
cd tools
npm install @polkadot/api@latest
package: typescript-api/package.json
dry-run: ${{ github.event.inputs.DryRun }}
34 changes: 20 additions & 14 deletions .github/workflows/upgrade-typescript-api.yml
Original file line number Diff line number Diff line change
Expand Up @@ -4,25 +4,27 @@ on:
inputs:
spec_version:
description: runtime spec version (ex. 1601)
required: true
required: false
timbrinded marked this conversation as resolved.
Show resolved Hide resolved
dry_run:
description: Dry Run - do not create PR
required: false
type: boolean
default: false

jobs:
upgrading-typescript-api:
runs-on: ubuntu-latest
steps:
- name: Checkout
uses: actions/checkout@v4
with:
ref: runtime-${{ github.event.inputs.spec_version }}
- name: Retrieve moonbeam binary
run: |
DOCKER_TAG="moonbeamfoundation/moonbeam:runtime-${{ github.event.inputs.spec_version }}"
# Clear the dummy container if it wasn't properly cleaned up
docker rm -f dummy 2> /dev/null
docker create -ti --name dummy $DOCKER_TAG bash
mkdir -p build
docker cp dummy:/moonbeam/moonbeam build/moonbeam
docker rm -f dummy
docker rm -f rtRelease 2> /dev/null
docker create -ti --name rtRelease $DOCKER_TAG bash
mkdir -p target/release
docker cp rtRelease:/moonbeam/moonbeam target/release/moonbeam
docker rm -f rtRelease
- name: Use Node.js
uses: actions/setup-node@v4
with:
Expand All @@ -31,26 +33,30 @@ jobs:
uses: pnpm/action-setup@v4
with:
version: 9
run_install: false

- name: Upgrade polkadotjs for moonbeam-types-bundle
run: |
cd moonbeam-types-bundle
pnpm install
- name: Upgrade polkadotjs for typescript-api
run: |
cd typescript-api
pnpm install
pnpm run build
- name: regenerate typescript api with new runtime metadata
run: |
cd typescript-api
./scripts/runtime-upgrade.sh ${{ github.event.inputs.spec_version }}
- name: Create Pull Request
if: ${{ !inputs.dry_run }}
uses: peter-evans/create-pull-request@v6
with:
base: master
branch: "typescript-api-${{ github.event.inputs.spec_version }}"
commit-message: typescript API v0.${{ github.event.inputs.spec_version }}.0
draft: true

title: "Upgrade typescript API for runtime-${{ github.event.inputs.spec_version }}"
reviewers: "moonsong-coredev"
labels: "B0-silent,D2-notlive"
- name: Display changes (Dry Run)
if: ${{ inputs.dry_run }}
run: |
git diff
echo "Dry run completed. Changes were not committed or pushed."
2 changes: 1 addition & 1 deletion typescript-api/src/moonbeam/interfaces/definitions.ts
Original file line number Diff line number Diff line change
@@ -1 +1 @@
export { default as empty } from "./moon/definitions";
export { default as moon } from "./moon/definitions";
2 changes: 1 addition & 1 deletion typescript-api/src/moonriver/interfaces/definitions.ts
Original file line number Diff line number Diff line change
@@ -1 +1 @@
export { default as empty } from "./moon/definitions";
export { default as moon } from "./moon/definitions";
2 changes: 1 addition & 1 deletion typescript-api/tsconfig.base.json
Original file line number Diff line number Diff line change
Expand Up @@ -17,5 +17,5 @@
"moonbase": ["moonbase/src"]
}
},
"exclude": ["node_modules","dist", "scripts"]
"exclude": ["node_modules", "dist", "scripts"]
}
50 changes: 19 additions & 31 deletions typescript-api/tsconfig.json
Original file line number Diff line number Diff line change
@@ -1,34 +1,22 @@
{
"extends":"./tsconfig.base.json",
"compilerOptions": {
"incremental": true,
"rootDir": "src",
"outDir": "dist",
"baseUrl": "./",
"paths": {
"@storagehub/api-augment/*": [
"src/*"
],
"@polkadot/api/augment": [
"src/interfaces/augment-api.ts"
],
"@polkadot/types/augment": [
"src/interfaces/augment-types.ts"
],
"@polkadot/types/lookup": [
"src/interfaces/types-lookup.ts"
]
},
"noEmit": false,
"declaration": true,
"declarationDir": "dist/types",
"allowImportingTsExtensions": false,
},
"exclude": [
"node_modules",
"dist",
"scripts"
],
"extends": "./tsconfig.base.json",
"compilerOptions": {
"incremental": true,
"rootDir": "src",
"outDir": "dist",
"baseUrl": "./",
"paths": {
"@storagehub/api-augment/*": ["src/*"],
"@polkadot/api/augment": ["src/interfaces/augment-api.ts"],
"@polkadot/types/augment": ["src/interfaces/augment-types.ts"],
"@polkadot/types/lookup": ["src/interfaces/types-lookup.ts"]
},
"noEmit": false,
"declaration": true,
"declarationDir": "dist/types",
"allowImportingTsExtensions": false
},
"exclude": ["node_modules", "dist", "scripts"],
"references": [
{
"path": "./src/moonbeam"
Expand All @@ -40,4 +28,4 @@
"path": "./src/moonbase"
}
]
}
}
Loading