From 2b0f956c52afc7ae88badbd329b637615848f464 Mon Sep 17 00:00:00 2001 From: Ivan Voskoboinyk Date: Tue, 9 May 2023 13:50:59 +0300 Subject: [PATCH 1/3] Automatically Open Github release page after publishing --- package.json | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/package.json b/package.json index e959479d6..70357b8ef 100644 --- a/package.json +++ b/package.json @@ -33,7 +33,8 @@ "release": "pnpm release:prepare && pnpm release:publish", "release:build": "pnpm build --force", "release:prepare": "pnpm release:build && pnpm check", - "release:publish": "lerna publish" + "release:publish": "lerna publish", + "postpublish": "open-cli https://github.com/prezly/slate/releases/new?tag=$(cat lerna.json | grep version | cut -d\\\" -f4)" }, "devEngines": { "node": ">= 16.13.0", @@ -97,6 +98,7 @@ "lerna": "^6.6.2", "mocha": "^10.2.0", "mocha-expect-snapshot": "^7.0.0", + "open-cli": "^7.2.0", "postcss": "^8.4.1", "postcss-modules": "^4.3.0", "prettier": "^2.8.8", From a74fd2d17a57ae273306aa13cdb07bdff8f52c84 Mon Sep 17 00:00:00 2001 From: Ivan Voskoboinyk Date: Tue, 9 May 2023 14:12:32 +0300 Subject: [PATCH 2/3] Simplify Github Actions configuration by extracting common steps into a composite action See https://github.com/prezly/setup-github-actions --- .github/workflows/build.yml | 90 ++++++++++---------------- .github/workflows/dependencies.yml | 86 ++++++++++--------------- .github/workflows/prettier.yml | 52 +++++---------- .github/workflows/storybook.yml | 100 ++++++++++++----------------- .github/workflows/test.yml | 94 +++++++++++---------------- 5 files changed, 161 insertions(+), 261 deletions(-) diff --git a/.github/workflows/build.yml b/.github/workflows/build.yml index 625d0039f..ef18e1463 100644 --- a/.github/workflows/build.yml +++ b/.github/workflows/build.yml @@ -1,59 +1,39 @@ name: Build -on: [push] +on: push jobs: - build: - runs-on: ubuntu-latest - - strategy: - matrix: - node-version: [16.x] - react-version: [16.14.0, 17, 18] - - steps: - - uses: actions/checkout@v2 - - - name: Use Node.js ${{ matrix.node-version }} - uses: actions/setup-node@v1 - with: - node-version: ${{ matrix.node-version }} - - - uses: pnpm/action-setup@v2 - name: Install pnpm - id: pnpm-install - with: - version: 8.4.0 - run_install: false - - - name: Get pnpm store directory - id: pnpm-cache - shell: bash - run: | - echo "STORE_PATH=$(pnpm store path)" >> $GITHUB_OUTPUT - - - uses: actions/cache@v3 - name: Setup pnpm cache - with: - path: ${{ steps.pnpm-cache.outputs.STORE_PATH }} - key: ${{ runner.os }}-pnpm-store-${{ hashFiles('**/pnpm-lock.yaml') }} - restore-keys: | - ${{ runner.os }}-pnpm-store- - - - name: Set React ${{ matrix.react-version }} - uses: jossef/action-set-json-field@v2.1 - with: - file: package.json - parse_json: true - field: pnpm.overrides - value: '{"@types/react":"${{ env.REACT_TYPES_VERSION }}","@types/react-dom":"${{ env.REACT_DOM_TYPES_VERSION }}","react":"${{ env.REACT_VERSION }}","react-dom":"${{ env.REACT_DOM_VERSION }}"}' - env: - REACT_TYPES_VERSION: ${{ matrix.react-version }} - REACT_VERSION: ${{ matrix.react-version }} - REACT_DOM_TYPES_VERSION: ${{ startsWith(matrix.react-version, '16.') && '16.9.9' || matrix.react-version }} - REACT_DOM_VERSION: ${{ matrix.react-version }} - - - name: Install dependencies - run: pnpm install --no-frozen-lockfile - - - run: pnpm build + build: + runs-on: ubuntu-latest + + strategy: + matrix: + node-version: [ 16.x ] + react-version: [ 16.14.0, 17, 18 ] + + steps: + - uses: actions/checkout@v2 + + - name: Setup Environment + uses: prezly/setup-github-actions@v1 + with: + node: ${{ matrix.node-version }} + pnpm: "8.4.0" + + - name: Set React ${{ matrix.react-version }} + uses: jossef/action-set-json-field@v2.1 + with: + file: package.json + parse_json: true + field: pnpm.overrides + value: '{"@types/react":"${{ env.REACT_TYPES_VERSION }}","@types/react-dom":"${{ env.REACT_DOM_TYPES_VERSION }}","react":"${{ env.REACT_VERSION }}","react-dom":"${{ env.REACT_DOM_VERSION }}"}' + env: + REACT_TYPES_VERSION: ${{ matrix.react-version }} + REACT_VERSION: ${{ matrix.react-version }} + REACT_DOM_TYPES_VERSION: ${{ startsWith(matrix.react-version, '16.') && '16.9.9' || matrix.react-version }} + REACT_DOM_VERSION: ${{ matrix.react-version }} + + - name: Install dependencies + run: pnpm install --no-frozen-lockfile + + - run: pnpm build diff --git a/.github/workflows/dependencies.yml b/.github/workflows/dependencies.yml index 6c7abc098..1333fdd8e 100644 --- a/.github/workflows/dependencies.yml +++ b/.github/workflows/dependencies.yml @@ -1,57 +1,37 @@ name: Dependencies Alignment -on: [push] +on: push jobs: - build: - runs-on: ubuntu-latest - - strategy: - matrix: - node-version: [16.x] - react-version: [16.14.0, 17, 18] - - steps: - - uses: actions/checkout@v2 - - - name: Use Node.js ${{ matrix.node-version }} - uses: actions/setup-node@v1 - with: - node-version: ${{ matrix.node-version }} - - - uses: pnpm/action-setup@v2 - name: Install pnpm - id: pnpm-install - with: - version: 8.4.0 - run_install: false - - - name: Get pnpm store directory - id: pnpm-cache - shell: bash - run: | - echo "STORE_PATH=$(pnpm store path)" >> $GITHUB_OUTPUT - - - uses: actions/cache@v3 - name: Setup pnpm cache - with: - path: ${{ steps.pnpm-cache.outputs.STORE_PATH }} - key: ${{ runner.os }}-pnpm-store-${{ hashFiles('**/pnpm-lock.yaml') }} - restore-keys: | - ${{ runner.os }}-pnpm-store- - - - name: Set React ${{ matrix.react-version }} - uses: jossef/action-set-json-field@v2.1 - with: - file: package.json - parse_json: true - field: pnpm.overrides - value: '{"@types/react":"${{ env.REACT_TYPES_VERSION }}","@types/react-dom":"${{ env.REACT_DOM_TYPES_VERSION }}","react":"${{ env.REACT_VERSION }}","react-dom":"${{ env.REACT_DOM_VERSION }}"}' - env: - REACT_TYPES_VERSION: ${{ matrix.react-version }} - REACT_VERSION: ${{ matrix.react-version }} - REACT_DOM_TYPES_VERSION: ${{ startsWith(matrix.react-version, '16.') && '16.9.9' || matrix.react-version }} - REACT_DOM_VERSION: ${{ matrix.react-version }} - - - name: Install dependencies - run: pnpm install --no-frozen-lockfile --strict-peer-dependencies --ignore-pnpmfile --prod + build: + runs-on: ubuntu-latest + + strategy: + matrix: + node-version: [ 16.x ] + react-version: [ 16.14.0, 17, 18 ] + + steps: + - uses: actions/checkout@v2 + + - name: Setup Environment + uses: prezly/setup-github-actions@v1 + with: + node: ${{ matrix.node-version }} + pnpm: "8.4.0" + + - name: Set React ${{ matrix.react-version }} + uses: jossef/action-set-json-field@v2.1 + with: + file: package.json + parse_json: true + field: pnpm.overrides + value: '{"@types/react":"${{ env.REACT_TYPES_VERSION }}","@types/react-dom":"${{ env.REACT_DOM_TYPES_VERSION }}","react":"${{ env.REACT_VERSION }}","react-dom":"${{ env.REACT_DOM_VERSION }}"}' + env: + REACT_TYPES_VERSION: ${{ matrix.react-version }} + REACT_VERSION: ${{ matrix.react-version }} + REACT_DOM_TYPES_VERSION: ${{ startsWith(matrix.react-version, '16.') && '16.9.9' || matrix.react-version }} + REACT_DOM_VERSION: ${{ matrix.react-version }} + + - name: Install dependencies + run: pnpm install --no-frozen-lockfile --strict-peer-dependencies --ignore-pnpmfile --prod diff --git a/.github/workflows/prettier.yml b/.github/workflows/prettier.yml index 6ba6f201b..804be02a4 100644 --- a/.github/workflows/prettier.yml +++ b/.github/workflows/prettier.yml @@ -1,45 +1,25 @@ name: Prettier -on: [push] +on: push jobs: - build: - runs-on: ubuntu-latest + build: + runs-on: ubuntu-latest - strategy: - matrix: - node-version: [16.x] + strategy: + matrix: + node-version: [ 16.x ] - steps: - - uses: actions/checkout@v2 + steps: + - uses: actions/checkout@v2 - - name: Use Node.js ${{ matrix.node-version }} - uses: actions/setup-node@v1 - with: - node-version: ${{ matrix.node-version }} + - name: Setup Environment + uses: prezly/setup-github-actions@v1 + with: + node: ${{ matrix.node-version }} + pnpm: "8.4.0" - - uses: pnpm/action-setup@v2 - name: Install pnpm - id: pnpm-install - with: - version: 8.4.0 - run_install: false + - name: Install dependencies + run: pnpm install - - name: Get pnpm store directory - id: pnpm-cache - shell: bash - run: | - echo "STORE_PATH=$(pnpm store path)" >> $GITHUB_OUTPUT - - - uses: actions/cache@v3 - name: Setup pnpm cache - with: - path: ${{ steps.pnpm-cache.outputs.STORE_PATH }} - key: ${{ runner.os }}-pnpm-store-${{ hashFiles('**/pnpm-lock.yaml') }} - restore-keys: | - ${{ runner.os }}-pnpm-store- - - - name: Install dependencies - run: pnpm install - - - run: pnpm prettier + - run: pnpm prettier diff --git a/.github/workflows/storybook.yml b/.github/workflows/storybook.yml index 394cb8555..8a605a833 100644 --- a/.github/workflows/storybook.yml +++ b/.github/workflows/storybook.yml @@ -1,64 +1,44 @@ name: Build Storybook -on: [push] +on: push jobs: - build: - runs-on: ubuntu-latest - - strategy: - matrix: - node-version: [16.x] - react-version: [16.14.0, 17, 18] - - steps: - - uses: actions/checkout@v2 - - - name: Use Node.js ${{ matrix.node-version }} - uses: actions/setup-node@v1 - with: - node-version: ${{ matrix.node-version }} - - - uses: pnpm/action-setup@v2 - name: Install pnpm - id: pnpm-install - with: - version: 8.4.0 - run_install: false - - - name: Get pnpm store directory - id: pnpm-cache - shell: bash - run: | - echo "STORE_PATH=$(pnpm store path)" >> $GITHUB_OUTPUT - - - uses: actions/cache@v3 - name: Setup pnpm cache - with: - path: ${{ steps.pnpm-cache.outputs.STORE_PATH }} - key: ${{ runner.os }}-pnpm-store-${{ hashFiles('**/pnpm-lock.yaml') }} - restore-keys: | - ${{ runner.os }}-pnpm-store- - - - name: Set React ${{ matrix.react-version }} - uses: jossef/action-set-json-field@v2.1 - with: - file: package.json - parse_json: true - field: pnpm.overrides - value: '{"@types/react":"${{ env.REACT_TYPES_VERSION }}","@types/react-dom":"${{ env.REACT_DOM_TYPES_VERSION }}","react":"${{ env.REACT_VERSION }}","react-dom":"${{ env.REACT_DOM_VERSION }}"}' - env: - REACT_TYPES_VERSION: ${{ matrix.react-version }} - REACT_VERSION: ${{ matrix.react-version }} - REACT_DOM_TYPES_VERSION: ${{ startsWith(matrix.react-version, '16.') && '16.9.9' || matrix.react-version }} - REACT_DOM_VERSION: ${{ matrix.react-version }} - - - name: Install dependencies - run: pnpm install --no-frozen-lockfile - - - name: Build Project - run: pnpm build - - - name: Build Storybook - run: pnpm storybook:build - working-directory: packages/slate-editor + build: + runs-on: ubuntu-latest + + strategy: + matrix: + node-version: [ 16.x ] + react-version: [ 16.14.0, 17, 18 ] + + steps: + - uses: actions/checkout@v2 + + - name: Setup Environment + uses: prezly/setup-github-actions@v1 + with: + node: ${{ matrix.node-version }} + pnpm: "8.4.0" + + - name: Set React ${{ matrix.react-version }} + uses: jossef/action-set-json-field@v2.1 + with: + file: package.json + parse_json: true + field: pnpm.overrides + value: '{"@types/react":"${{ env.REACT_TYPES_VERSION }}","@types/react-dom":"${{ env.REACT_DOM_TYPES_VERSION }}","react":"${{ env.REACT_VERSION }}","react-dom":"${{ env.REACT_DOM_VERSION }}"}' + env: + REACT_TYPES_VERSION: ${{ matrix.react-version }} + REACT_VERSION: ${{ matrix.react-version }} + REACT_DOM_TYPES_VERSION: ${{ startsWith(matrix.react-version, '16.') && '16.9.9' || matrix.react-version }} + REACT_DOM_VERSION: ${{ matrix.react-version }} + + - name: Install dependencies + run: pnpm install --no-frozen-lockfile + + - name: Build Project + run: pnpm build + + - name: Build Storybook + run: pnpm storybook:build + working-directory: packages/slate-editor diff --git a/.github/workflows/test.yml b/.github/workflows/test.yml index 045b65f44..ce38629ab 100644 --- a/.github/workflows/test.yml +++ b/.github/workflows/test.yml @@ -1,61 +1,41 @@ name: Test -on: [push] +on: push jobs: - build: - runs-on: ubuntu-latest - - strategy: - matrix: - node-version: [16.x] - react-version: [16.14.0, 17, 18] - - steps: - - uses: actions/checkout@v2 - - - name: Use Node.js ${{ matrix.node-version }} - uses: actions/setup-node@v1 - with: - node-version: ${{ matrix.node-version }} - - - uses: pnpm/action-setup@v2 - name: Install pnpm - id: pnpm-install - with: - version: 8.4.0 - run_install: false - - - name: Get pnpm store directory - id: pnpm-cache - shell: bash - run: | - echo "STORE_PATH=$(pnpm store path)" >> $GITHUB_OUTPUT - - - uses: actions/cache@v3 - name: Setup pnpm cache - with: - path: ${{ steps.pnpm-cache.outputs.STORE_PATH }} - key: ${{ runner.os }}-pnpm-store-${{ hashFiles('**/pnpm-lock.yaml') }} - restore-keys: | - ${{ runner.os }}-pnpm-store- - - - name: Set React ${{ matrix.react-version }} - uses: jossef/action-set-json-field@v2.1 - with: - file: package.json - parse_json: true - field: pnpm.overrides - value: '{"@types/react":"${{ env.REACT_TYPES_VERSION }}","@types/react-dom":"${{ env.REACT_DOM_TYPES_VERSION }}","react":"${{ env.REACT_VERSION }}","react-dom":"${{ env.REACT_DOM_VERSION }}"}' - env: - REACT_TYPES_VERSION: ${{ matrix.react-version }} - REACT_VERSION: ${{ matrix.react-version }} - REACT_DOM_TYPES_VERSION: ${{ startsWith(matrix.react-version, '16.') && '16.9.9' || matrix.react-version }} - REACT_DOM_VERSION: ${{ matrix.react-version }} - - - name: Install dependencies - run: pnpm install --no-frozen-lockfile - - - run: pnpm build - - - run: pnpm test + build: + runs-on: ubuntu-latest + + strategy: + matrix: + node-version: [ 16.x ] + react-version: [ 16.14.0, 17, 18 ] + + steps: + - uses: actions/checkout@v2 + + - name: Setup Environment + uses: prezly/setup-github-actions@v1 + with: + node: ${{ matrix.node-version }} + pnpm: "8.4.0" + + - name: Set React ${{ matrix.react-version }} + uses: jossef/action-set-json-field@v2.1 + with: + file: package.json + parse_json: true + field: pnpm.overrides + value: '{"@types/react":"${{ env.REACT_TYPES_VERSION }}","@types/react-dom":"${{ env.REACT_DOM_TYPES_VERSION }}","react":"${{ env.REACT_VERSION }}","react-dom":"${{ env.REACT_DOM_VERSION }}"}' + env: + REACT_TYPES_VERSION: ${{ matrix.react-version }} + REACT_VERSION: ${{ matrix.react-version }} + REACT_DOM_TYPES_VERSION: ${{ startsWith(matrix.react-version, '16.') && '16.9.9' || matrix.react-version }} + REACT_DOM_VERSION: ${{ matrix.react-version }} + + - name: Install dependencies + run: pnpm install --no-frozen-lockfile + + - run: pnpm build + + - run: pnpm test From 0e41d06a37c310672a18ad0bc3bf691b699033a1 Mon Sep 17 00:00:00 2001 From: Ivan Voskoboinyk Date: Tue, 9 May 2023 14:12:57 +0300 Subject: [PATCH 3/3] Use the `.pnpm` storage folder from the workspace root To leverage PNPM caching in Github Actions --- packages/slate-editor/storybook/.npmrc | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/packages/slate-editor/storybook/.npmrc b/packages/slate-editor/storybook/.npmrc index bc3b5fc0d..07527279c 100644 --- a/packages/slate-editor/storybook/.npmrc +++ b/packages/slate-editor/storybook/.npmrc @@ -1,4 +1,4 @@ -store-dir=.pnpm +store-dir=../../../.pnpm ignore-workspace-root-check=true # @see https://github.com/pnpm/pnpm/issues/6463#issuecomment-1536115297 resolution-mode=lowest-direct