chore(release): publish #5624
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
name: CI | |
on: | |
push: | |
branches: [ master ] | |
pull_request: | |
branches: [ master ] | |
jobs: | |
build_bricks: | |
name: Build bricks | |
runs-on: ubuntu-latest | |
strategy: | |
matrix: | |
node-version: [20.x] | |
steps: | |
- name: Setup timezone | |
uses: zcong1993/setup-timezone@master | |
with: | |
timezone: Asia/Shanghai | |
- uses: actions/checkout@v4 | |
- name: Use Node.js ${{ matrix.node-version }} | |
uses: actions/setup-node@v4 | |
with: | |
node-version: ${{ matrix.node-version }} | |
registry-url: 'https://registry.npmjs.org' | |
- name: Get yarn cache directory path | |
id: yarn-cache-dir-path | |
run: echo "::set-output name=dir::$(yarn cache dir)" | |
- name: Cache for yarn | |
uses: actions/cache@v4 | |
with: | |
path: ${{ steps.yarn-cache-dir-path.outputs.dir }} | |
key: node-cache-${{ runner.os }}-yarn-${{ hashFiles('yarn.lock') }} | |
restore-keys: | | |
node-cache-${{ runner.os }}-yarn- | |
- name: Cache nx cache | |
uses: actions/cache@v4 | |
with: | |
save-always: true | |
path: .cache | |
key: ${{ runner.os }}-nx-${{ hashFiles('yarn.lock', 'package.json', 'shared/common-bricks/common-bricks.json') }}-${{ hashFiles('**/package.json') }} | |
restore-keys: | | |
${{ runner.os }}-nx-${{ hashFiles('yarn.lock', 'package.json', 'shared/common-bricks/common-bricks.json') }}- | |
# Fix `yarn install --frozen-lockfile` not working in monorepo. | |
# https://github.com/yarnpkg/yarn/issues/5840#issuecomment-468782288 | |
- name: Get checksum before yarn install | |
id: yarn-lock-check-before | |
run: echo "::set-output name=sum::$(cksum yarn.lock)" | |
- run: yarn install --frozen-lockfile | |
- name: Get checksum after yarn install | |
id: yarn-lock-check-after | |
run: echo "::set-output name=sum::$(cksum yarn.lock)" | |
- name: Exit if yarn.lock updated | |
run: exit 1 | |
if: steps.yarn-lock-check-before.outputs.sum != steps.yarn-lock-check-after.outputs.sum | |
- run: yarn build | |
env: | |
NX_REJECT_UNKNOWN_LOCAL_CACHE: '0' | |
- run: yarn test:ci | |
env: | |
NX_REJECT_UNKNOWN_LOCAL_CACHE: '0' | |
- name: Get coverage files | |
run: | | |
echo "COVERAGE_FILES=$(find ./{bricks,shared} -maxdepth 1 -mindepth 1 -type d -exec echo "{}/.coverage/cobertura-coverage.xml" \; | tr '\n' ',' | sed 's/,$//')" >> $GITHUB_ENV | |
- name: Codecov | |
uses: codecov/codecov-action@v4 | |
with: | |
token: ${{ secrets.CODECOV_TOKEN }} | |
files: ${{ env.COVERAGE_FILES }} | |
disable_search: true | |
- uses: easyops-cn/actions-next-publish-from-tags@master | |
with: | |
npm-token: ${{ secrets.NPM_TOKEN }} | |
if: github.event_name == 'push' | |
- uses: actions/upload-artifact@v4 | |
with: | |
name: brick-artifacts | |
path: | | |
bricks/*/dist | |
bricks/*/docs | |
bricks/*/src/**/example.yaml | |
bricks/*/src/**/example.html | |
netlify.toml | |
!*.map | |
!bricks/v2-adapter | |
!bricks/ui-test | |
!bricks/vb-experiment | |
!bricks/form-renderer | |
retention-days: 1 | |
build_docs: | |
name: Build docs | |
needs: build_bricks | |
runs-on: ubuntu-latest | |
strategy: | |
matrix: | |
node-version: [20.x] | |
steps: | |
- uses: actions/checkout@v4 | |
with: | |
repository: easyops-cn/brick-docs | |
ref: refs/heads/master | |
token: ${{ secrets.GH_TOKEN_EVE }} | |
- uses: actions/download-artifact@v4 | |
with: | |
name: brick-artifacts | |
path: ci-bricks | |
- name: Get yarn cache directory path | |
id: yarn-cache-dir-path | |
run: echo "::set-output name=dir::$(yarn cache dir)" | |
- name: Cache for yarn | |
uses: actions/cache@v4 | |
with: | |
path: ${{ steps.yarn-cache-dir-path.outputs.dir }} | |
key: docs-node-cache-${{ runner.os }}-yarn-v3-${{ hashFiles('yarn.lock') }} | |
restore-keys: | | |
docs-node-cache-${{ runner.os }}-yarn-v3- | |
- name: Install dependencies (docs) | |
run: yarn install --frozen-lockfile | |
- name: Build (docs) | |
run: yarn build | |
- name: Deploy to Netlify (pull request) | |
id: netlify-deploy | |
uses: nwtgck/actions-netlify@v3.0 | |
with: | |
publish-dir: './build' | |
production-branch: master | |
github-token: ${{ secrets.GITHUB_TOKEN }} | |
deploy-message: "${{ github.event.pull_request.title }}" | |
alias: docs-preview-${{ github.event.number }} | |
netlify-config-path: ./ci-bricks/netlify.toml | |
env: | |
NETLIFY_AUTH_TOKEN: ${{ secrets.NETLIFY_AUTH_TOKEN }} | |
NETLIFY_SITE_ID: ${{ secrets.NETLIFY_SITE_ID }} | |
timeout-minutes: 2 | |
if: github.event_name == 'pull_request' | |
- name: Deploy to gh-pages (push to master) | |
uses: peaceiris/actions-gh-pages@v4 | |
with: | |
personal_token: ${{ secrets.GH_TOKEN_EVE }} | |
external_repository: easyops-cn/bricks | |
cname: bricks.js.org | |
publish_dir: ./build | |
publish_branch: gh-pages | |
force_orphan: true | |
if: github.event_name == 'push' | |
size_check: | |
name: Size check | |
needs: build_bricks | |
runs-on: ubuntu-latest | |
strategy: | |
matrix: | |
node-version: [20.x] | |
steps: | |
- uses: actions/checkout@v4 | |
- uses: actions/download-artifact@v4 | |
with: | |
name: brick-artifacts | |
path: ci-bricks | |
- name: Get yarn cache directory path | |
id: yarn-cache-dir-path | |
run: echo "::set-output name=dir::$(yarn cache dir)" | |
- name: Cache for yarn | |
uses: actions/cache@v4 | |
with: | |
path: ${{ steps.yarn-cache-dir-path.outputs.dir }} | |
key: node-cache-${{ runner.os }}-yarn-${{ hashFiles('yarn.lock') }} | |
restore-keys: | | |
node-cache-${{ runner.os }}-yarn- | |
- run: yarn install --frozen-lockfile | |
env: | |
CYPRESS_INSTALL_BINARY: '' | |
- run: cp size-check.config.mjs dev.config.mjs | |
- run: yarn size-check:ci | |
env: | |
CYPRESS_RECORD_KEY: ${{ secrets.CYPRESS_RECORD_KEY }} | |
continue-on-error: true | |
- name: Report size check result | |
run: | | |
curl -v -X POST -H 'Content-Type: text/plain' -H 'Size-Checker-Token: ${{ secrets.SIZE_CHECKER_TOKEN }}' --data-binary @size-check.log.yml https://size-checker.shenwei.xyz/api/upload/easyops-cn--next-bricks/${{ github.sha }} | |
- name: Generate size check comment | |
if: github.event_name == 'pull_request' | |
run: | | |
echo "📐🤏 Size check result (${{ github.event.pull_request.base.sha }}...${{ github.sha }}):" >> size-check-comment.md | |
echo "" >> size-check-comment.md | |
curl https://size-checker.shenwei.xyz/api/compare/easyops-cn--next-bricks/${{ github.event.pull_request.base.sha }}/${{ github.sha }}.md >> size-check-comment.md | |
- if: github.event_name == 'pull_request' | |
name: Find size check comment | |
uses: peter-evans/find-comment@v3 | |
id: find-comment | |
with: | |
issue-number: ${{ github.event.pull_request.number }} | |
comment-author: 'github-actions[bot]' | |
body-includes: '📐🤏 Size check result' | |
- if: github.event_name == 'pull_request' | |
name: Create or update size check comment | |
uses: peter-evans/create-or-update-comment@v4 | |
with: | |
comment-id: ${{ steps.find-comment.outputs.comment-id }} | |
issue-number: ${{ github.event.pull_request.number }} | |
edit-mode: replace | |
body-path: size-check-comment.md |