Skip to content

Pre-release types

Pre-release types #243

name: Pre-release types
on:
push:
branches:
- 'rc/*'
paths:
- packages/types/**
workflow_dispatch:
inputs:
parachainDocker:
description: "Name of the parachain docker reference"
type: string
required: false
default: "mangatasolutions/mangata-node:develop"
branch:
description: "Branch where to make pre release"
type: string
required: false
default: ""
concurrency: ${{ github.workflow }}-${{ github.ref }}
env:
API_URL: "ws://127.0.0.1:9947"
permissions:
contents: write
id-token: write
deployments: write
checks: write
jobs:
release:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v3
with:
fetch-depth: 0
- uses: nrwl/nx-set-shas@v3
- name: Clone mangata node repository with branch
if: ${{ github.event.inputs.branch != '' }}
uses: actions/checkout@v3
with:
repository: mangata-finance/mangata-node
path: mangata-repo
ref: ${{ github.event.inputs.branch }}
- name: Clone mangata node repository default develop
if: ${{ github.event.inputs.branch == '' }}
uses: actions/checkout@v3
with:
repository: mangata-finance/mangata-node
path: mangata-repo
ref: develop
- name: Setup Node version and cache dependencies
uses: actions/setup-node@v3
with:
node-version: "18"
cache: "npm"
- name: Install WASM toolchain
uses: actions-rs/toolchain@v1
with:
toolchain: nightly
target: wasm32-unknown-unknown
- name: Install websocat
run: |
cargo install websocat
shell: bash
- name: Replace parachain docker image reference in config
working-directory: mangata-repo/devops/parachain-launch
run: sed -i 's+mangatasolutions/mangata-node:.*+${{ github.event.inputs.parachainDocker }}+g' config.yml
- name: Generate the config
working-directory: mangata-repo/devops/parachain-launch
run: npx @open-web3/parachain-launch generate config.yml
- name: Remove obsolete node run args from generated docker-compose.yml
working-directory: mangata-repo/devops/parachain-launch/output
run: sed -i '/ws-external/d' docker-compose.yml
- name: Run the Node
working-directory: mangata-repo/devops/parachain-launch/output
run: |
docker-compose up -d --build
docker ps
- name: Sleep for 1 minutes
run: sleep 60s
- run: npm ci
- name: Extract the latest version of type definitions
run: |
version=$(npm show @mangata-finance/type-definitions version)
echo "NPM package version of mangata type definitions is $version"
echo "MANGATA_TYPE_DEFINITIONS=$version" >> $GITHUB_ENV
- name: Install always latest type definitions
run: npm i @mangata-finance/type-definitions@${{ env.MANGATA_TYPE_DEFINITIONS }}
- run: npx nx run @mangata-finance/types:generate-metadata
- run: npx nx run @mangata-finance/types:build-types
- run: npx nx run @mangata-finance/types:lint
- name: NPM version bump
if: ${{ github.event.inputs.branch != '' }}
working-directory: packages/types
env:
INPUTS_BRANCH: ${{ github.event.inputs.branch }}
run: |
# Branch name sanitization added to avoid issues with npm version command
# Example `ci/new-branch` -> `ci-new-branch`
npm version prerelease --preid="${INPUTS_BRANCH//\//-}"
- name: git add and commit new version
if: ${{ github.event.inputs.branch != '' }}
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
- name: Build
if: ${{ github.event.inputs.branch != '' }}
run: npx nx run @mangata-finance/types:build
- name: Publish to NPM
if: ${{ github.event.inputs.branch != '' }}
working-directory: dist/packages/types
env:
NPM_TOKEN: ${{ secrets.NPM_TOKEN }}
INPUTS_BRANCH: ${{ github.event.inputs.branch }}
run: |
echo "//registry.npmjs.org/:_authToken=\${NPM_TOKEN}" > .npmrc
# Branch name sanitization added to avoid issues with npm version command
# Example `ci/new-branch` -> `ci-new-branch`
npm publish --tag "${INPUTS_BRANCH//\//-}" --access public
- name: Publish rc to NPM
if: ${{ github.event.inputs.branch == '' }}
run: npx nx run @mangata-finance/types:semantic-release
env:
GITHUB_TOKEN: ${{ secrets.GH_TOKEN }}
NPM_TOKEN: ${{ secrets.NPM_TOKEN }}