diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index ff17bdb6..3ec78712 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -3,6 +3,7 @@ on: push: branches: - main + - dev pull_request: jobs: diff --git a/.github/workflows/release.yml b/.github/workflows/release.yml new file mode 100644 index 00000000..f16c41fc --- /dev/null +++ b/.github/workflows/release.yml @@ -0,0 +1,142 @@ +name: Release +on: + workflow_run: + workflows: [CI] + types: [completed] + branches: [main] + +jobs: + GetVersion: + runs-on: ubuntu-latest + timeout-minutes: 60 + outputs: + version: ${{ steps.version.outputs.value }} + steps: + - name: Checkout code + uses: actions/checkout@v2 + - id: version + name: Get version + run: echo "::set-output name=value::$(cat VERSION | grep v)" + + Github-release: + name: Create Release + runs-on: ubuntu-latest + needs: + - GetVersion + steps: + - name: Checkout code + uses: actions/checkout@v2 + - name: print version with needs + run: echo ${{ needs.GetVersion.outputs.version }} + - name: Create Release + id: create_release + uses: actions/create-release@v1 + env: + GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} + with: + tag_name: ${{ needs.GetVersion.outputs.version }} + release_name: Release ${{ needs.GetVersion.outputs.version }} + draft: false + prerelease: false + + Deploy-Built-Artifacts: + strategy: + matrix: + package: + - hello-world,hello + - simple-storage,simple-storage + - json-rpc,jsonrpc + - subgraph-query,subgraph + language: + - assemblyscript + - rust + + runs-on: ubuntu-latest + timeout-minutes: 60 + env: + CI: false + steps: + - name: Checkout repository + uses: actions/checkout@v2 + - name: Read .nvmrc + run: echo ::set-output name=NVMRC::$(cat .nvmrc) + id: nvm + - name: Setup Node.js + uses: actions/setup-node@master + with: + node-version: "${{ steps.nvm.outputs.NVMRC }}" + - name: Get yarn cache directory path + id: yarn-cache-dir-path + run: echo "::set-output name=dir::$(yarn cache dir)" + - uses: actions/cache@v2 + with: + path: ${{ steps.yarn-cache-dir-path.outputs.dir }} + key: ${{ runner.os }}-yarn-deployments-v1 + restore-keys: | + ${{ runner.os }}-yarn-deployments- + + # Install packages + - name: Install pinata cli + run: yarn global add pinata-upload-cli + - name: Install ethers cli + run: yarn global add @ethersproject/cli + + # Get Package Metadata + - id: package + name: Get Package Metadata + run: | + echo ::set-output name=name::$(node ./scripts/release/getPackageData.js ${{ matrix.package }} ${{ matrix.language }} 0) + echo ::set-output name=uri::$(node ./scripts/release/getPackageData.js ${{ matrix.package }} ${{ matrix.language }} 1) + + # Setup Pinata + - name: Setup Pinata + run: pinata-cli -a ${{ secrets.PINATA_API_KEY }} + + # Fetch Built Wrappers + - uses: dawidd6/action-download-artifact@v2 + with: + github_token: ${{secrets.GITHUB_TOKEN}} + workflow: ci.yml + workflow_conclusion: success + branch: main + event: push + name: ${{ steps.package.outputs.name }}-${{ matrix.language }}-build-artifact + path: ./${{ steps.package.outputs.name }} + - name: create deployments + run: mkdir ./deployments # fails if dir already exists but that's okay + continue-on-error: true + + # Deploy wrappers to IPFS + - name: Deploy current wrapper to IPFS + run: pinata-cli -u ./${{ steps.package.outputs.name }} > ./deployments/${{ steps.package.outputs.name }}.ipfs.txt + - id: ipfs + name: Fetch IPFS CID for current wrapper + run: echo ::set-output name=value::$(node ./scripts/release/getIpfsCid.js "$(cat ./deployments/${{ steps.package.outputs.name }}.ipfs.txt)") + + # Deploy wrappers to ENS + - id: ensExists + name: Check if ens uri exists + run: 'echo ::set-output name=value::$(node ./scripts/release/checkEnsExists.js "$(ethers-ens lookup ${{ steps.package.outputs.uri }} --rpc https://goerli.infura.io/v3/${{ secrets.INFURA_KEY }})")' + + - name: Create ens subdomain uri + uses: Wandalen/wretry.action@v1.0.11 + with: + command: ethers-ens set-subnode "${{ steps.package.outputs.uri }}" --account ${{ secrets.PRIVATE_KEY }} --rpc https://goerli.infura.io/v3/${{ secrets.INFURA_KEY }} --yes --wait + attempt_limit: 3 + attempt_delay: 20000 + if: ${{ (steps.ensExists.outputs.value == 'false') }} + + - name: Set Resolver for created ens subdomain + uses: Wandalen/wretry.action@v1.0.11 + with: + command: "ethers-ens set-resolver ${{ steps.package.outputs.uri }} --account ${{ secrets.PRIVATE_KEY }} --rpc https://goerli.infura.io/v3/${{ secrets.INFURA_KEY }} --yes --wait" + attempt_limit: 3 + attempt_delay: 20000 + if: ${{ (steps.ensExists.outputs.value == 'false') }} + + - name: Publish current wrapper to ENS + uses: Wandalen/wretry.action@v1.0.11 + with: + command: "ethers-ens set-content ${{ steps.package.outputs.uri }} ${{ steps.ipfs.outputs.value }} --account ${{ secrets.PRIVATE_KEY }} --rpc https://goerli.infura.io/v3/${{ secrets.INFURA_KEY }} --yes --wait" + attempt_limit: 3 + attempt_delay: 20000 diff --git a/VERSION b/VERSION new file mode 100644 index 00000000..9ff151c5 --- /dev/null +++ b/VERSION @@ -0,0 +1 @@ +v0.1.0 \ No newline at end of file diff --git a/hello-world/wrapper/assemblyscript/package.json b/hello-world/wrapper/assemblyscript/package.json index 6295a70c..9df73845 100644 --- a/hello-world/wrapper/assemblyscript/package.json +++ b/hello-world/wrapper/assemblyscript/package.json @@ -2,7 +2,7 @@ "name": "hello-world-demo", "description": "Polywrap Hello World Demo", "private": true, - "version": "1.0.0", + "version": "0.1.0", "scripts": { "build": "polywrap build", "codegen": "polywrap codegen", diff --git a/hello-world/wrapper/rust/package.json b/hello-world/wrapper/rust/package.json index 7f7b8cde..7c40888a 100644 --- a/hello-world/wrapper/rust/package.json +++ b/hello-world/wrapper/rust/package.json @@ -2,7 +2,7 @@ "name": "hello-world-demo", "description": "Polywrap Hello World Demo", "private": true, - "version": "1.0.0", + "version": "0.1.0", "scripts": { "build": "polywrap build", "codegen": "polywrap codegen", diff --git a/json-rpc/wrapper/assemblyscript/package.json b/json-rpc/wrapper/assemblyscript/package.json index 6b3f1273..3bcbc4f5 100644 --- a/json-rpc/wrapper/assemblyscript/package.json +++ b/json-rpc/wrapper/assemblyscript/package.json @@ -2,7 +2,7 @@ "name": "json-rpc-demo-as", "description": "Polywrap AssemblyScript Wrapper Demo: JSON-RPC with HTTP plugin", "private": true, - "version": "0.2.0", + "version": "0.1.0", "scripts": { "build": "npx polywrap build", "test:env:up": "npx polywrap infra up --modules=eth-ens-ipfs", diff --git a/json-rpc/wrapper/rust/package.json b/json-rpc/wrapper/rust/package.json index cdbc429b..0bd07372 100644 --- a/json-rpc/wrapper/rust/package.json +++ b/json-rpc/wrapper/rust/package.json @@ -2,7 +2,7 @@ "name": "json-rpc-demo-rs", "description": "Polywrap Rust Wrapper Demo: JSON-RPC with HTTP plugin", "private": true, - "version": "0.2.0", + "version": "0.1.0", "scripts": { "build": "npx polywrap build", "test:env:up": "npx polywrap infra up --modules=eth-ens-ipfs", diff --git a/scripts/release/checkEnsExists.js b/scripts/release/checkEnsExists.js new file mode 100644 index 00000000..1d27661d --- /dev/null +++ b/scripts/release/checkEnsExists.js @@ -0,0 +1,16 @@ +const argv = process.argv.slice(2); + +if (argv.length !== 1) { + throw Error(`Require 1 arguments, passed: ${argv.length}`); +} + +const str = argv[0]; +const pattern = /Resolver:[\t\n ]*0x([A-Za-z0-9]*)/; + +const match = str.match(pattern); + +if (!match || match.length < 2 || !match[1]) { + console.log("false"); +} else { + console.log("true"); +} diff --git a/scripts/release/getIpfsCid.js b/scripts/release/getIpfsCid.js new file mode 100644 index 00000000..44e5721a --- /dev/null +++ b/scripts/release/getIpfsCid.js @@ -0,0 +1,16 @@ +const argv = process.argv.slice(2); + +if (argv.length !== 1) { + throw Error(`Require 1 arguments, passed: ${argv.length}`); +} + +const str = argv[0]; +const pattern = /IpfsHash:[\t\n ]*'([A-Za-z0-9]*)'/; + +const match = str.match(pattern); + +if (!match) { + throw new Error(`No IPFS CID found in deployment log:\n ${str}`); +} + +console.log(match[1]); diff --git a/scripts/release/getPackageData.js b/scripts/release/getPackageData.js new file mode 100644 index 00000000..d9ba38ac --- /dev/null +++ b/scripts/release/getPackageData.js @@ -0,0 +1,19 @@ +const argv = process.argv.slice(2); + +if (argv.length !== 3) { + throw Error(`Require 3 arguments, passed: ${argv.length}`); +} + +const langAlias = { + assemblyscript: "as", + rust: "rs" +} + +const str = argv[0]; +const lang = langAlias[argv[1]]; +const idx = argv[2]; + +const arr = str.split(","); +arr[1] = `${arr[1]}.${lang}.demos.wraplib.eth` + +console.log(arr[parseInt(idx)]); diff --git a/simple-storage/app/package.json b/simple-storage/app/package.json index eb1ea95f..692f645d 100644 --- a/simple-storage/app/package.json +++ b/simple-storage/app/package.json @@ -2,7 +2,7 @@ "name": "@polywrap/demo-simple-storage-dapp", "description": "Polywrap SimpleStorage dApp Demo", "private": true, - "version": "0.2.0", + "version": "0.1.0", "license": "MIT", "repository": { "type": "git", diff --git a/subgraph-query/wrapper/rust/package.json b/subgraph-query/wrapper/rust/package.json index c4f85136..49802ffb 100644 --- a/subgraph-query/wrapper/rust/package.json +++ b/subgraph-query/wrapper/rust/package.json @@ -2,7 +2,7 @@ "name": "subgraph-query-rs", "description": "Subgraph query demo rust wrapper", "private": true, - "version": "0.1.1", + "version": "0.1.0", "scripts": { "build": "npx polywrap build", "postbuild": "yarn codegen:app",