Skip to content

Commit

Permalink
release v9
Browse files Browse the repository at this point in the history
  • Loading branch information
nicolasbrugneaux authored and aaronmgdr committed Oct 5, 2023
1 parent 720fd4d commit b997d18
Show file tree
Hide file tree
Showing 9 changed files with 83 additions and 16 deletions.
5 changes: 4 additions & 1 deletion .github/workflows/publish-contracts-abi-release.yml
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@ on:
jobs:
publish:
runs-on: ubuntu-latest
# TODO only do the action if tag is core-contract.v*
steps:
- uses: actions/checkout@v3
# Setup .npmrc file to publish to npm
Expand All @@ -16,7 +17,9 @@ jobs:
- run: cd packages/protocol
- run: yarn install
- run: yarn build:sol
# TODO: parse version number from release
env:
RELEASE_TYPE: release
# TODO: postbuild sets env variable matching the version
- run: yarn publish build/contracts --version TODO --no-git-tag-version
env:
NODE_AUTH_TOKEN: ${{ secrets.NPM_TOKEN }}
Expand Down
2 changes: 2 additions & 0 deletions .github/workflows/publish-contracts-abis-beta.yml
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,8 @@ jobs:
- run: cd packages/protocol
- run: yarn install
- run: yarn build:sol
env:
RELEASE_TYPE: prerelease
- run: yarn publish build/contracts --tag beta --prerelease --no-git-tag-version
env:
NODE_AUTH_TOKEN: ${{ secrets.NPM_TOKEN }}
Expand Down
3 changes: 3 additions & 0 deletions packages/protocol/contracts/.npmignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
test/*
package.abis.json
README.abis.md
2 changes: 1 addition & 1 deletion packages/protocol/contracts/package.abis.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "@celo/abis",
"version": "8.1.0",
"version": "9.0.0",
"author": "cLabs",
"license": "LGPL-3.0",
"repository": {
Expand Down
2 changes: 1 addition & 1 deletion packages/protocol/contracts/package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "@celo/contracts",
"version": "8.1.0",
"version": "9.0.0",
"author": "cLabs",
"license": "LGPL-3.0",
"repository": {
Expand Down
4 changes: 2 additions & 2 deletions packages/protocol/package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "@celo/protocol",
"version": "1.0.0",
"version": "9.0.0",
"private": true,
"main": "index.ts",
"author": "Celo",
Expand All @@ -23,7 +23,7 @@
"build": "yarn pull-submodules && yarn build:sol && yarn build:ts",
"postbuild:sol": "cp ./contracts/package.abis.json ./build/contracts/package.json && cp ./contracts/README.abis.md ./build/contracts/README.md",
"prebuild": "rm -rf ./build",
"postbuild": "./scripts/bash/prepare-contracts-and-abis-publishing.sh",
"postbuild": "ts-node ./scripts/prepare-contracts-and-abis-publishing.ts $npm_package_version",
"sourcify-publish": "ts-node ./scripts/sourcify-publish.ts",
"migrate": "./scripts/bash/migrate.sh",
"set_block_gas_limit": "./scripts/bash/set_block_gas_limit.sh",
Expand Down
Original file line number Diff line number Diff line change
@@ -1,10 +0,0 @@
#!/usr/bin/env bash
set -euo pipefail

mkdir -p ./build/contracts/types
ts-node ./scripts/build.ts --ethersTypes ./build/contracts/types/ethers
ts-node ./scripts/build.ts --web3Types ./build/contracts/types/web3
ts-node ./scripts/build.ts --truffleTypes ./build/contracts/types/truffle

cp ./contracts/package.abis.json ./build/contracts/package.json
cp ./contracts/README.abis.md ./build/contracts/README.md
68 changes: 68 additions & 0 deletions packages/protocol/scripts/prepare-contracts-and-abis-publishing.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,68 @@
import * as child_process from 'child_process'
import * as fs from 'fs'
import * as path from 'path'
import rimraf from 'rimraf'
import { version } from '../package.json'

const SRC_DIR = path.join(__dirname, '../contracts')
const BUILD_DIR = path.join(__dirname, '../build/contracts')
const TYPES_DIR = path.join(BUILD_DIR, 'types')
const BUILD_EXECUTABLE = path.join(__dirname, 'build.ts')

rimraf.sync(TYPES_DIR)
rimraf.sync(path.join(BUILD_DIR, 'package.json'))
rimraf.sync(path.join(BUILD_DIR, 'README.md'))
fs.mkdirSync(TYPES_DIR, { recursive: true })

const allFiles = lsRecursive(SRC_DIR)

child_process.execSync(
`ts-node ${BUILD_EXECUTABLE} --ethersTypes ${path.join(TYPES_DIR, 'ethers')}`,
{ stdio: 'inherit' }
)
child_process.execSync(`ts-node ${BUILD_EXECUTABLE} --web3Types ${path.join(TYPES_DIR, 'web3')}`, {
stdio: 'inherit',
})
child_process.execSync(
`ts-node ${BUILD_EXECUTABLE} --truffleTypes ${path.join(TYPES_DIR, 'truffle')}`,
{ stdio: 'inherit' }
)

allFiles.forEach((filePath) => {
const name = path.basename(filePath)
if (filePath.includes('/test/') || name.startsWith('Mock')) {
console.log('deleting', name)
rimraf.sync(path.join(BUILD_DIR, name.replace('sol', 'json')))
rimraf.sync(path.join(TYPES_DIR, 'ethers', name.replace('sol', '.d.ts')))
rimraf.sync(path.join(TYPES_DIR, 'web3', name.replace('sol', '.ts')))
}
})

fs.copyFileSync(path.join(SRC_DIR, 'package.abis.json'), path.join(BUILD_DIR, 'package.json'))
fs.copyFileSync(path.join(SRC_DIR, 'README.abis.md'), path.join(BUILD_DIR, 'README.md'))

if (process.env.RELEASE_TYPE === 'release') {
process.env.RELEASE_ABIS_VERSION = version
} else {
const latestRelease = child_process.execSync(`npm view @celo/contracts version`)
console.log(latestRelease.toString())
process.env.RELEASE_ABIS_VERSION = latestRelease.toString()
}

function lsRecursive(dir: string): string[] {
const filesAndDirectories = fs.readdirSync(dir, { withFileTypes: true })
return filesAndDirectories.reduce((fileNames, fileOrDir) => {
const filePath = path.join(dir, fileOrDir.name)
if (fileOrDir.isDirectory()) {
return fileNames.concat(lsRecursive(filePath))
}
return fileNames.concat([filePath])
}, [])
}

/*
❯ du -h build/contracts/
0B build/contracts//types
62M build/contracts/
*/
3 changes: 2 additions & 1 deletion packages/protocol/tsconfig.json
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,8 @@
"skipLibCheck": true,
"sourceMap": true,
"target": "es5",
"downlevelIteration": true
"downlevelIteration": true,
"resolveJsonModule": true
},
"exclude": ["node_modules"],
"references": [{ "path": "../sdk/utils" }]
Expand Down

0 comments on commit b997d18

Please sign in to comment.