Skip to content

Commit

Permalink
Merge pull request #296 from morpho-labs/feat/publish-to-npm
Browse files Browse the repository at this point in the history
feat: add release CI
  • Loading branch information
julien-devatom authored Oct 24, 2023
2 parents 9c73205 + d0f812e commit 262ec4d
Show file tree
Hide file tree
Showing 6 changed files with 114 additions and 13 deletions.
15 changes: 15 additions & 0 deletions .github/actions/build-hardhat/action.yml
Original file line number Diff line number Diff line change
@@ -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
1 change: 1 addition & 0 deletions .github/workflows/formatting.yml
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@ concurrency:

jobs:
lint:
name: Lint
runs-on: ubuntu-latest
steps:
- name: Generate a token
Expand Down
9 changes: 2 additions & 7 deletions .github/workflows/hardhat.yml
Original file line number Diff line number Diff line change
Expand Up @@ -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
88 changes: 88 additions & 0 deletions .github/workflows/release.yml
Original file line number Diff line number Diff line change
@@ -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 "[email protected]"
- 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"
7 changes: 4 additions & 3 deletions package.json
Original file line number Diff line number Diff line change
@@ -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",
Expand Down
7 changes: 4 additions & 3 deletions tsconfig.json
Original file line number Diff line number Diff line change
@@ -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
},
Expand Down

0 comments on commit 262ec4d

Please sign in to comment.