diff --git a/.github/workflows/publish.yml b/.github/workflows/publish.yml new file mode 100644 index 0000000000..e8f10c3ab8 --- /dev/null +++ b/.github/workflows/publish.yml @@ -0,0 +1,64 @@ +name: Release Pipeline (develop/2.0) + +on: + pull_request: + branches: + - master + types: + - labeled + check_suite: + types: + - completed + +jobs: + merge-release-branch: + # only run if prechecks pass and the source branch is named 'prerelease/*' + if: ${{ startsWith(github.head_ref, 'prerelease/2') }} && ${{ github.event.label.name == 'automerge' }} + runs-on: ubuntu-latest + steps: + - name: Automerge + uses: "pascalgn/automerge-action@v0.12.0" + env: + GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} + MERGE_LABELS: automerge + MERGE_METHOD: squash + release-to-github: + needs: + - merge-release-branch + # release to github only when its a prerelease branch and auto merge label is triggered + if: ${{ startsWith(github.head_ref, 'prerelease/2') }} && ${{ github.event.label.name == 'automerge' }} + runs-on: ubuntu-latest + steps: + # checkout merged branch + - uses: actions/checkout@v2 + with: + ref: master + - uses: actions/setup-node@v1 + with: + node-version: '15.3' + - name: find release version + id: find_version + run: | + echo ::set-output name=tag_name::$(cat packages/api/package.json \ + | grep version \ + | head -1 \ + | grep -E -o '[0-9|.]+\-*[a-z]*\.[0-9]+|]+') + - name: make release branch + uses: peterjgrainger/action-create-branch@v2.0.1 + env: + GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} + with: + branch: "release/${{steps.find_version.outputs.tag_name}}" + - name: package + run: | + yarn && yarn build + npx lerna exec -- 'cp package.json build/' + npx lerna exec -- 'cp README.md build/' + npx lerna exec -- 'cp ../../LICENSE build/' + - name: publish to npm + env: + NPM_KEY: ${{ secrets.NPM_KEY }} + run: | + echo "//registry.npmjs.org/:_authToken=${NPM_KEY}" > ~/.npmrc + echo 'Publishing to npmjs.org.' + npx lerna exec -- 'cd build && npm publish --access public' diff --git a/packages/extension-dapp/src/index.ts b/packages/extension-dapp/src/index.ts index 00c1569df3..553873a4ac 100644 --- a/packages/extension-dapp/src/index.ts +++ b/packages/extension-dapp/src/index.ts @@ -44,10 +44,12 @@ let web3EnablePromise: Promise | null = null; export { isWeb3Injected, web3EnablePromise }; +const CENNZNET_EXT = "cennznet-extension"; + function getWindowExtensions (originName: string): Promise<[InjectedExtensionInfo, Injected | void][]> { if (win.injectedWeb3["cennznet-extension"]) { return Promise.all( - Object.entries([win.injectedWeb3["cennznet-extension"]]).map(([name, {enable, version}]): Promise<[InjectedExtensionInfo, Injected | void]> => + Object.entries([win.injectedWeb3[CENNZNET_EXT]]).map(([name, {enable, version}]): Promise<[InjectedExtensionInfo, Injected | void]> => Promise.all([ Promise.resolve({name, version}), enable(originName).catch((error: Error): void => {