PR automation types rollup solochain #1067
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| name: PR automation types rollup solochain | |
| on: | |
| workflow_dispatch: | |
| inputs: | |
| nodeDockerImageTag: | |
| description: "gasp-node docker image tag" | |
| type: string | |
| required: false | |
| default: "a5060642ee6f68c18b258f53593639b8a343e4b6" | |
| nodeRepository: | |
| description: "Name of the repository where gasp-node code is stored" | |
| type: string | |
| required: false | |
| default: "mangata-finance/mangata-node" | |
| nodeRepositoryRevision: | |
| description: "Revision of the repository where gasp-node code is stored" | |
| type: string | |
| required: false | |
| default: "" | |
| nodeCodebaseWorkingDirectory: | |
| description: "Working directory where gasp-node code is stored" | |
| type: string | |
| required: false | |
| default: "mangata-repo" | |
| branch: | |
| description: "Branch where to run workflow" | |
| type: string | |
| required: false | |
| default: "" | |
| concurrency: ${{ github.workflow }}-${{ github.ref }} | |
| permissions: | |
| contents: write | |
| id-token: write | |
| deployments: write | |
| checks: write | |
| env: | |
| INPUTS_BRANCH: ${{ github.event.inputs.branch || github.ref_name }} | |
| CACHE_VERSION: 1 | |
| jobs: | |
| release: | |
| runs-on: ubuntu-latest | |
| outputs: | |
| type-definitions-version: ${{ steps.show-versions.outputs.type-definitions-version }} | |
| types-version: ${{ steps.show-versions.outputs.types-version }} | |
| sdk-version: ${{ steps.show-versions.outputs.sdk-version }} | |
| steps: | |
| - uses: actions/checkout@v4 | |
| with: | |
| fetch-depth: 0 | |
| ref: ${{ github.event.inputs.branch }} | |
| - uses: nrwl/nx-set-shas@v4 | |
| - name: Clone gasp-node repository | |
| uses: actions/checkout@v4 | |
| with: | |
| repository: ${{ github.event.inputs.nodeRepository }} | |
| path: mangata-repo | |
| ref: ${{ github.event.inputs.nodeRepositoryRevision || env.INPUTS_BRANCH }} | |
| - name: Run the Node | |
| working-directory: ${{ github.event.inputs.nodeCodebaseWorkingDirectory }} | |
| env: | |
| ROLLUP_NODE_VERSION: ${{ github.event.inputs.nodeDockerImageTag }} | |
| run: | | |
| # --no-build to ensure that we don't try to build the node from source if it can't be pulled from the registry | |
| docker compose up -d --no-build | |
| docker compose ps | |
| - name: Install WASM toolchain | |
| uses: actions-rust-lang/[email protected] | |
| with: | |
| toolchain: nightly | |
| target: wasm32-unknown-unknown | |
| - run: cargo install websocat | |
| - uses: actions/setup-node@v4 | |
| with: | |
| node-version-file: ".nvmrc" | |
| - name: Get npm cache directory | |
| id: npm-cache-dir | |
| shell: bash | |
| run: echo "dir=$(npm config get cache)" >> ${GITHUB_OUTPUT} | |
| - uses: actions/cache@v4 | |
| with: | |
| path: ${{ steps.npm-cache-dir.outputs.dir }} | |
| key: ${{ runner.os }}-${{ env.CACHE_VERSION }}-nodejs-${{ hashFiles('**/package-lock.json') }} | |
| restore-keys: | | |
| ${{ runner.os }}-${{ env.CACHE_VERSION }}-nodejs- | |
| - run: npm ci | |
| - run: npx nx run gasp-type-definitions:lint | |
| - run: npx nx run gasp-types:lint | |
| - run: npx nx run gasp-sdk:lint | |
| ######################################################### | |
| # Release type definitions | |
| ######################################################### | |
| - name: '[gasp-type-definitions] NPM version bump' | |
| working-directory: packages/type-definitions | |
| run: | | |
| # Branch name sanitization added to avoid issues with npm version command | |
| # Example `ci/new-branch-1.0.0` -> `ci-new-branch-1-0-0` | |
| npm version prerelease --preid="$(echo "${INPUTS_BRANCH}" | sed -E 's@[/\.]@-@g; s@_@-@g')" | |
| - name: '[gasp-type-definitions] git add and commit new version' | |
| run: | | |
| git config user.name mangatafinance | |
| git config user.email [email protected] | |
| git add . | |
| git commit -m "chore: updated type definitions to new prerelease version" | |
| git push | |
| - name: '[gasp-type-definitions] Build type definitions' | |
| run: npx nx run gasp-type-definitions:build | |
| - name: '[gasp-type-definitions] Publish type definitions to NPM' | |
| working-directory: dist/packages/type-definitions | |
| env: | |
| NPM_TOKEN: ${{ secrets.NPM_TOKEN }} | |
| run: | | |
| echo "//registry.npmjs.org/:_authToken=\${NPM_TOKEN}" > .npmrc | |
| # Branch name sanitization added to avoid issues with npm version command | |
| # Example `ci/new-branch-1.0.0` -> `ci-new-branch-1-0-0` | |
| npm publish --tag "$(echo "${INPUTS_BRANCH}" | sed -E 's@[/\.]@-@g; s@_@-@g')" --access public | |
| ######################################################### | |
| # Release types | |
| ######################################################### | |
| - name: '[gasp-types] Generate metadata for solochain' | |
| run: npx nx run gasp-types:generate-metadata-solochain | |
| - name: '[gasp-types] Build types' | |
| run: npx nx run gasp-types:build-types | |
| - name: '[gasp-types] NPM version bump' | |
| working-directory: packages/types | |
| run: | | |
| # Branch name sanitization added to avoid issues with npm version command | |
| # Example `ci/new-branch-1.0.0` -> `ci-new-branch-1-0-0` | |
| npm version prerelease --preid="$(echo "${INPUTS_BRANCH}" | sed -E 's@[/\.]@-@g; s@_@-@g')" | |
| - name: '[gasp-types] Remove Cloned Repository' | |
| run: rm -rf mangata-repo | |
| - name: '[gasp-types] git add and commit new version' | |
| run: | | |
| git config user.name mangatafinance | |
| git config user.email [email protected] | |
| git add . | |
| git commit -m "chore: updated to new prerelease version" | |
| git push origin ${{ env.INPUTS_BRANCH }} | |
| - name: '[gasp-types] Build types' | |
| run: npx nx run gasp-types:build | |
| - name: '[gasp-types] Publish to NPM' | |
| working-directory: dist/packages/types | |
| env: | |
| NPM_TOKEN: ${{ secrets.NPM_TOKEN }} | |
| run: | | |
| echo "//registry.npmjs.org/:_authToken=\${NPM_TOKEN}" > .npmrc | |
| # Branch name sanitization added to avoid issues with npm version command | |
| # Example `ci/new-branch-1.0.0` -> `ci-new-branch-1-0-0` | |
| npm publish --tag "$(echo "${INPUTS_BRANCH}" | sed -E 's@[/\.]@-@g; s@_@-@g')" --access public | |
| ######################################################### | |
| # Release sdk | |
| ######################################################### | |
| - name: '[gasp-sdk] Type definitions version for branch' | |
| run: | | |
| branchTypeDefinitionsVersion=$(npm show gasp-type-definitions dist-tags."$(echo "${{ env.INPUTS_BRANCH }}" | sed -E 's@[/\.]@-@g; s@_@-@g')") | |
| echo "BRANCH_TYPE_DEFINITIONS_VERSION=$branchTypeDefinitionsVersion" >> $GITHUB_ENV | |
| - name: '[gasp-sdk] Types version for branch' | |
| run: | | |
| branchTypesVersion=$(npm show gasp-types dist-tags."$(echo "${{ env.INPUTS_BRANCH }}" | sed -E 's@[/\.]@-@g; s@_@-@g')") | |
| echo "BRANCH_TYPES_VERSION=$branchTypesVersion" >> $GITHUB_ENV | |
| - name: '[gasp-sdk] Update types dependency version' | |
| working-directory: packages/sdk | |
| run: | | |
| sed -i "s/\"gasp-types\": \".*\"/\"gasp-types\": \"${{env.BRANCH_TYPES_VERSION}}\"/" package.json | |
| - name: '[gasp-sdk] Update type definitions dependency version' | |
| working-directory: packages/sdk | |
| run: | | |
| sed -i "s/\"gasp-type-definitions\": \".*\"/\"gasp-type-definitions\": \"${{env.BRANCH_TYPE_DEFINITIONS_VERSION}}\"/" package.json | |
| - name: '[gasp-sdk] NPM version bump' | |
| working-directory: packages/sdk | |
| run: | | |
| # Branch name sanitization added to avoid issues with npm version command | |
| # Example `ci/new-branch-1.0.0` -> `ci-new-branch-1-0-0` | |
| npm version prerelease --preid="$(echo "${INPUTS_BRANCH}" | sed -E 's@[/\.]@-@g; s@_@-@g')" | |
| - name: '[gasp-sdk] git add and commit new version' | |
| run: | | |
| git config user.name mangatafinance | |
| git config user.email [email protected] | |
| git add . | |
| git commit -m "chore: updated sdk to new prerelease version" | |
| git push | |
| - name: '[gasp-sdk] Build sdk' | |
| run: npx nx run gasp-sdk:build | |
| - name: '[gasp-sdk] Publish to NPM' | |
| working-directory: dist/packages/sdk | |
| env: | |
| NPM_TOKEN: ${{ secrets.NPM_TOKEN }} | |
| run: | | |
| echo "//registry.npmjs.org/:_authToken=\${NPM_TOKEN}" > .npmrc | |
| # Branch name sanitization added to avoid issues with npm version command | |
| # Example `ci/new-branch-1.0.0` -> `ci-new-branch-1-0-0` | |
| npm publish --tag "$(echo "${INPUTS_BRANCH}" | sed -E 's@[/\.]@-@g; s@_@-@g')" --access public | |
| ######################################################### | |
| # Show released versions | |
| ######################################################### | |
| - name: '[gasp-sdk] Show released versions' | |
| id: show-versions | |
| run: | | |
| echo "Version of gasp-type-definitions:" | |
| TYPE_DEF_VERSION=$(npm show gasp-type-definitions dist-tags."$(echo "${{ env.INPUTS_BRANCH }}" | sed -E 's@[/\.]@-@g; s@_@-@g')") | |
| echo $TYPE_DEF_VERSION | |
| echo "type-definitions-version=$TYPE_DEF_VERSION" >> $GITHUB_OUTPUT | |
| echo "Version of gasp-types:" | |
| TYPES_VERSION=$(npm show gasp-types dist-tags."$(echo "${{ env.INPUTS_BRANCH }}" | sed -E 's@[/\.]@-@g; s@_@-@g')") | |
| echo $TYPES_VERSION | |
| echo "types-version=$TYPES_VERSION" >> $GITHUB_OUTPUT | |
| echo "Version of gasp-sdk:" | |
| SDK_VERSION=$(npm show gasp-sdk dist-tags."$(echo "${{ env.INPUTS_BRANCH }}" | sed -E 's@[/\.]@-@g; s@_@-@g')") | |
| echo $SDK_VERSION | |
| echo "sdk-version=$SDK_VERSION" >> $GITHUB_OUTPUT | |
| echo "## Released Versions" >> $GITHUB_STEP_SUMMARY | |
| echo "- gasp-type-definitions: $TYPE_DEF_VERSION" >> $GITHUB_STEP_SUMMARY | |
| echo "- gasp-types: $TYPES_VERSION" >> $GITHUB_STEP_SUMMARY | |
| echo "- gasp-sdk: $SDK_VERSION" >> $GITHUB_STEP_SUMMARY |