-
Notifications
You must be signed in to change notification settings - Fork 1
198 lines (186 loc) · 5.9 KB
/
ci-cd.yml
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
name: CI/CD
on:
push:
branches: [ main ]
pull_request:
branches: [ main ]
jobs:
build:
runs-on: ubuntu-latest
strategy:
matrix:
node-version: [ 20 ]
steps:
- uses: actions/checkout@v3
- name: Use Node.js ${{ matrix.node-version }}
uses: actions/setup-node@v3
with:
node-version: ${{ matrix.node-version }}
- run: npm ci
- run: npm run lint
- run: npm run build
- run: npm test
- name: Save @pod-os/core build
uses: actions/upload-artifact@v3
with:
name: core-build
path: |
core/dist/
core/lib/
core/types/
core/package.json
retention-days: 1
- name: Save @pod-os/elements build
uses: actions/upload-artifact@v3
with:
name: elements-build
path: |
elements/dist/
elements/loader/
elements/package.json
retention-days: 1
npm-publish-core-build:
if: github.ref == 'refs/heads/main'
needs: build
runs-on: ubuntu-latest
outputs:
prereleaseVersion: ${{ steps.prerelease.outputs.version }}
steps:
- uses: actions/download-artifact@v3
with:
name: core-build
- uses: actions/setup-node@v3
with:
node-version: lts/*
- uses: rlespinasse/[email protected]
- name: prerelease version
run: |
echo "::set-output name=version::$(npm version prerelease --preid ${GITHUB_SHA_SHORT} --no-git-tag-version)"
id: prerelease
- run: echo prerelease version is ${{ steps.prerelease.outputs.version }}
- uses: JS-DevTools/npm-publish@v1
name: Publish @pod-os/core
with:
token: ${{ secrets.NPM_TOKEN }}
tag: ${{ env.GITHUB_REF_SLUG }}
npm-publish-elements-build:
if: github.ref == 'refs/heads/main'
needs: build
runs-on: ubuntu-latest
outputs:
prereleaseVersion: ${{ steps.prerelease.outputs.version }}
steps:
- uses: actions/download-artifact@v3
with:
name: elements-build
- uses: actions/setup-node@v3
with:
node-version: lts/*
- uses: rlespinasse/[email protected]
- name: prerelease version
run: |
echo "::set-output name=version::$(npm version prerelease --preid ${GITHUB_SHA_SHORT} --no-git-tag-version)"
id: prerelease
- run: echo prerelease version is ${{ steps.prerelease.outputs.version }}
- uses: JS-DevTools/npm-publish@v1
name: Publish @pod-os/elements
with:
token: ${{ secrets.NPM_TOKEN }}
tag: ${{ env.GITHUB_REF_SLUG }}
build-pages:
if: github.ref == 'refs/heads/main'
needs:
- npm-publish-elements-build
- npm-publish-core-build
runs-on: ubuntu-latest
steps:
- run: echo elements version is ${{ needs.npm-publish-elements-build.outputs.prereleaseVersion }}
- run: echo core version is ${{ needs.npm-publish-core-build.outputs.prereleaseVersion }}
- uses: actions/checkout@v3
- name: Setup Pages
uses: actions/configure-pages@v2
- name: Use Node.js 20
uses: actions/setup-node@v3
with:
node-version: 20
- name: Install storybook
working-directory: ./storybook
run: npm ci
- name: Build storybook
working-directory: ./storybook
env:
STORYBOOK_POD_OS_ELEMENTS_DIST_URL: https://unpkg.com/@pod-os/elements@${{ needs.npm-publish-elements-build.outputs.prereleaseVersion }}/dist/elements
run: npm run build
- name: Upload pages
uses: actions/upload-pages-artifact@v1
with:
path: 'gh-pages'
deploy-pages:
if: github.ref == 'refs/heads/main'
permissions:
contents: read
pages: write
id-token: write
environment:
name: github-pages
url: ${{ steps.deployment.outputs.page_url }}
runs-on: ubuntu-latest
needs: build-pages
steps:
- name: Deploy to GitHub Pages
id: deployment
uses: actions/deploy-pages@v1
npm-release-latest-core:
if: github.ref == 'refs/heads/main'
needs: build
runs-on: ubuntu-latest
steps:
- uses: actions/download-artifact@v3
with:
name: core-build
- uses: actions/setup-node@v3
with:
node-version: lts/*
- uses: JS-DevTools/npm-publish@v1
name: Release @pod-os/core
with:
token: ${{ secrets.NPM_TOKEN }}
tag: latest
npm-release-latest-elements:
if: github.ref == 'refs/heads/main'
needs: build
runs-on: ubuntu-latest
outputs:
releaseType: ${{ steps.release.outputs.type }}
releaseVersion: ${{ steps.release.outputs.version }}
steps:
- uses: actions/download-artifact@v3
with:
name: elements-build
- uses: actions/setup-node@v3
with:
node-version: lts/*
- uses: JS-DevTools/npm-publish@v1
id: release
name: Release @pod-os/elements
with:
token: ${{ secrets.NPM_TOKEN }}
tag: latest
deploy-pod-os-apps:
needs: npm-release-latest-elements
if: needs.npm-release-latest-elements.outputs.releaseType != 'none'
runs-on: ubuntu-latest
env:
POD_OS_ELEMENTS_VERSION: ${{ needs.npm-release-latest-elements.outputs.releaseVersion }}
steps:
- run: echo release apps based on @pod-os/elements version ${POD_OS_ELEMENTS_VERSION}
- uses: actions/checkout@v3
- name: Build PodOS Browser
working-directory: ./apps
run: make pos-app-browser
- name: Deploy PodOS Browser
working-directory: ./apps
run: npx netlify-cli deploy --site=pod-os-browser --dir=dist/pos-app-browser --prod
env:
NETLIFY_SITE_ID: ${{ secrets.NETLIFY_POD_OS_BROWSER_SITE_ID }}
NETLIFY_AUTH_TOKEN: ${{ secrets.NETLIFY_AUTH_TOKEN }}