-
Notifications
You must be signed in to change notification settings - Fork 186
155 lines (133 loc) · 5.28 KB
/
publish.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
name: 'Publish @vkontakte/vkui'
on:
workflow_dispatch:
inputs:
type:
description: 'version type:'
required: true
type: choice
default: 'minor'
options:
- patch
- minor
- major
custom_version:
description: 'custom version: x.y.z (without "v")'
required: false
close_milestone:
description: 'whether to close associated milestone after publish'
type: boolean
default: true
latest:
description: 'set latest tag'
type: boolean
default: true
run-name: Publish ${{ inputs.type }} ${{ inputs.custom_version }}
jobs:
publish:
concurrency: ci-gh-pages
outputs:
release_tag: ${{ steps.updated_version.outputs.version }}
permissions:
id-token: write
runs-on: ubuntu-latest
steps:
- name: Checkout
uses: actions/checkout@v4
with:
token: ${{ secrets.DEVTOOLS_GITHUB_TOKEN }}
- name: Setup NodeJS
uses: actions/setup-node@v4
with:
node-version: 20
cache: 'yarn'
always-auth: true
registry-url: 'https://registry.npmjs.org'
- name: Install dependencies
run: YARN_ENABLE_SCRIPTS=false yarn install --immutable
- name: Set Git credentials
run: |
git config --local user.email "[email protected]"
git config --local user.name "GitHub Action"
- name: Saving current version to env
id: prev_version
run: |
echo "version=$(yarn workspace @vkontakte/vkui node -p "require('./package.json').version")" >> $GITHUB_OUTPUT
- name: Bump by version type
if: ${{ !github.event.inputs.custom_version }}
run: yarn workspace @vkontakte/vkui run g:npm:version ${{ github.event.inputs.type }}
- name: Bump by custom version
if: ${{ github.event.inputs.custom_version }}
run: yarn workspace @vkontakte/vkui run g:npm:version ${{ github.event.inputs.custom_version }}
- name: Saving updated version to env
id: updated_version
run: |
echo "version=$(yarn workspace @vkontakte/vkui node -p "require('./package.json').version")" >> $GITHUB_OUTPUT
- name: Adding commit and tag with updated version number
run: |
git add -A
git commit -m 'bump(@vkontakte/vkui): from ${{ steps.prev_version.outputs.version }} to ${{ steps.updated_version.outputs.version }}'
git tag v${{ steps.updated_version.outputs.version }}
- name: Run linters
run: yarn run lint
- name: Run @vkontakte/vkui unit tests
run: yarn workspace @vkontakte/vkui run test
- name: Pushing changes
uses: ad-m/github-push-action@master
with:
github_token: ${{ secrets.DEVTOOLS_GITHUB_TOKEN }}
branch: ${{ github.ref }}
tags: true
- name: Create stable branch
uses: VKCOM/gh-actions/VKUI/stable-branch@main
with:
token: ${{ secrets.DEVTOOLS_GITHUB_TOKEN }}
directory: packages/vkui/
- name: Generate archive
working-directory: ./packages/vkui
run: yarn pack
- name: Publishing with latest tag
working-directory: ./packages/vkui
if: ${{ github.event.inputs.latest == 'true' }}
run: npm publish package.tgz
env:
NODE_AUTH_TOKEN: ${{ secrets.NPMJS_PUBLISH_TOKEN }}
- name: Publishing with legacy tag
working-directory: ./packages/vkui
if: ${{ github.event.inputs.latest != 'true' }}
run: npm publish package.tgz --tag legacy
env:
NODE_AUTH_TOKEN: ${{ secrets.NPMJS_PUBLISH_TOKEN }}
- name: Creating doc for stable release
if: ${{ github.event.inputs.latest == 'true' }}
run: |
yarn run docs:styleguide:build
yarn run docs:storybook:build
mkdir styleguide/${{ steps.updated_version.outputs.version }} styleguide/dist/playground
cp -R packages/vkui/storybook-static/* styleguide/dist/playground
cp -R styleguide/dist/* styleguide/${{ steps.updated_version.outputs.version }}
mv styleguide/${{ steps.updated_version.outputs.version }} styleguide/dist/${{ steps.updated_version.outputs.version }}
- name: Build styleguide and storybook for legacy release
if: ${{ github.event.inputs.latest != 'true' }}
run: |
yarn run docs:styleguide:build --dist dist/${{ steps.updated_version.outputs.version }}
yarn docs:storybook:build -o ../../styleguide/dist/${{ steps.updated_version.outputs.version }}/playground
- name: Publishing doc
uses: JamesIves/github-pages-deploy-action@v4
with:
token: ${{ secrets.DEVTOOLS_GITHUB_TOKEN }}
branch: gh-pages
folder: styleguide/dist
clean: false
force: false
close_milestone:
needs: ['publish']
if: ${{ github.event.inputs.close_milestone == 'true' }}
runs-on: ubuntu-latest
steps:
- name: Close milestone, comment on issues and release notes
uses: VKCOM/gh-actions/VKUI/complete-publish@main
with:
token: ${{ secrets.DEVTOOLS_GITHUB_TOKEN }}
releaseTag: ${{ needs.publish.outputs.release_tag }}
latest: ${{ github.event.inputs.latest }}