Skip to content

Commit

Permalink
new build script and CI config
Browse files Browse the repository at this point in the history
  • Loading branch information
kostysh committed Nov 5, 2020
1 parent 1e4684a commit 29ec402
Show file tree
Hide file tree
Showing 4 changed files with 78 additions and 0 deletions.
49 changes: 49 additions & 0 deletions .github/workflows/npm-publish.yml
Original file line number Diff line number Diff line change
@@ -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}}
File renamed without changes.
6 changes: 6 additions & 0 deletions index.js
Original file line number Diff line number Diff line change
Expand Up @@ -4,12 +4,18 @@ 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,
DirectoryContract: DirectoryContract,
DirectoryIndexContract: DirectoryIndexContract,
DirectoryIndexInterfaceContract: DirectoryIndexInterfaceContract,
DirectoryInterfaceContract: DirectoryInterfaceContract,
addresses: {
DirectoryIndex: {
ropsten: ropstenDirectoryIndexConfig.contract.proxy
}
}
};

23 changes: 23 additions & 0 deletions scripts/build-index.js
Original file line number Diff line number Diff line change
Expand Up @@ -2,14 +2,22 @@ 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',
'^DirectoryInterface.json',
'^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 = [];
Expand All @@ -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')}
Expand Down

0 comments on commit 29ec402

Please sign in to comment.