|
| 1 | +name: Release |
| 2 | + |
1 | 3 | on:
|
2 | 4 | push:
|
3 | 5 | branches:
|
4 | 6 | - main
|
5 | 7 |
|
| 8 | +concurrency: ${{ github.workflow }}-${{ github.ref }} |
| 9 | + |
6 | 10 | jobs:
|
7 | 11 | publish:
|
8 | 12 | runs-on: ubuntu-latest
|
9 |
| - environment: |
10 |
| - name: Chromatic prod |
11 |
| - url: ${{ steps.publish_chromatic.outputs.url }} |
12 |
| - |
13 |
| - env: |
14 |
| - INPUT_TOKEN: ${{ secrets.NPM_TOKEN }} |
15 |
| - NETLIFY_SITE_ID: ${{ secrets.NETLIFY_SITE_ID }} |
16 |
| - NETLIFY_AUTH_TOKEN: ${{ secrets.NETLIFY_AUTH_TOKEN }} |
17 | 13 | steps:
|
18 |
| - - uses: actions/checkout@v1 |
| 14 | + - uses: actions/checkout@v2 |
| 15 | + |
| 16 | + - name: Setup Node.js |
| 17 | + uses: actions/setup-node@v3 |
19 | 18 | with:
|
20 |
| - fetch-depth: 0 # Required to retrieve git history |
| 19 | + node-version-file: '.nvmrc' |
21 | 20 |
|
22 |
| - - uses: actions/setup-node@v2 |
| 21 | + - uses: actions/cache@v2 |
| 22 | + id: yarn-cache |
23 | 23 | with:
|
24 |
| - node-version: 14 |
| 24 | + path: | |
| 25 | + **/node_modules |
| 26 | + **/.eslintcache |
| 27 | + key: ${{ runner.os }}-yarn-${{ hashFiles('**/yarn.lock') }} |
| 28 | + restore-keys: | |
| 29 | + ${{ runner.os }}-yarn--${{ steps.yarn-cache-dir-path.outputs.version }}-${{ hashFiles('**/yarn.lock') }} |
25 | 30 |
|
26 |
| - - name: Install dependencies |
| 31 | + - name: Install Dependencies |
27 | 32 | run: yarn --frozen-lockfile
|
28 | 33 |
|
29 |
| - - run: yarn build |
30 |
| - - id: publish |
31 |
| - uses: JS-DevTools/npm-publish@v1 |
| 34 | + - name: Build project |
| 35 | + run: yarn build |
| 36 | + |
| 37 | + - name: Create Release Pull Request or Publish to npm |
| 38 | + id: changesets |
| 39 | + uses: changesets/action@v1 |
32 | 40 | with:
|
33 |
| - token: ${{ secrets.NPM_TOKEN }} |
34 |
| - access: public |
35 |
| - check-version: true |
36 |
| - package: ./dist/package.json |
| 41 | + publish: npx changeset publish |
| 42 | + commit: 'chore: release' |
| 43 | + env: |
| 44 | + GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} |
| 45 | + NPM_TOKEN: ${{ secrets.NPM_TOKEN }} |
37 | 46 |
|
38 |
| - - if: steps.publish.outputs.type != 'none' |
39 |
| - run: | |
40 |
| - echo "Version changed: ${{ steps.publish.outputs.old-version }} => ${{ steps.publish.outputs.version }}" |
| 47 | + deploy-chromatic: |
| 48 | + name: 'Prepare Storybook for review & tests' |
| 49 | + runs-on: ubuntu-latest |
| 50 | + environment: |
| 51 | + name: Chromatic staging |
| 52 | + url: ${{ steps.publish_chromatic.outputs.url }} |
| 53 | + env: |
| 54 | + CHROMATIC_RETRIES: 5 |
| 55 | + LOG_LEVEL: 'error' |
| 56 | + steps: |
| 57 | + - uses: actions/checkout@v2 |
| 58 | + with: |
| 59 | + fetch-depth: 0 |
41 | 60 |
|
42 |
| - - name: Build storybook |
43 |
| - run: yarn build-storybook --quiet |
| 61 | + - uses: actions/cache@v2 |
| 62 | + id: yarn-cache |
| 63 | + with: |
| 64 | + path: | |
| 65 | + **/node_modules |
| 66 | + **/.eslintcache |
| 67 | + key: ${{ runner.os }}-yarn-${{ hashFiles('**/yarn.lock') }} |
| 68 | + restore-keys: | |
| 69 | + ${{ runner.os }}-yarn--${{ steps.yarn-cache-dir-path.outputs.version }}-${{ hashFiles('**/yarn.lock') }} |
44 | 70 |
|
45 |
| - - name: Publish storybook |
46 |
| - run: npx netlify-cli deploy -p |
| 71 | + - uses: actions/setup-node@v3 |
| 72 | + with: |
| 73 | + node-version-file: '.nvmrc' |
| 74 | + |
| 75 | + - name: Install dependencies |
| 76 | + run: yarn --frozen-lockfile |
47 | 77 |
|
48 | 78 | - name: Publish to Chromatic
|
49 | 79 | id: publish_chromatic
|
50 | 80 | uses: chromaui/action@v1
|
51 | 81 | with:
|
| 82 | + exitZeroOnChanges: true |
| 83 | + exitOnceUploaded: true |
52 | 84 | projectToken: ${{ secrets.CHROMATIC_PROJECT_TOKEN }}
|
| 85 | + |
| 86 | + deploy-docs: |
| 87 | + name: 'Prepare Docs for the Review' |
| 88 | + runs-on: ubuntu-latest |
| 89 | + if: ${{ steps.changesets.outputs.published }} |
| 90 | + environment: |
| 91 | + name: Docs staging |
| 92 | + url: ${{ steps.publish_docs.outputs.NETLIFY_PREVIEW_URL }} |
| 93 | + env: |
| 94 | + NETLIFY_SITE_ID: ${{ secrets.NETLIFY_SITE_ID }} |
| 95 | + NETLIFY_AUTH_TOKEN: ${{ secrets.NETLIFY_AUTH_TOKEN }} |
| 96 | + steps: |
| 97 | + - uses: actions/checkout@v2 |
| 98 | + |
| 99 | + - uses: actions/cache@v2 |
| 100 | + id: yarn-cache |
| 101 | + with: |
| 102 | + path: | |
| 103 | + **/node_modules |
| 104 | + **/.eslintcache |
| 105 | + key: ${{ runner.os }}-yarn-${{ hashFiles('**/yarn.lock') }} |
| 106 | + restore-keys: | |
| 107 | + ${{ runner.os }}-yarn--${{ steps.yarn-cache-dir-path.outputs.version }}-${{ hashFiles('**/yarn.lock') }} |
| 108 | +
|
| 109 | + - uses: actions/setup-node@v3 |
| 110 | + with: |
| 111 | + node-version-file: '.nvmrc' |
| 112 | + |
| 113 | + - name: Install dependencies |
| 114 | + run: yarn --frozen-lockfile |
| 115 | + |
| 116 | + - name: Build Docs |
| 117 | + run: yarn build-docs --quiet |
| 118 | + |
| 119 | + - name: Deploy docs to Netlify |
| 120 | + id: publish_docs |
| 121 | + run: | |
| 122 | + OUTPUT=$(sh -c "npx netlify-cli deploy") |
| 123 | + NETLIFY_OUTPUT=$(echo "$OUTPUT") |
| 124 | + NETLIFY_PREVIEW_URL=$(echo "$OUTPUT" | grep -Eo '(http|https)://[a-zA-Z0-9./?=_-]*(--)[a-zA-Z0-9./?=_-]*') #Unique key: -- |
| 125 | + NETLIFY_LOGS_URL=$(echo "$OUTPUT" | grep -Eo '(http|https)://app.netlify.com/[a-zA-Z0-9./?=_-]*') #Unique key: app.netlify.com |
| 126 | + NETLIFY_LIVE_URL=$(echo "$OUTPUT" | grep -Eo '(http|https)://[a-zA-Z0-9./?=_-]*' | grep -Eov "netlify.com") #Unique key: don't containr -- and app.netlify.com |
| 127 | +
|
| 128 | + echo "::set-output name=NETLIFY_OUTPUT::$NETLIFY_OUTPUT" |
| 129 | + echo "::set-output name=NETLIFY_PREVIEW_URL::$NETLIFY_PREVIEW_URL" |
| 130 | + echo "::set-output name=NETLIFY_LOGS_URL::$NETLIFY_LOGS_URL" |
| 131 | + echo "::set-output name=NETLIFY_LIVE_URL::$NETLIFY_LIVE_URL" |
0 commit comments