-
Notifications
You must be signed in to change notification settings - Fork 186
210 lines (183 loc) · 8.02 KB
/
pr_close.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
199
200
201
202
203
204
205
206
207
208
209
210
name: 'Close Pull Request'
on:
pull_request:
types: [closed]
workflow_dispatch:
inputs:
pr_number_by_workflow_dispatch:
description: 'Number of PR'
type: number
required: true
jobs:
upload_pr_workflow_payload:
# Не используем always(), т.к. он не учитывает отмену воркфлоу
# см. https://github.com/orgs/community/discussions/26303
if: ${{ !cancelled() }}
name: Call reusable workflow
uses: ./.github/workflows/reusable_workflow_pr_worfklow_payload.yml
with:
action: upload
override_pr_number: ${{ inputs.pr_number_by_workflow_dispatch }}
patch:
if: github.event.pull_request.merged == true && contains(github.event.pull_request.labels.*.name, 'patch')
concurrency: ci-stable
runs-on: ubuntu-latest
name: Stable Patch
steps:
- name: Checkout (for forked PR)
if: github.event.pull_request.base.repo.id != github.event.pull_request.head.repo.id
uses: actions/checkout@v4
- name: Checkout (for maintainer's PR)
if: github.event.pull_request.base.repo.id == github.event.pull_request.head.repo.id
uses: actions/checkout@v4
with:
token: ${{ secrets.DEVTOOLS_GITHUB_TOKEN }}
- name: Enable Corepack
run: corepack enable
shell: bash
- name: Setup NodeJS
uses: actions/setup-node@v4
with:
node-version-file: '.nvmrc'
- name: Set Git credentials
run: |
git config --local user.email "[email protected]"
git config --local user.name "GitHub Action"
- name: Make patch
uses: VKCOM/gh-actions/VKUI/patch@main
with:
token: ${{ secrets.DEVTOOLS_GITHUB_TOKEN }}
directory: packages/vkui/
is-updated-vkui-floating-ui:
runs-on: ubuntu-latest
if: ${{ github.event.pull_request.merged == true
&& github.event.pull_request.user.login == 'dependabot[bot]'
&& github.event.pull_request.base.ref == 'master' }}
outputs:
result: ${{ steps.check_floating_ui_updated.outputs.floating_ui_updated }}
prev_floating_ui_version: ${{ steps.check_floating_ui_updated.outputs.prev_version }}
new_floating_ui_version: ${{ steps.check_floating_ui_updated.outputs.new_version }}
steps:
- name: Checkout code
uses: actions/checkout@v4
- name: Node setup
uses: ./.github/actions/node-setup
- name: Dependabot metadata
id: metadata
uses: dependabot/fetch-metadata@v2
with:
github-token: ${{ secrets.GITHUB_TOKEN }}
- name: Check if vkui-floating-ui was updated
id: check_floating_ui_updated
if: ${{ steps.metadata.outputs.directory == 'packages/vkui-floating-ui' }}
run: |
UPDATED_DEPS=$(echo ${{ steps.metadata.outputs.dependency-names }} | sed "s/,/ /g")
if [[ $UPDATED_DEPS =~ "@floating-ui/react-dom" ]]; then
echo "floating_ui_updated=true" >> $GITHUB_OUTPUT
echo "prev_version=${{ steps.metadata.outputs.previous-version }}" >> $GITHUB_OUTPUT
echo "new_version=${{ steps.metadata.outputs.new-version }}" >> $GITHUB_OUTPUT
else
echo "floating_ui_updated=false" >> $GITHUB_OUTPUT
fi
autopublish-vkui-floating-ui:
runs-on: ubuntu-latest
needs: is-updated-vkui-floating-ui
if: ${{ needs.is-updated-vkui-floating-ui.outputs.result == 'true' }}
permissions:
issues: write
pull-requests: write
contents: write
steps:
- name: Checkout code
uses: actions/checkout@v4
- name: Node setup
uses: ./.github/actions/node-setup
- name: Get vkui-floating-ui version
id: get_version
run: |
echo "floating_ui_version=$(node -p "require('./packages/vkui-floating-ui/package.json').version")" >> $GITHUB_OUTPUT
# Рассчитываем новую версию @vkui-floating-ui
- name: Calculate new version of vkui-floating-ui
id: calc_new_version_vkui_floating_ui
uses: VKCOM/gh-actions/VKUI/bump-vkui-floating-ui-version@main
with:
prev_origin_version: ${{ needs.is-updated-vkui-floating-ui.outputs.prev_floating_ui_version }}
new_origin_version: ${{ needs.is-updated-vkui-floating-ui.outputs.new_floating_ui_version }}
current_version: ${{ steps.get_version.outputs.floating_ui_version }}
- name: Define branch name for new version release
run: |
BRANCH_NAME_PREFIX="release/vkui-floating-ui-"
VERSION_POSTFIX="${{ steps.calc_new_version_vkui_floating_ui.outputs.new_version }}"
echo "RELEASE_BRANCH_NAME="${BRANCH_NAME_PREFIX}${VERSION_POSTFIX}"" >> "$GITHUB_ENV"
- name: Set Git credentials
run: |
git config --local user.email "[email protected]"
git config --local user.name "GitHub Action"
- name: Create branch for new version release
uses: ad-m/github-push-action@master
with:
github_token: ${{ secrets.GITHUB_TOKEN }}
branch: ${{ env.RELEASE_BRANCH_NAME }}
# Запускаем форкфлоу скрипта публикации
- name: Publish new version
uses: actions/github-script@v7
with:
script: |
github.rest.actions.createWorkflowDispatch({
owner: context.repo.owner,
repo: context.repo.repo,
workflow_id: 'publish.yml',
ref: ${{ env.RELEASE_BRANCH_NAME }},
inputs: {
package_name: '@vkontakte/vkui-floating-ui',
custom_version: "${{ steps.calc_new_version_vkui_floating_ui.outputs.new_version }}"
latest: true,
close_milestone: false,
}
})
# Обновляем версию vkui-floating-ui в vkui
- name: update vkui-floating-ui version in vkui
run: |
yarn workspace @vkontakte/vkui add @vkontakte/vkui-floating-ui@${{ steps.calc_new_version_vkui_floating_ui.outputs.new_version }}
# Создаем pull request с изменениями в ветке
- name: Create PR with changes
id: create_pull_request
uses: peter-evans/create-pull-request@v7
with:
token: ${{ secrets.GITHUB_TOKEN }}
base: master
branch: ${{ env.RELEASE_BRANCH_NAME }}
commit-message: 'build(deps): Bump @vkontakte/vkui-floating-ui to ${{ steps.calc_new_version_vkui_floating_ui.outputs.new_version }}'
delete-branch: true
title: 'build(deps): Bump @vkontakte/vkui-floating-ui to ${{ steps.calc_new_version_vkui_floating_ui.outputs.new_version }}'
body: ''
labels: subpackage:@vkontakte/vkui-floating-ui, dependencies
# Добавляем майлстоун следующей минорной версии
- name: Add next minor version milestone to pull request
uses: VKCOM/gh-actions/VKUI/add-next-minor-milestone@main
with:
token: ${{ secrets.GITHUB_TOKEN }}
pull_request_number: ${{ steps.create_pull_request.outputs.pull-request-number }}
update-release-notes:
if: ${{ github.event.pull_request.merged == true
&& github.event.pull_request.base.ref == 'master'}}
runs-on: ubuntu-latest
name: Update release notes
permissions:
contents: write
concurrency:
group: ${{ github.workflow }}-${{ github.event.pull_request.base.ref }}
cancel-in-progress: false
steps:
- name: Checkout repository
uses: actions/checkout@v4
- name: Get vkui version
id: get_version
run: |
echo "vkui_version=$(node -p "require('./packages/vkui/package.json').version")" >> $GITHUB_OUTPUT
- name: Update release notes script
uses: VKCOM/gh-actions/VKUI/auto-update-release-notes@main
with:
token: ${{ secrets.GITHUB_TOKEN }}
current_vkui_version: ${{ steps.get_version.outputs.vkui_version }}
pull_request_number: ${{ github.event.pull_request.number }}