General revamp of the typescript library #3041
Workflow file for this run
This file contains 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: TypeScript bindings | |
on: | |
schedule: | |
- cron: "0 0 * * *" | |
push: | |
branches: | |
- main | |
paths: | |
- "typescript/**" | |
pull_request: | |
workflow_dispatch: | |
inputs: | |
environment: | |
description: "Environment (network) for workflow execution, e.g. `goerli`" | |
required: false | |
upstream_builds: | |
description: "Upstream builds" | |
required: false | |
upstream_ref: | |
description: "Git reference to checkout (e.g. branch name)" | |
required: false | |
default: "main" | |
jobs: | |
typescript-detect-changes: | |
runs-on: ubuntu-latest | |
outputs: | |
path-filter: ${{ steps.filter.outputs.path-filter }} | |
steps: | |
- uses: actions/checkout@v3 | |
if: github.event_name == 'pull_request' | |
- uses: dorny/paths-filter@v2 | |
if: github.event_name == 'pull_request' | |
id: filter | |
with: | |
filters: | | |
path-filter: | |
- './typescript/**' | |
typescript-build-and-test: | |
needs: typescript-detect-changes | |
if: | | |
github.event_name != 'pull_request' | |
|| needs.typescript-detect-changes.outputs.path-filter == 'true' | |
runs-on: ubuntu-latest | |
defaults: | |
run: | |
working-directory: ./typescript | |
steps: | |
- uses: actions/checkout@v3 | |
- uses: actions/setup-node@v3 | |
with: | |
node-version: "18.x" | |
cache: "yarn" | |
cache-dependency-path: typescript/yarn.lock | |
# We need this step because the `@keep-network/tbtc-v2` which we update in | |
# next step has an indirect dependency to `@summa-tx/[email protected]` | |
# package, which downloads one of its sub-dependencies via unathenticated | |
# `git://` protocol. That protocol is no longer supported. Thanks to this | |
# step `https://` is used instead of `git://`. | |
- name: Configure git to don't use unauthenticated protocol | |
run: git config --global url."https://".insteadOf git:// | |
- name: Install dependencies | |
run: yarn install | |
- name: Build | |
run: yarn build | |
- name: Tests | |
run: yarn test | |
typescript-build-and-deploy-testnet: | |
needs: [typescript-detect-changes, typescript-build-and-test] | |
if: github.event_name == 'workflow_dispatch' | |
runs-on: ubuntu-latest | |
defaults: | |
run: | |
working-directory: ./typescript | |
steps: | |
- uses: actions/checkout@v2 | |
- uses: actions/setup-node@v2 | |
with: | |
node-version: "18.x" | |
cache: "yarn" | |
cache-dependency-path: typescript/yarn.lock | |
registry-url: "https://registry.npmjs.org" | |
# We need this step because the `@keep-network/tbtc-v2` which we update in | |
# next step has an indirect dependency to `@summa-tx/[email protected]` | |
# package, which downloads one of its sub-dependencies via unathenticated | |
# `git://` protocol. That protocol is no longer supported. Thanks to this | |
# step `https://` is used instead of `git://`. | |
- name: Configure git to don't use unauthenticated protocol | |
run: git config --global url."https://".insteadOf git:// | |
- name: Install dependencies | |
run: yarn install --frozen-lockfile | |
- name: Get upstream packages versions | |
uses: keep-network/ci/actions/upstream-builds-query@v2 | |
id: upstream-builds-query | |
with: | |
upstream-builds: ${{ github.event.inputs.upstream_builds }} | |
query: | | |
ecdsa-contracts-version = github.com/keep-network/keep-core/ecdsa#version | |
tbtc-v2-contracts-version = github.com/keep-network/tbtc-v2#version | |
- name: Resolve latest contracts | |
run: | | |
yarn upgrade \ | |
@keep-network/ecdsa@${{ steps.upstream-builds-query.outputs.ecdsa-contracts-version }} \ | |
@keep-network/tbtc-v2@${{ steps.upstream-builds-query.outputs.tbtc-v2-contracts-version }} | |
- name: Build | |
run: yarn build | |
- name: Bump up package version | |
id: npm-version-bump | |
uses: keep-network/npm-version-bump@v2 | |
with: | |
work-dir: typescript | |
environment: ${{ github.event.inputs.environment }} | |
branch: ${{ github.ref }} | |
commit: ${{ github.sha }} | |
- name: Publish to npm | |
env: | |
NODE_AUTH_TOKEN: ${{ secrets.NPM_TOKEN }} | |
run: npm publish --access=public --tag ${{ github.event.inputs.environment }} | |
- name: Notify CI about completion of the workflow | |
uses: keep-network/ci/actions/notify-workflow-completed@v2 | |
env: | |
GITHUB_TOKEN: ${{ secrets.CI_GITHUB_TOKEN }} | |
with: | |
module: "github.com/keep-network/tbtc-v2.ts" | |
url: https://github.com/${{ github.repository }}/actions/runs/${{ github.run_id }} | |
environment: ${{ github.event.inputs.environment }} | |
upstream_builds: ${{ github.event.inputs.upstream_builds }} | |
upstream_ref: ${{ github.event.inputs.upstream_ref }} | |
version: ${{ steps.npm-version-bump.outputs.version }} | |
typescript-format: | |
needs: typescript-detect-changes | |
if: | | |
github.event_name == 'push' | |
|| needs.typescript-detect-changes.outputs.path-filter == 'true' | |
runs-on: ubuntu-latest | |
defaults: | |
run: | |
working-directory: ./typescript | |
steps: | |
- uses: actions/checkout@v3 | |
- uses: actions/setup-node@v3 | |
with: | |
node-version: "18.x" | |
cache: "yarn" | |
cache-dependency-path: typescript/yarn.lock | |
# We need this step because the `@keep-network/tbtc-v2` which we update in | |
# next step has an indirect dependency to `@summa-tx/[email protected]` | |
# package, which downloads one of its sub-dependencies via unathenticated | |
# `git://` protocol. That protocol is no longer supported. Thanks to this | |
# step `https://` is used instead of `git://`. | |
- name: Configure git to don't use unauthenticated protocol | |
run: git config --global url."https://".insteadOf git:// | |
- name: Install dependencies | |
run: yarn install | |
- name: Check formatting | |
run: yarn format |