diff --git a/.github/actions/build-hardhat/action.yml b/.github/actions/build-hardhat/action.yml new file mode 100644 index 00000000..1b2c8d4e --- /dev/null +++ b/.github/actions/build-hardhat/action.yml @@ -0,0 +1,15 @@ +name: Install & build contracts & package with hardhat. + +runs: + using: composite + + steps: + - uses: ./.github/actions/install + + - name: Build contracts + run: yarn build:hardhat --force # don't use compilation cache + shell: bash + + - name: Build package + run: yarn build:pkg + shell: bash \ No newline at end of file diff --git a/.github/workflows/formatting.yml b/.github/workflows/formatting.yml index 7915e568..ed822d33 100644 --- a/.github/workflows/formatting.yml +++ b/.github/workflows/formatting.yml @@ -12,6 +12,7 @@ concurrency: jobs: lint: + name: Lint runs-on: ubuntu-latest steps: - name: Generate a token diff --git a/.github/workflows/hardhat.yml b/.github/workflows/hardhat.yml index ece75147..03b0daf2 100644 --- a/.github/workflows/hardhat.yml +++ b/.github/workflows/hardhat.yml @@ -29,10 +29,5 @@ jobs: token: ${{ steps.generate-token.outputs.token }} submodules: recursive - - uses: ./.github/actions/install - - - name: Build contracts - run: yarn build:hardhat --force # don't use compilation cache - - - name: Build package - run: yarn build:pkg + - name: Build contracts & package with hardhat + uses: ./.github/actions/build-hardhat diff --git a/.github/workflows/release.yml b/.github/workflows/release.yml new file mode 100644 index 00000000..f28969e9 --- /dev/null +++ b/.github/workflows/release.yml @@ -0,0 +1,88 @@ +name: Publish on NPM + +on: + workflow_dispatch: + inputs: + version_type: + description: 'Version to release' + required: true + type: choice + options: + - patch + - minor + - major + +concurrency: + group: ${{ github.workflow }}-${{ github.ref }}-${{ github.event_name }} + cancel-in-progress: true + + +jobs: + build-and-deploy: + name: Build and Publish + runs-on: ubuntu-latest + steps: + - name: Generate a token + id: generate-token + uses: tibdex/github-app-token@b62528385c34dbc9f38e5f4225ac829252d1ea92 + with: + app_id: ${{ secrets.APP_ID }} + private_key: ${{ secrets.APP_PRIVATE_KEY }} + + - name: Checkout + uses: actions/checkout@v3 + with: + token: ${{ steps.generate-token.outputs.token }} + submodules: recursive + + - name: Build contracts & package with hardhat + uses: ./.github/actions/build-hardhat + + - name: Determine version + id: determine_version + run: | + if [ "${{ github.event.inputs.version_type }}" == "major" ]; then + version_type="major" + elif [ "${{ github.event.inputs.version_type }}" == "minor" ]; then + version_type="minor" + else + version_type="patch" + fi + echo "version_type=$version_type" >> $GITHUB_OUTPUT + shell: bash + + - name: Configure Git User + run: | + git config user.name "Morpho Intern" + git config user.email "intern@morpho.org" + + - name: Bump package.json version + run: | + version_type=$(echo "${{ steps.determine_version.outputs.version_type }}") + yarn version --${version_type} + + - name: Push to Correct Branch + run: | + git push origin $(echo "${{ github.ref }}" | sed 's|refs/heads/||') + + - name: Publish to npm + run: | + echo "//registry.npmjs.org/:_authToken=${{ secrets.NPM_TOKEN }}" > ~/.npmrc + yarn publish --access public + + - name: Create Git Tag + run: | + version=$(node -e "console.log(require('./package.json').version)") + git tag -a "v${version}" -m "Release version ${version}" + + - name: Push Git Tag + run: | + git push origin $(echo "${{ github.ref }}" | sed 's|refs/heads/||') --tags + + - name: Create GitHub Release + env: + GITHUB_TOKEN: ${{ steps.generate-token.outputs.token }} + run: | + version=$(node -e "console.log(require('./package.json').version)") + version_type=$(echo "${{ steps.determine_version.outputs.version_type }}") + curl -X POST -H "Authorization: token $GITHUB_TOKEN" -d "{\"tag_name\":\"v$version\",\"name\":\"Release $version_type $version\",\"body\":\"Release type: $version_type\n\nAdditional release notes can go here.\"}" "https://api.github.com/repos/${{ github.repository }}/releases" diff --git a/package.json b/package.json index 14eb6efa..ccc450e2 100644 --- a/package.json +++ b/package.json @@ -1,11 +1,12 @@ { - "name": "morpho-blue-bundlers", + "name": "@morpho-org/blue-bundlers", "description": "Morpho Blue Bundlers", "license": "GPL-2.0-or-later", - "version": "1.0.0", + "version": "0.0.0", "main": "dist/index.js", "files": [ - "dist/**/*" + "dist", + "package.json" ], "repository": { "type": "git", diff --git a/tsconfig.json b/tsconfig.json index 7e9cd652..fdbb3786 100644 --- a/tsconfig.json +++ b/tsconfig.json @@ -1,12 +1,13 @@ { "compilerOptions": { - "target": "esnext", + "target": "ES6", "strict": true, "esModuleInterop": true, - "rootDir": ".", + "rootDir": "", "baseUrl": ".", "outDir": "dist", - "moduleResolution": "node", + "module": "NodeNext", + "moduleResolution": "NodeNext", "resolveJsonModule": true, "declaration": true },