Skip to content

Commit

Permalink
Merge pull request #81 from polywrap/nk/cd
Browse files Browse the repository at this point in the history
refactor: keep version of all the wrappers 0.1.0
  • Loading branch information
Niraj-Kamdar authored Jul 20, 2022
2 parents 739bd90 + 456c8b9 commit 35ebbc4
Show file tree
Hide file tree
Showing 12 changed files with 201 additions and 6 deletions.
1 change: 1 addition & 0 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@ on:
push:
branches:
- main
- dev
pull_request:

jobs:
Expand Down
142 changes: 142 additions & 0 deletions .github/workflows/release.yml
Original file line number Diff line number Diff line change
@@ -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/[email protected]
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/[email protected]
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/[email protected]
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
1 change: 1 addition & 0 deletions VERSION
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
v0.1.0
2 changes: 1 addition & 1 deletion hello-world/wrapper/assemblyscript/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -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",
Expand Down
2 changes: 1 addition & 1 deletion hello-world/wrapper/rust/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -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",
Expand Down
2 changes: 1 addition & 1 deletion json-rpc/wrapper/assemblyscript/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -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",
Expand Down
2 changes: 1 addition & 1 deletion json-rpc/wrapper/rust/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -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",
Expand Down
16 changes: 16 additions & 0 deletions scripts/release/checkEnsExists.js
Original file line number Diff line number Diff line change
@@ -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");
}
16 changes: 16 additions & 0 deletions scripts/release/getIpfsCid.js
Original file line number Diff line number Diff line change
@@ -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]);
19 changes: 19 additions & 0 deletions scripts/release/getPackageData.js
Original file line number Diff line number Diff line change
@@ -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)]);
2 changes: 1 addition & 1 deletion simple-storage/app/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -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",
Expand Down
2 changes: 1 addition & 1 deletion subgraph-query/wrapper/rust/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -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",
Expand Down

0 comments on commit 35ebbc4

Please sign in to comment.