diff --git a/.github/workflows/pr.yml b/.github/workflows/pr.yml index 7c41c46990..a5c775d458 100644 --- a/.github/workflows/pr.yml +++ b/.github/workflows/pr.yml @@ -25,7 +25,7 @@ jobs: key: ${{ runner.os }}-build-cache-${{ hashFiles('**/src/', '!**/node_modules', '!**/dist') }} # Only setup & build if there was no build cache hit - - name: Use Node.js 16 + - name: Use Node 16 uses: actions/setup-node@v3 if: ${{ steps.build-cache.outputs.cache-hit != 'true' }} with: @@ -48,7 +48,7 @@ jobs: steps: - uses: actions/checkout@v2 - - name: Use Node.js 16 + - name: Use Node 16 uses: actions/setup-node@v3 with: node-version: '16' @@ -64,14 +64,12 @@ jobs: !**/node_modules key: ${{ runner.os }}-build-cache-${{ hashFiles('**/src/', '!**/node_modules', '!**/dist') }} - - run: yarn install --frozen-lockfile --prefer-offline + - name: Install Dependencies + run: yarn install --frozen-lockfile --prefer-offline - name: lint run: yarn lint - outputs: - yarn-cache-dir: ${{ steps.get-yarn-cache-dir.outputs.dir }} - chromatic: name: Chromatic runs-on: ubuntu-latest @@ -82,14 +80,15 @@ jobs: with: fetch-depth: 0 - - name: Use Node.js 16 + - name: Use Node 16 uses: actions/setup-node@v3 with: node-version: '16' cache: yarn cache-dependency-path: 'yarn.lock' - - run: yarn install --frozen-lockfile --prefer-offline + - name: Install Dependencies + run: yarn install --frozen-lockfile --prefer-offline - uses: actions/cache/restore@v3 name: Restore build cache @@ -115,14 +114,15 @@ jobs: steps: - uses: actions/checkout@v2 - - name: Use Node.js 16 + - name: Use Node 16 uses: actions/setup-node@v3 with: node-version: '16' cache: yarn cache-dependency-path: 'yarn.lock' - - run: yarn install --frozen-lockfile --prefer-offline + - name: Install Dependencies + run: yarn install --frozen-lockfile --prefer-offline - uses: actions/cache/restore@v3 name: Restore build cache @@ -145,14 +145,15 @@ jobs: steps: - uses: actions/checkout@v2 - - name: Use Node.js 16 + - name: Use Node 16 uses: actions/setup-node@v3 with: node-version: '16' cache: yarn cache-dependency-path: 'yarn.lock' - - run: yarn install --frozen-lockfile --prefer-offline + - name: Install Dependencies + run: yarn install --frozen-lockfile --prefer-offline - uses: actions/cache/restore@v3 name: Restore build cache diff --git a/.github/workflows/release.yml b/.github/workflows/release.yml index da1c63ed6c..c0426d56fa 100644 --- a/.github/workflows/release.yml +++ b/.github/workflows/release.yml @@ -6,33 +6,67 @@ on: - main jobs: - release: - name: Release + build: + name: Build packages runs-on: ubuntu-latest steps: - - name: Checkout Repo - uses: actions/checkout@v2 + - uses: actions/checkout@v2 + + - uses: actions/cache@v3 + name: Check for build cache + id: build-cache with: - fetch-depth: 0 + path: | + **/dist + !**/node_modules + key: ${{ runner.os }}-build-cache-${{ hashFiles('**/src/', '!**/node_modules', '!**/dist') }} - - name: Setup Node.js 16.x - uses: actions/setup-node@v1 + # Only setup & build if there was no build cache hit + - name: Use Node 16 + uses: actions/setup-node@v3 + if: ${{ steps.build-cache.outputs.cache-hit != 'true' }} with: - node-version: 16.x + node-version: '16' + cache: yarn + cache-dependency-path: 'yarn.lock' - - name: Install Dependencies - run: yarn + - name: Install + if: ${{ steps.build-cache.outputs.cache-hit != 'true' }} + run: yarn install --frozen-lockfile --prefer-offline - - name: Build packages + - name: build + if: ${{ steps.build-cache.outputs.cache-hit != 'true' }} run: yarn build - - name: Build typescript - run: yarn tsc + chromatic: + name: Establish Chromatic baseline + runs-on: ubuntu-latest + needs: [build] + steps: + - uses: actions/checkout@v2 + with: + fetch-depth: 0 + + - name: Use Node 16 + uses: actions/setup-node@v3 + with: + node-version: '16' + cache: yarn + cache-dependency-path: 'yarn.lock' - - name: Build TSDoc - run: yarn build:docs + - name: Install Dependencies + run: yarn install --frozen-lockfile --prefer-offline + + - uses: actions/cache/restore@v3 + name: Restore build cache + id: build-cache + with: + path: | + **/dist + !**/node_modules + key: ${{ runner.os }}-build-cache-${{ hashFiles('**/src/', '!**/node_modules', '!**/dist') }} - - name: Establish Chromatic baseline + - name: Publish to Chromatic uses: chromaui/action@v1 with: projectToken: ${{ secrets.CHROMATIC_PROJECT_TOKEN }} @@ -41,6 +75,35 @@ jobs: exitZeroOnChanges: true autoAcceptChanges: true + release: + name: Release + runs-on: ubuntu-latest + needs: [build] + outputs: + published: ${{ steps.changesets.outputs.published }} + publishedPackages: ${{ steps.changesets.outputs.publishedPackages }} + steps: + - uses: actions/checkout@v2 + + - name: Use Node 16 + uses: actions/setup-node@v3 + with: + node-version: '16' + cache: yarn + cache-dependency-path: 'yarn.lock' + + - name: Install Dependencies + run: yarn install --frozen-lockfile --prefer-offline + + - uses: actions/cache/restore@v3 + name: Restore build cache + id: build-cache + with: + path: | + **/dist + !**/node_modules + key: ${{ runner.os }}-build-cache-${{ hashFiles('**/src/', '!**/node_modules', '!**/dist') }} + - name: Create Release Pull Request id: changesets uses: changesets/action@v1 @@ -51,7 +114,13 @@ jobs: GITHUB_TOKEN: '${{ secrets.GITHUB_TOKEN }}' NPM_TOKEN: '${{ secrets.NPM_TOKEN }}' + notify: + name: Notify Slack & Website + runs-on: ubuntu-latest + needs: [release] + steps: - name: Dispatch to Website repo + if: ${{ needs.release.outputs.published == 'true' }} uses: peter-evans/repository-dispatch@v2 continue-on-error: true with: @@ -60,8 +129,8 @@ jobs: event-type: release-leafygreen-ui - name: Notify Slack channel of new releases - if: steps.changesets.outputs.published == 'true' + if: ${{ needs.release.outputs.published == 'true' }} id: slackbot - run: yarn slackbot '${{steps.changesets.outputs.publishedPackages}}' + run: yarn slackbot '${{ needs.release.outputs.publishedPackages }}' env: - SLACK_BOT_TOKEN: '${{secrets.SLACK_BOT_TOKEN}}' + SLACK_BOT_TOKEN: '${{ secrets.SLACK_BOT_TOKEN }}'