-
Notifications
You must be signed in to change notification settings - Fork 273
157 lines (154 loc) · 5.72 KB
/
os-increment-plugin-versions.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
---
name: Increment OpenSearch Plugins Version
on:
schedule:
- cron: 0 0 * * *
workflow_dispatch:
inputs:
logLevel:
description: Log level
required: true
default: warning
type: choice
options:
- info
- warning
- debug
jobs:
plugin-version-increment-sync:
if: github.repository == 'opensearch-project/opensearch-build'
runs-on: ubuntu-latest
strategy:
fail-fast: false
matrix:
entry:
# Adding the core repo OpenSearch for the label creation automation
- {repo: OpenSearch}
- {repo: alerting}
- {repo: anomaly-detection}
- {repo: asynchronous-search}
- {repo: common-utils}
- {repo: cross-cluster-replication}
- {repo: geospatial}
- {repo: index-management}
- {repo: job-scheduler}
- {repo: k-NN}
- {repo: neural-search}
- {repo: ml-commons}
- {repo: notifications, path: notifications}
- {repo: observability}
- {repo: performance-analyzer}
- {repo: performance-analyzer-rca}
- {repo: reporting}
- {repo: security}
- {repo: security-analytics}
- {repo: sql}
- {repo: custom-codecs}
- {repo: flow-framework}
- {repo: skills}
- {repo: query-insights}
- {repo: opensearch-system-templates}
branch:
- 1.x
- '1.3'
- 2.x
- main
- '2.17'
- '2.18'
- '2.19'
exclude:
- {entry: {repo: geospatial}, branch: '1.3'}
- {entry: {repo: neural-search}, branch: '1.3'}
- {entry: {repo: security-analytics}, branch: '1.3'}
- {entry: {repo: notifications, path: notifications}, branch: '1.3'}
- {entry: {repo: custom-codecs}, branch: '1.3'}
steps:
- name: Check out OpenSearch repo
uses: actions/checkout@v3
with:
repository: opensearch-project/OpenSearch
ref: ${{ matrix.branch }}
- name: Fetch OpenSearch version
run: |
OPENSEARCH_VERSION=$(cat buildSrc/version.properties | grep opensearch | cut -d= -f2 | grep -oE '[0-9.]+')
echo "OPENSEARCH_VERSION_NUMBER=$OPENSEARCH_VERSION" >> $GITHUB_ENV
OPENSEARCH_VERSION=$OPENSEARCH_VERSION-SNAPSHOT
echo "OPENSEARCH_VERSION=$OPENSEARCH_VERSION" >> $GITHUB_ENV
- name: Check out plugin repo
if: ${{ matrix.entry.repo != 'OpenSearch' }}
uses: actions/checkout@v3
with:
repository: opensearch-project/${{ matrix.entry.repo }}
ref: ${{ matrix.branch }}
- name: Increment Version in ${{ matrix.entry.repo }}
if: ${{ matrix.entry.repo != 'OpenSearch' }}
run: |
echo "OpenSearch Core repo version on branch ${{ matrix.branch }} is ${{ env.OPENSEARCH_VERSION_NUMBER }}"
if [ ${{ matrix.entry.path }} ]; then
echo "The gradle path is ${{ matrix.entry.path }}"
cd ${{ matrix.entry.path }}
fi
./gradlew updateVersion -DnewVersion=${{ env.OPENSEARCH_VERSION }}
- name: GitHub App token
id: github_app_token
uses: tibdex/[email protected]
with:
app_id: ${{ secrets.APP_ID }}
private_key: ${{ secrets.APP_PRIVATE_KEY }}
installation_id: 22958780
- name: Check and Create label
id: check_create_label
uses: actions/github-script@v6
with:
github-token: ${{ steps.github_app_token.outputs.token }}
result-encoding: string
script: |
const labelName = "v${{ env.OPENSEARCH_VERSION_NUMBER }}";
let labelFound = false;
try {
const label = await github.rest.issues.getLabel({
owner: context.repo.owner,
repo: "${{ matrix.entry.repo }}",
name: labelName
});
labelFound = true;
} catch (error) {
if (error.status === 404) {
const randomColor = Math.floor(Math.random() * 16777215).toString(16);
const newLabel = {
owner: context.repo.owner,
repo: "${{ matrix.entry.repo }}",
name: labelName,
color: randomColor,
description: "Issues targeting release " + labelName
};
await github.rest.issues.createLabel(newLabel);
labelFound = true;
} else {
throw error;
}
}
console.log(labelFound);
return labelFound
- name: Create Pull Request
if: ${{ matrix.entry.repo != 'OpenSearch' }}
id: cpr
uses: peter-evans/create-pull-request@v4
with:
token: ${{ steps.github_app_token.outputs.token }}
committer: opensearch-ci-bot <[email protected]>
author: opensearch-ci-bot <[email protected]>
commit-message: |
Increment version to ${{ env.OPENSEARCH_VERSION }}
Signed-off-by: opensearch-ci-bot <[email protected]>
delete-branch: true
branch: create-pull-request/${{ env.OPENSEARCH_VERSION }}
title: '[AUTO] Increment version to ${{ env.OPENSEARCH_VERSION }}'
labels: |
v${{ env.OPENSEARCH_VERSION_NUMBER }}
body: |
- Incremented version to **${{ env.OPENSEARCH_VERSION }}**.
- name: Check outputs
run: |-
echo "Pull Request Number - ${{ steps.cpr.outputs.pull-request-number }}"
echo "Pull Request URL - ${{ steps.cpr.outputs.pull-request-url }}"