From 29ec4029c50b0d45cd33d5b1b77cb9fca7647426 Mon Sep 17 00:00:00 2001 From: Kostiantyn Smyrnov Date: Thu, 5 Nov 2020 13:48:33 +0200 Subject: [PATCH] new build script and CI config --- .github/workflows/npm-publish.yml | 49 ++++++++++++++++++++++++++++++ .travis.yml => DISABLED_travis.yml | 0 index.js | 6 ++++ scripts/build-index.js | 23 ++++++++++++++ 4 files changed, 78 insertions(+) create mode 100644 .github/workflows/npm-publish.yml rename .travis.yml => DISABLED_travis.yml (100%) diff --git a/.github/workflows/npm-publish.yml b/.github/workflows/npm-publish.yml new file mode 100644 index 0000000..153c8a5 --- /dev/null +++ b/.github/workflows/npm-publish.yml @@ -0,0 +1,49 @@ +# This workflow will run tests using node and then publish a package to GitHub Packages when a release is created +# For more information see: https://help.github.com/actions/language-and-framework-guides/publishing-nodejs-packages + +name: Node.js Package + +on: + release: + types: [created] + +jobs: + build: + runs-on: ubuntu-latest + steps: + - uses: actions/checkout@v2 + - uses: actions/setup-node@v1 + with: + node-version: 10 + - run: npm ci + - run: npm test + + publish-npm: + needs: build + runs-on: ubuntu-latest + steps: + - uses: actions/checkout@v2 + - uses: actions/setup-node@v1 + with: + node-version: 10 + registry-url: https://registry.npmjs.org/ + - run: npm ci + - run: npm run build + - run: npm publish + env: + NODE_AUTH_TOKEN: ${{secrets.npm_token}} + + publish-gpr: + needs: build + runs-on: ubuntu-latest + steps: + - uses: actions/checkout@v2 + - uses: actions/setup-node@v1 + with: + node-version: 10 + registry-url: https://npm.pkg.github.com/ + - run: npm ci + - run: npm run build + - run: npm publish + env: + NODE_AUTH_TOKEN: ${{secrets.GITHUB_TOKEN}} diff --git a/.travis.yml b/DISABLED_travis.yml similarity index 100% rename from .travis.yml rename to DISABLED_travis.yml diff --git a/index.js b/index.js index b433005..712d053 100644 --- a/index.js +++ b/index.js @@ -4,6 +4,7 @@ const DirectoryContract = require('./build/contracts/Directory.json'); const DirectoryIndexContract = require('./build/contracts/DirectoryIndex.json'); const DirectoryIndexInterfaceContract = require('./build/contracts/DirectoryIndexInterface.json'); const DirectoryInterfaceContract = require('./build/contracts/DirectoryInterface.json'); +const ropstenDirectoryIndexConfig = require('./.openzeppelin/ropsten-DirectoryIndex.json'); module.exports = { ArbitrableDirectoryContract: ArbitrableDirectoryContract, @@ -11,5 +12,10 @@ module.exports = { DirectoryIndexContract: DirectoryIndexContract, DirectoryIndexInterfaceContract: DirectoryIndexInterfaceContract, DirectoryInterfaceContract: DirectoryInterfaceContract, + addresses: { + DirectoryIndex: { + ropsten: ropstenDirectoryIndexConfig.contract.proxy + } + } }; diff --git a/scripts/build-index.js b/scripts/build-index.js index 6b81a4c..b0bfed9 100755 --- a/scripts/build-index.js +++ b/scripts/build-index.js @@ -2,7 +2,9 @@ const fs = require('fs'); const path = require('path'); const BASE_PATH = 'build/contracts'; +const DEPLOYMENTS_PATH = '.openzeppelin'; const CONTRACTS_DIR = path.resolve(__dirname, `../${BASE_PATH}`); +const DEPLOYMENTS_DIR = path.resolve(__dirname, `../${DEPLOYMENTS_PATH}`); const bundle = [ '^Directory.json', '^DirectoryIndex.json', @@ -10,6 +12,12 @@ const bundle = [ '^DirectoryIndexInterface.json', '^ArbitrableDirectory.json' ]; + +// 'ropsten-ArbitrableDirectory-airlines.json', +// 'ropsten-ArbitrableDirectory-hotels.json', +// 'ropsten-ArbitrableDirectory-insurance.json', +// 'ropsten-ArbitrableDirectory-ota.json', + const files = fs.readdirSync(CONTRACTS_DIR); const bundleRegex = new RegExp(bundle.join('|')); const importStatements = []; @@ -23,6 +31,21 @@ files exportStatements.push(` ${name}Contract: ${name}Contract,`); }); +const addresses = []; +const deploymentsInfo = [ + { + contract: 'DirectoryIndex', + config: 'ropsten-DirectoryIndex.json' + } +]; +deploymentsInfo + .map(info => { + const network = info.config.split('-')[0]; + importStatements.push(`const ${network}${info.contract}Config = require('./${DEPLOYMENTS_PATH}/${info.config}');`); + addresses.push(` ${info.contract}: {\n ${network}: ${network}${info.contract}Config.contract.proxy\n }`); + }); +exportStatements.push(` addresses: {\n${addresses.join('\n')}\n }`); + const result = ` ${importStatements.join('\n')}