diff --git a/.github/workflows/pull_requests.yml b/.github/workflows/pull_requests.yml new file mode 100644 index 0000000..1a9c6cd --- /dev/null +++ b/.github/workflows/pull_requests.yml @@ -0,0 +1,10 @@ +on: + workflow_dispatch: + pull_request: + +name: 'Pull Request' + +jobs: + tests: + name: 'Lint and Tests' + uses: ./.github/workflows/tests.yml diff --git a/.github/workflows/release.yml b/.github/workflows/release.yml new file mode 100644 index 0000000..3624830 --- /dev/null +++ b/.github/workflows/release.yml @@ -0,0 +1,36 @@ +on: + push: + branches: + - main + - beta + - +([0-9])?(.{+([0-9]),x}).x + +name: 'Release' + +jobs: + tests: + name: 'Lint and Tests' + uses: ./.github/workflows/tests.yml + + release: + name: 'Publish Release' + needs: [tests] + runs-on: 'ubuntu-latest' + steps: + - uses: actions/checkout@v3 + - uses: actions/setup-node@v3 + with: + cache: npm + node-version: 16 + - run: npm ci --no-audit + - run: npm run build + - uses: codfish/semantic-release-action@v2 + id: semantic + env: + GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} + NPM_TOKEN: ${{ secrets.NPM_TOKEN }} + - name: 'Output new release version' + if: steps.semantic.outputs.new-release-published == 'true' + run: | + echo "## New Release Published" >> $GITHUB_STEP_SUMMARY + echo "🎉 ${{ steps.semantic.outputs.release-version }}" >> $GITHUB_STEP_SUMMARY diff --git a/.github/workflows/tests.yml b/.github/workflows/tests.yml new file mode 100644 index 0000000..e6f1daa --- /dev/null +++ b/.github/workflows/tests.yml @@ -0,0 +1,37 @@ +on: + workflow_call: + +name: 'Tests' + +jobs: + tests: + name: 'Pull Request Checks' + runs-on: 'ubuntu-latest' + steps: + - name: 'Check out the repo' + uses: actions/checkout@v3 + + - name: 'Install Node.js' + uses: actions/setup-node@v3 + with: + cache: npm + node-version: 16 + + - name: 'Install the dependencies' + run: npm ci --no-audit + + - name: 'Lint the code' + run: npm run lint + + - name: 'Add lint summary' + run: | + echo "## Lint results" >> $GITHUB_STEP_SUMMARY + echo "✅ Passed" >> $GITHUB_STEP_SUMMARY + + - name: 'Test run build' + run: npm run build + + - name: 'Add test summary' + run: | + echo "## Build results" >> $GITHUB_STEP_SUMMARY + echo "✅ Passed" >> $GITHUB_STEP_SUMMARY diff --git a/README.md b/README.md index d77e376..3d2823e 100644 --- a/README.md +++ b/README.md @@ -1,14 +1,14 @@ # ethers-decode-error -[![TypeScript version][ts-badge]][typescript-5-0] +[![Release][gha-badge]][gha-ci] [![TypeScript version][ts-badge]][typescript-5-0] [![License: Apache 2.0][license-badge]][license] +[gha-ci]: https://github.com/superical/ethers-decode-error/actions/workflows/release.yml +[gha-badge]: https://github.com/superical/ethers-decode-error/actions/workflows/release.yml/badge.svg [ts-badge]: https://img.shields.io/badge/TypeScript-5.0-blue.svg [typescript-5-0]: https://devblogs.microsoft.com/typescript/announcing-typescript-5-0/ [license-badge]: https://img.shields.io/badge/license-Apache_2.0-blue.svg [license]: https://github.com/superical/ethers-decode-error/blob/main/LICENSE -[gha-ci]: https://github.com/superical/ethers-decode-error/actions/workflows/release.yml -[gha-badge]: https://github.com/superical/ethers-decode-error/actions/workflows/release.yml/badge.svg For those who've grappled with extracting the actual error message or reason from the JSON RPC when a transaction fails or a smart contract reverts, you'll certainly appreciate how cumbersome it could at times. @@ -24,6 +24,7 @@ npm install ethers-decode-error --save ``` You will need to install ethers.js in your project if you have not: + ```bash npm install ethers@^5 --save ``` @@ -116,4 +117,4 @@ console.log('Custom error reason:', reason) ## Contributing -Feel free to open an issue or PR for any bugs/improvements. \ No newline at end of file +Feel free to open an issue or PR for any bugs/improvements.