Skip to content

Commit 120c6f5

Browse files
authored
Refactor release issue creation workflows (#5344)
Signed-off-by: Sayali Gaikawad <gaiksaya@amazon.com>
1 parent 8afba57 commit 120c6f5

File tree

3 files changed

+201
-201
lines changed

3 files changed

+201
-201
lines changed
+101
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,101 @@
1+
---
2+
name: create-release-issues
3+
4+
on:
5+
workflow_dispatch:
6+
inputs:
7+
version:
8+
required: true
9+
description: 'Release version'
10+
type: string
11+
repos:
12+
required: true
13+
description: 'List of components repositories'
14+
type: string
15+
workflow_call:
16+
inputs:
17+
version:
18+
required: true
19+
description: 'Release version'
20+
type: string
21+
repos:
22+
required: true
23+
description: 'List of components repositories'
24+
type: string
25+
26+
jobs:
27+
build-repo-issue-check:
28+
outputs:
29+
build_repo_issue_exists: ${{ steps.check_if_build_repo_issue_exists.outputs.issues }}
30+
runs-on: ubuntu-latest
31+
steps:
32+
- name: GitHub App token
33+
id: github_app_token
34+
uses: tibdex/github-app-token@v1.6.0
35+
with:
36+
app_id: ${{ secrets.APP_ID }}
37+
private_key: ${{ secrets.APP_PRIVATE_KEY }}
38+
installation_id: 22958780
39+
- name: Checkout Build repo
40+
uses: actions/checkout@v4
41+
- name: Check if build repo release issue exists
42+
id: check_if_build_repo_issue_exists
43+
uses: actions-cool/issues-helper@v3
44+
with:
45+
actions: 'find-issues'
46+
repo: opensearch-project/opensearch-build
47+
token: ${{ steps.github_app_token.outputs.token }}
48+
issue-state: 'open'
49+
title-includes: '[RELEASE] Release version ${{ inputs.version }}'
50+
51+
52+
component-release-issue:
53+
needs: build-repo-issue-check
54+
if: needs.build-repo-issue-check.outputs.build_repo_issue_exists != '[]'
55+
runs-on: ubuntu-latest
56+
strategy:
57+
fail-fast: false
58+
matrix:
59+
repos: ${{ fromJson(inputs.repos) }}
60+
steps:
61+
- name: GitHub App token
62+
id: github_app_token
63+
uses: tibdex/github-app-token@v1.6.0
64+
with:
65+
app_id: ${{ secrets.APP_ID }}
66+
private_key: ${{ secrets.APP_PRIVATE_KEY }}
67+
installation_id: 22958780
68+
- name: Check if plugin repo release issue exists
69+
id: check_if_plugin_repo_issue_exists
70+
uses: actions-cool/issues-helper@v3
71+
with:
72+
actions: 'find-issues'
73+
repo: opensearch-project/${{ matrix.repos }}
74+
token: ${{ steps.github_app_token.outputs.token }}
75+
title-includes: '[RELEASE] Release version ${{ inputs.version }}'
76+
- name: Checkout Build repo
77+
uses: actions/checkout@v4
78+
- name: Replace Placeholders
79+
if: steps.check_if_plugin_repo_issue_exists.outputs.issues == '[]'
80+
run: |
81+
# Read the file contents and replace the placeholders
82+
file_path=".github/ISSUE_TEMPLATE/component_release_template.md"
83+
RELEASE_VERSION="${{ inputs.version }}"
84+
RELEASE_BRANCH=$(echo ${{ inputs.version }} | cut -d. -f1-2)
85+
BUILD_REPO_ISSUE_OUTPUT=$(cat <<EOF
86+
${{ needs.build-repo-issue-check.outputs.build_repo_issue_exists.outputs.issues }}
87+
EOF
88+
)
89+
RELEASE_ISSUE_NUMBER=$(echo $BUILD_REPO_ISSUE_OUTPUT | jq -r '.[0].number')
90+
RELEASE_ISSUE="https://github.com/opensearch-project/opensearch-build/issues/${RELEASE_ISSUE_NUMBER}"
91+
RELEASE_VERSION_X=$(echo "${{ inputs.version }}" | awk -F'.' '{print $1}').x
92+
sed -e "s|{{RELEASE_VERSION}}|${RELEASE_VERSION}|g" -e "s|{{RELEASE_ISSUE}}|${RELEASE_ISSUE}|g" -e "s|{{RELEASE_BRANCH}}|${RELEASE_BRANCH}|g" -e "s|{{RELEASE_VERSION_X}}|${RELEASE_VERSION_X}|g" "$file_path" > "$file_path.tmp" && mv "$file_path.tmp" "$file_path"
93+
- name: Create component release issue from file
94+
if: steps.check_if_plugin_repo_issue_exists.outputs.issues == '[]'
95+
uses: peter-evans/create-issue-from-file@v4
96+
with:
97+
title: '[RELEASE] Release version ${{ inputs.version }}'
98+
content-filepath: ../opensearch-build/.github/ISSUE_TEMPLATE/component_release_template.md
99+
labels: v${{ inputs.version }}
100+
token: ${{ steps.github_app_token.outputs.token }}
101+
repository: opensearch-project/${{ matrix.repos }}

.github/workflows/os-release-issues.yml

+50-104
Original file line numberDiff line numberDiff line change
@@ -3,16 +3,6 @@ name: release-issue-os
33

44
on:
55
workflow_dispatch:
6-
inputs:
7-
logLevel:
8-
description: Log level
9-
required: true
10-
default: warning
11-
type: choice
12-
options:
13-
- info
14-
- warning
15-
- debug
166
schedule:
177
- cron: 0 1 * * *
188

@@ -21,103 +11,59 @@ jobs:
2111
if: github.repository == 'opensearch-project/opensearch-build'
2212
runs-on: ubuntu-latest
2313
outputs:
24-
matrix: ${{ steps.set-matrix.outputs.matrix }}
14+
versions_matrix: ${{ steps.set-matrix.outputs.versions }}
2515
steps:
26-
- uses: actions/checkout@v3
27-
with:
28-
repository: opensearch-project/opensearch-build
29-
ref: main
16+
- uses: actions/checkout@v4
3017
- id: set-matrix
31-
# produces a list of major versions, e.g. ["1.4.0","2.10.0","2.6.0","2.7.0","2.8.0","2.9.0","3.0.0"]
32-
run: echo "::set-output name=matrix::$(ls manifests/**/opensearch*.yml | cut -d'/' -f2 | grep '0$' | grep -v '[0-9]0$' | sort | uniq | jq -R -s -c 'split("\n")[:-1]')"
33-
component-release-issue:
18+
# produces a list of major.minor versions only, no patch versions e.g. ["1.4.0","2.10.0","2.6.0","2.7.0","2.8.0","2.9.0","3.0.0"]
19+
run: echo "versions=$(ls manifests/**/opensearch*.yml | cut -d'/' -f2 | grep '0$' | grep -v '[0-9]0$' | sort | uniq | jq -R -s -c 'split("\n")[:-1]')" >> $GITHUB_OUTPUT
20+
21+
list-components-per-version:
3422
needs: list-manifest-versions
3523
runs-on: ubuntu-latest
36-
strategy:
37-
fail-fast: false
38-
matrix:
39-
entry:
40-
- {repo: OpenSearch}
41-
- {repo: alerting}
42-
- {repo: anomaly-detection}
43-
- {repo: asynchronous-search}
44-
- {repo: common-utils}
45-
- {repo: cross-cluster-replication}
46-
- {repo: geospatial}
47-
- {repo: index-management}
48-
- {repo: job-scheduler}
49-
- {repo: k-NN}
50-
- {repo: neural-search}
51-
- {repo: ml-commons}
52-
- {repo: notifications}
53-
- {repo: observability}
54-
- {repo: performance-analyzer}
55-
- {repo: performance-analyzer-rca}
56-
- {repo: reporting}
57-
- {repo: security}
58-
- {repo: security-analytics}
59-
- {repo: sql}
60-
- {repo: custom-codecs}
61-
- {repo: flow-framework}
62-
- {repo: skills}
63-
- {repo: query-insights}
64-
- {repo: opensearch-system-templates}
65-
release_version: ${{ fromJson(needs.list-manifest-versions.outputs.matrix) }}
24+
outputs:
25+
version_components_matrix: ${{ steps.get-all-components.outputs.combined_matrix }}
6626
steps:
67-
- name: GitHub App token
68-
id: github_app_token
69-
uses: tibdex/github-app-token@v1.6.0
70-
with:
71-
app_id: ${{ secrets.APP_ID }}
72-
private_key: ${{ secrets.APP_PRIVATE_KEY }}
73-
installation_id: 22958780
74-
- name: Checkout
75-
uses: actions/checkout@v3
76-
- name: Check if build repo release issue exists
77-
id: check_if_build_repo_issue_exists
78-
uses: actions-cool/issues-helper@v3
79-
with:
80-
actions: 'find-issues'
81-
repo: opensearch-project/opensearch-build
82-
token: ${{ steps.github_app_token.outputs.token }}
83-
issue-state: 'open'
84-
title-includes: '[RELEASE] Release version ${{ matrix.release_version }}'
85-
- name: Check out plugin repo
86-
uses: actions/checkout@v3
87-
with:
88-
path: plugin-repo
89-
repository: opensearch-project/${{ matrix.entry.repo }}
90-
- name: Check if plugin repo release issue exists
91-
if: steps.check_if_build_repo_issue_exists.outputs.issues != '[]'
92-
id: check_if_plugin_repo_issue_exists
93-
uses: actions-cool/issues-helper@v3
94-
with:
95-
actions: 'find-issues'
96-
repo: opensearch-project/${{ matrix.entry.repo }}
97-
token: ${{ steps.github_app_token.outputs.token }}
98-
title-includes: '[RELEASE] Release version ${{ matrix.release_version }}'
99-
- name: Replace Placeholders
100-
if: steps.check_if_plugin_repo_issue_exists.outputs.issues == '[]'
27+
- uses: actions/checkout@v4
28+
29+
- id: get-all-components
10130
run: |
102-
# Read the file contents and replace the placeholders
103-
file_path="../opensearch-build/.github/ISSUE_TEMPLATE/component_release_template.md"
104-
RELEASE_VERSION="${{ matrix.release_version }}"
105-
RELEASE_BRANCH=$(echo ${{ matrix.release_version }} | cut -d. -f1-2)
106-
BUILD_REPO_ISSUE_OUTPUT=$(cat <<EOF
107-
${{ steps.check_if_build_repo_issue_exists.outputs.issues }}
108-
EOF
109-
)
110-
RELEASE_ISSUE_NUMBER=$(echo $BUILD_REPO_ISSUE_OUTPUT | jq -r '.[0].number')
111-
RELEASE_ISSUE="https://github.com/opensearch-project/opensearch-build/issues/${RELEASE_ISSUE_NUMBER}"
112-
RELEASE_VERSION_X=$(echo "${{ matrix.release_version }}" | awk -F'.' '{print $1}').x
113-
sed -e "s|{{RELEASE_VERSION}}|${RELEASE_VERSION}|g" -e "s|{{RELEASE_ISSUE}}|${RELEASE_ISSUE}|g" -e "s|{{RELEASE_BRANCH}}|${RELEASE_BRANCH}|g" -e "s|{{RELEASE_VERSION_X}}|${RELEASE_VERSION_X}|g" "$file_path" > "$file_path.tmp" && mv "$file_path.tmp" "$file_path"
114-
- name: Create component release issue from file
115-
if: steps.check_if_plugin_repo_issue_exists.outputs.issues == '[]'
116-
uses: peter-evans/create-issue-from-file@v4
117-
with:
118-
title: '[RELEASE] Release version ${{ matrix.release_version }}'
119-
content-filepath: ../opensearch-build/.github/ISSUE_TEMPLATE/component_release_template.md
120-
labels: |
121-
v${{ matrix.release_version }}
122-
token: ${{ steps.github_app_token.outputs.token }}
123-
repository: opensearch-project/${{ matrix.entry.repo }}
31+
versions_array=${{ needs.list-manifest-versions.outputs.versions_matrix }}
32+
33+
# Remove brackets from the array string
34+
versions_array="${versions_array:1:-1}"
35+
36+
# Split by commas and process each version
37+
IFS=',' read -ra VERSIONS <<< "$versions_array"
38+
39+
# Initialize an array to store all entries
40+
declare -a matrix_entries=()
41+
42+
for version in "${VERSIONS[@]}"; do
43+
# Remove quotes and whitespace from version
44+
version=$(echo $version | tr -d '"' | xargs)
45+
46+
# Get components for this version
47+
components=$(yq eval '.components[].repository' "manifests/$version/opensearch-$version.yml" | \
48+
sed 's/.*\///;s/\.git$//' | \
49+
jq -R -s -c 'split("\n")[:-1]')
50+
51+
# Add this version-components pair to the matrix
52+
matrix_entries+=("{\"version\":\"$version\",\"components\":$components}")
53+
done
54+
55+
# Combine all entries into the final matrix format
56+
matrix_json="{\"include\":[$(IFS=,; echo "${matrix_entries[*]}")]}"
57+
58+
echo "combined_matrix=$matrix_json" >> $GITHUB_OUTPUT
59+
60+
trigger-issue-creation-workflow:
61+
needs: list-components-per-version
62+
strategy:
63+
matrix: ${{ fromJson(needs.list-components-per-version.outputs.version_components_matrix) }}
64+
fail-fast: false
65+
uses: ./.github/workflows/create-release-issues.yml
66+
secrets: inherit
67+
with:
68+
version: ${{ matrix.version }}
69+
repos: ${{ toJson(matrix.components) }}

0 commit comments

Comments
 (0)