-
Notifications
You must be signed in to change notification settings - Fork 0
199 lines (165 loc) · 5.51 KB
/
release.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
# NOTES:
# generating changelog for release is performed twice because first changelog generates for release notes,
# so it runs before release step, and second changelog generates for updating CHANGELOG.md file, so it runs after release step.
# if i'd try to generate changelog once, changes will be marked as "master" branch changes, cause there's no new tag yet.
name: Webitel UI release with docs
on:
push:
branches: [ master ]
jobs:
install_deps:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- name: Cache node_modules
uses: actions/cache@v4
id: cache_node_modules
with:
path: node_modules
key: node_modules-${{ hashFiles('**/package-lock.json') }}
- name: Use Node.js
uses: actions/setup-node@v4
with:
node-version: lts/*
check-latest: true
- name: Install dependencies
if: steps.cache_node_modules.outputs.cache-hit != 'true'
run: npm ci
test:
needs: [install_deps]
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- uses: actions/cache@v3
with:
path: node_modules
key: node_modules-${{ hashFiles('**/package-lock.json') }}
- name: Use Node.js
uses: actions/setup-node@v4
with:
node-version: lts/*
check-latest: true
- run: npm run test:unit
release:
needs: [install_deps, test]
permissions:
contents: write
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
with:
fetch-depth: 0
- name: get prevTag
id: prevTag
uses: "WyriHaximus/github-action-get-previous-tag@v1"
# for release notes // why 2 changelogs? see NOTES
- name: generate Release Changelog
id: changelog
uses: requarks/changelog-action@v1
continue-on-error: true
with:
writeToFile: false
reverseOrder: true
excludeTypes: build
token: ${{ github.token }}
fromTag: ${{ github.ref_name }}
toTag: ${{ steps.prevTag.outputs.tag }}
- name: get-npm-version
id: package-version
uses: martinbeentjes/[email protected]
- name: Create release
id: create_release
uses: softprops/action-gh-release@v1
with:
tag_name: "v${{ steps.package-version.outputs.current-version}}"
name: "@webitel/ui-sdk v${{ steps.package-version.outputs.current-version}}"
body: ${{ steps.changelog.outputs.changes }}
# update tags list after prev step release, so that we fetch new tag, created by prev step
- uses: actions/checkout@v4
with:
fetch-depth: 0
- name: get newTag
id: newTag
uses: "WyriHaximus/github-action-get-previous-tag@v1"
# update CHANGELOG.md file // why 2 changelogs? see NOTES
- name: update Release Changelog
id: update-changelog
uses: requarks/changelog-action@v1
continue-on-error: true
with:
reverseOrder: true
excludeTypes: build
token: ${{ github.token }}
fromTag: ${{ steps.newTag.outputs.tag }}
toTag: ${{ steps.prevTag.outputs.tag }}
- name: commit changelog
uses: stefanzweifel/git-auto-commit-action@v5
with:
commit_message: autoupdate changelog
file_pattern: 'CHANGELOG.md'
push_options: --force
publish:
needs: [release]
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- uses: actions/cache@v3
with:
path: node_modules
key: node_modules-${{ hashFiles('**/package-lock.json') }}
- name: Use Node.js
uses: actions/setup-node@v4
with:
node-version: lts/*
check-latest: true
registry-url: https://registry.npmjs.org
- name: Check publish status
id: check_publish
uses: tehpsalmist/npm-publish-status-action@v1
- name: Publish release
id: publish_release
if: ${{ steps.check_publish.outputs.exists == '0' }}
run: |
echo "Publishing release, ${{ steps.check_publish.outputs.exists }}"
npm run build
npm config set //registry.npmjs.org/:_authToken=${{ secrets.NPM_TOKEN }}
npm publish --access public
- name: Report publish status
if: ${{ steps.check_publish.outputs.exists == '1' }}
run: echo "Package already published"
build_docs:
needs: [release]
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- uses: actions/cache@v3
with:
path: node_modules
key: node_modules-${{ hashFiles('**/package-lock.json') }}
- name: Use Node.js
uses: actions/setup-node@v4
with:
node-version: lts/*
check-latest: true
- name: Build docs
run: npm run docs:build
- name: Upload Artifact
uses: actions/upload-pages-artifact@v3
with:
name: docs
path: docs/.vitepress/dist
deploy:
needs: [build_docs]
permissions:
pages: write # to deploy to Pages
id-token: write # to verify the deployment originates from an appropriate source
runs-on: ubuntu-latest
steps:
- name: setup Github Pages
id: setup_pages
uses: actions/configure-pages@v4
- name: deploy to Github Pages
id: deploy_pages
uses: actions/deploy-pages@v4
with:
artifact_name: docs