Skip to content

Commit ed07084

Browse files
Test release (#90)
* feat: improve cicd * chore: changeset
1 parent cd55d9d commit ed07084

File tree

3 files changed

+111
-70
lines changed

3 files changed

+111
-70
lines changed

.changeset/long-buses-worry.md

+5
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
---
2+
'@cube-dev/ui-kit': patch
3+
---
4+
5+
this is a test release. will be removed

.github/workflows/main.yml

+106-27
Original file line numberDiff line numberDiff line change
@@ -1,52 +1,131 @@
1+
name: Release
2+
13
on:
24
push:
35
branches:
46
- main
57

8+
concurrency: ${{ github.workflow }}-${{ github.ref }}
9+
610
jobs:
711
publish:
812
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 }}
1713
steps:
18-
- uses: actions/checkout@v1
14+
- uses: actions/checkout@v2
15+
16+
- name: Setup Node.js
17+
uses: actions/setup-node@v3
1918
with:
20-
fetch-depth: 0 # Required to retrieve git history
19+
node-version-file: '.nvmrc'
2120

22-
- uses: actions/setup-node@v2
21+
- uses: actions/cache@v2
22+
id: yarn-cache
2323
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') }}
2530
26-
- name: Install dependencies
31+
- name: Install Dependencies
2732
run: yarn --frozen-lockfile
2833

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
3240
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 }}
3746

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
4160

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') }}
4470
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
4777

4878
- name: Publish to Chromatic
4979
id: publish_chromatic
5080
uses: chromaui/action@v1
5181
with:
82+
exitZeroOnChanges: true
83+
exitOnceUploaded: true
5284
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"

.github/workflows/release.yml

-43
This file was deleted.

0 commit comments

Comments
 (0)