Skip to content

Commit

Permalink
Merge pull request #387 from ckb-js/rc/v0.0.1-alpha
Browse files Browse the repository at this point in the history
  • Loading branch information
Keith-CY authored Jul 21, 2023
2 parents 47c69f0 + 05a5fe0 commit 0afbf2a
Show file tree
Hide file tree
Showing 330 changed files with 31,634 additions and 10,670 deletions.
10 changes: 10 additions & 0 deletions .eslintignore
Original file line number Diff line number Diff line change
@@ -1 +1,11 @@
*.js
*.md
*.txt
docker-compose.yml
dockerfile
*.toml
*.sh
*.rs
*.lock
contract/
*.mol
5 changes: 3 additions & 2 deletions .eslintrc.js
Original file line number Diff line number Diff line change
Expand Up @@ -8,9 +8,10 @@ module.exports = {
'error',
{
varsIgnorePattern: '^_',
argsIgnorePattern: '^_',
},
],
'@typescript-eslint/no-explicit-any': 'error',
'@typescript-eslint/explicit-module-boundary-types': 'error',
'@typescript-eslint/explicit-module-boundary-types': 'off',
},
};
}
7 changes: 7 additions & 0 deletions .github/.codecov.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
codecov:
require_ci_to_pass: yes

comment:
layout: 'reach,diff,flags,files,footer'
behavior: default
require_changes: no
9 changes: 9 additions & 0 deletions .github/release-drafter.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
name-template: 'v$RESOLVED_VERSION'
tag-template: 'v$RESOLVED_VERSION'

change-template: '- #$NUMBER: $TITLE (@$AUTHOR)'
change-title-escapes: '\<*_&@`'
template: |
## What's Changed
$CHANGES
67 changes: 67 additions & 0 deletions .github/workflows/bump-version.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,67 @@
name: Update versions and changelogs

on: create

jobs:
default:
name: Update versions and changelogs
runs-on: ubuntu-latest
permissions:
pull-requests: write # for updating PR
contents: write # for opening PR
env:
IS_RC_BRANCH: ${{ startsWith(github.ref_name, 'rc/v') }}
steps:
- name: Checkout
uses: actions/checkout@v3
with:
fetch-depth: '0'

- name: Setup Node.js
uses: actions/setup-node@v3
with:
node-version: 18.x

# this is a patch for incompatibility between lerna@7 and npm@9 https://github.com/lerna/lerna/issues/3418#issuecomment-1337756237
- name: Remove lock file
if: env.IS_RC_BRANCH == 'true'
run: rm package-lock.json

- name: Get version number
if: env.IS_RC_BRANCH == 'true'
id: version-number
run: |
branch_name=${{ github.ref_name }}
version_number=${branch_name#rc/v}
echo "version_number=${version_number}" >> $GITHUB_OUTPUT
- name: Update versions and changelogs
if: env.IS_RC_BRANCH == 'true'
id: changelog
run: |
npm run bump-version ${{ steps.version-number.outputs.version_number }}
git add CHANGELOG.md
changelog=$(git diff HEAD CHANGELOG.md | tail -n +7 | cut -c 2-)
echo -e "changelog<<EOF"$'\n'"$changelog"$'\n'EOF >> $GITHUB_OUTPUT
- name: Set GPG
if: env.IS_RC_BRANCH == 'true'
uses: crazy-max/ghaction-import-gpg@v5
with:
gpg_private_key: ${{ secrets.GPG_PRIVATE_KEY }}
passphrase: ${{ secrets.GPG_PASSPHRASE }}
git_user_signingkey: true
git_commit_gpgsign: true

- name: Open PR to rc branch
if: env.IS_RC_BRANCH == 'true'
uses: peter-evans/create-pull-request@v5
with:
title: Update versions and changelogs for ${{ steps.version-number.outputs.version_number }}
commit-message: 'chore: update versions and changelogs'
body: ${{ steps.changelog.outputs.changelog }}
committer: Chen Yu <[email protected]>
branch: chore-update-version-for-${{ github.ref_name }}
add-paths: ':!package-lock.json'
66 changes: 66 additions & 0 deletions .github/workflows/deploy.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,66 @@
name: Deploy
on:
push:
branches:
- 'develop'
paths:
- 'packages/samples/**'

jobs:
build:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v3

- uses: actions/setup-node@v3
with:
node-version: 18

- name: restore lerna
uses: actions/cache@v3
with:
path: '**/node_modules'
key: ${{ runner.os }}-${{ hashFiles('**/package-lock.json') }}

- name: Install project dependencies and build
run: npm i

- name: Build packages
run: npm run build

- name: Get GitHub organization or user
run: echo 'ORG='$(echo $(dirname ${GITHUB_REPOSITORY}) | awk '{print tolower($0)}' | tr -d - ) >> $GITHUB_ENV

- name: Set up QEMU
uses: docker/setup-qemu-action@v2

- name: Set up Docker Buildx
uses: docker/setup-buildx-action@v2

- name: Login to DockerHub
uses: docker/login-action@v2
with:
username: ${{ secrets.DOCKER_USER }}
password: ${{ secrets.DOCKER_TOKEN }}

- name: Build and push
uses: docker/build-push-action@v4
with:
context: .
file: docker/mvp-dapp/Dockerfile
pull: true
push: true
tags: ${{ env.ORG }}/kuai-mvp-dapp:latest
platforms: linux/amd64,linux/arm64
cache-from: type=gha
cache-to: type=gha,mode=max

redeploy:
name: Redeploy webhook call
runs-on: ubuntu-latest
needs: [build]
steps:
- name: Deploy docker container webhook
uses: joelwmale/webhook-action@master
env:
WEBHOOK_URL: ${{ secrets.DEPLOY_WEBHOOK_URL }}
41 changes: 41 additions & 0 deletions .github/workflows/open-pr-to-main.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,41 @@
name: Open PR from rc branch to main branch

on:
pull_request:
types:
- closed
branches:
- rc/v*

jobs:
default:
name: Open PR from rc branch to main branch
runs-on: ubuntu-latest
permissions:
pull-requests: write # for updating PR
contents: write # for opening PR
env:
IS_VERSION_MERGED: ${{ github.event.pull_request.merged == true && startsWith(github.head_ref, 'chore-update-version-for-rc/') }}
steps:
- name: Debug
run: |
echo $IS_VERSION_MERGED
- name: Checkout
uses: actions/checkout@v3

- name: Open PR to main branch
uses: actions/script@v6
with:
script: |
github.rest.pulls.create({
owner: context.repo.owner,
repo: context.repo.repo,
head: context.ref,
base: 'main',
title: `Merge ${context.ref} to main branch`,
body: `Ready to release ${context.ref}`
})
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
38 changes: 38 additions & 0 deletions .github/workflows/publish-packages.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,38 @@
name: Publish packages to npm registry
on:
release:
types:
- published

jobs:
publish:
runs-on: ubuntu-latest
steps:
- name: Checkout
uses: actions/checkout@v3

- name: Set registry
uses: actions/setup-node@v3
with:
node-version: 18
registry-url: https://registry.npmjs.org

- name: restore lerna
uses: actions/cache@v3
with:
path: '**/node_modules'
key: ${{ runner.os }}-${{ hashFiles('**/package-lock.json') }}

- name: Install dependencies
run: npm ci

- name: Build packages
run: npm run build

- name: Run test
run: npx lerna run test

- name: Publish
run: npm run publish:all
env:
NODE_AUTH_TOKEN: ${{ secrets.NPM_TOKEN }}
22 changes: 22 additions & 0 deletions .github/workflows/release-draft.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
name: Release draft

on:
pull_request:
types:
- closed
branches:
- main

jobs:
release:
name: Create Release
runs-on: ubuntu-latest
permissions:
contents: write # for creating release
env:
IS_RC_MERGED: ${{ github.event.pull_requst.merged == true && startsWith(github.head_ref, 'rc/v')}}
steps:
- name: Create a release draft
uses: release-drafter/release-drafter@v5
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
9 changes: 6 additions & 3 deletions .github/workflows/test.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -17,10 +17,13 @@ jobs:
key: ${{ runner.os }}-${{ hashFiles('**/package-lock.json') }}

- name: Install project dependencies and build
run: npx lerna bootstrap
run: npm i

- name: Build packages
run: npm run build

- name: Run unit test
run: yarn test
- name: Run test with coverage
run: npx lerna run test -- --coverage

- name: Upload coverage to Codecov
uses: codecov/codecov-action@v3
8 changes: 8 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -6,4 +6,12 @@ lerna-debug.log*
node_modules/
**/lib

# build cache
.tsbuildinfo

.idea
yarn.lock

# Coverage directory used by tools like istanbul
coverage
*.lcov
3 changes: 2 additions & 1 deletion .prettierrc
Original file line number Diff line number Diff line change
Expand Up @@ -2,5 +2,6 @@
"printWidth": 120,
"trailingComma": "all",
"singleQuote": true,
"arrowParens": "always"
"arrowParens": "always",
"semi": false
}
Loading

0 comments on commit 0afbf2a

Please sign in to comment.