forked from opensearch-project/OpenSearch
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
[Github Action] Enhance version increment script to create tracking i…
…ssue (opensearch-project#11926) Signed-off-by: Kunal Kotwani <[email protected]>
- Loading branch information
1 parent
d99c573
commit 99b25be
Showing
1 changed file
with
69 additions
and
40 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,28 +1,32 @@ | ||
name: Increment Version | ||
|
||
on: | ||
workflow_dispatch: | ||
inputs: | ||
tag: | ||
description: 'the tag' | ||
required: true | ||
type: string | ||
push: | ||
tags: | ||
- '*.*.*' | ||
|
||
permissions: {} | ||
permissions: | ||
contents: write | ||
issues: write | ||
pull-requests: write | ||
|
||
jobs: | ||
build: | ||
if: github.repository == 'opensearch-project/OpenSearch' | ||
runs-on: ubuntu-latest | ||
steps: | ||
- 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 | ||
|
||
- uses: actions/checkout@v4 | ||
- name: Fetch Tag and Version Information | ||
- name: Fetch tag and version information | ||
run: | | ||
TAG=$(echo "${GITHUB_REF#refs/*/}") | ||
if [ -n ${{ github.event.inputs.tag }} ]; then | ||
TAG=${{ github.event.inputs.tag }} | ||
fi | ||
CURRENT_VERSION_ARRAY=($(echo "$TAG" | tr . '\n')) | ||
BASE=$(IFS=. ; echo "${CURRENT_VERSION_ARRAY[*]:0:2}") | ||
BASE_X=$(IFS=. ; echo "${CURRENT_VERSION_ARRAY[*]:0:1}.x") | ||
|
@@ -44,24 +48,22 @@ jobs: | |
echo "NEXT_VERSION=$NEXT_VERSION" >> $GITHUB_ENV | ||
echo "NEXT_VERSION_UNDERSCORE=$NEXT_VERSION_UNDERSCORE" >> $GITHUB_ENV | ||
echo "NEXT_VERSION_ID=$NEXT_VERSION_ID" >> $GITHUB_ENV | ||
- uses: actions/checkout@v4 | ||
with: | ||
ref: ${{ env.BASE }} | ||
token: ${{ steps.github_app_token.outputs.token }} | ||
|
||
- name: Increment Patch Version | ||
run: | | ||
echo Incrementing $CURRENT_VERSION to $NEXT_VERSION | ||
echo " - \"$CURRENT_VERSION\"" >> .ci/bwcVersions | ||
sed -i "s/opensearch = $CURRENT_VERSION/opensearch = $NEXT_VERSION/g" buildSrc/version.properties | ||
echo Adding $NEXT_VERSION_UNDERSCORE after $CURRENT_VERSION_UNDERSCORE | ||
sed -i "s/public static final Version $CURRENT_VERSION_UNDERSCORE = new Version(\([[:digit:]]\+\)\(.*\));/\0\n public static final Version $NEXT_VERSION_UNDERSCORE = new Version($NEXT_VERSION_ID\2);/g" libs/core/src/main/java/org/opensearch/Version.java | ||
sed -i "s/CURRENT = $CURRENT_VERSION_UNDERSCORE;/CURRENT = $NEXT_VERSION_UNDERSCORE;/g" libs/core/src/main/java/org/opensearch/Version.java | ||
- name: Increment Patch Version on Major.Minor branch | ||
uses: peternied/opensearch-core-version-updater@v1 | ||
with: | ||
previous-version: ${{ env.CURRENT_VERSION }} | ||
new-version: ${{ env.NEXT_VERSION }} | ||
update-current: true | ||
|
||
- name: Create Pull Request | ||
- name: Create PR for BASE | ||
id: base_pr | ||
uses: peter-evans/create-pull-request@v5 | ||
with: | ||
token: ${{ steps.github_app_token.outputs.token }} | ||
base: ${{ env.BASE }} | ||
branch: 'create-pull-request/patch-${{ env.BASE }}' | ||
commit-message: Increment version to ${{ env.NEXT_VERSION }} | ||
|
@@ -76,19 +78,18 @@ jobs: | |
- uses: actions/checkout@v4 | ||
with: | ||
ref: ${{ env.BASE_X }} | ||
token: ${{ steps.github_app_token.outputs.token }} | ||
|
||
- name: Add bwc version to .X branch | ||
run: | | ||
echo Adding bwc version $NEXT_VERSION after $CURRENT_VERSION | ||
sed -i "s/- \"$CURRENT_VERSION\"/\0\n - \"$NEXT_VERSION\"/g" .ci/bwcVersions | ||
echo Adding $NEXT_VERSION_UNDERSCORE after $CURRENT_VERSION_UNDERSCORE | ||
sed -i "s/public static final Version $CURRENT_VERSION_UNDERSCORE = new Version(\([[:digit:]]\+\)\(.*\));/\0\n public static final Version $NEXT_VERSION_UNDERSCORE = new Version($NEXT_VERSION_ID\2);/g" libs/core/src/main/java/org/opensearch/Version.java | ||
- name: Add Patch Version on Major.X branch | ||
uses: peternied/opensearch-core-version-updater@v1 | ||
with: | ||
previous-version: ${{ env.CURRENT_VERSION }} | ||
new-version: ${{ env.NEXT_VERSION }} | ||
update-current: false | ||
|
||
- name: Create Pull Request | ||
- name: Create PR for BASE_X | ||
id: base_x_pr | ||
uses: peter-evans/create-pull-request@v5 | ||
with: | ||
token: ${{ steps.github_app_token.outputs.token }} | ||
base: ${{ env.BASE_X }} | ||
branch: 'create-pull-request/patch-${{ env.BASE_X }}' | ||
commit-message: Add bwc version ${{ env.NEXT_VERSION }} | ||
|
@@ -103,19 +104,18 @@ jobs: | |
- uses: actions/checkout@v4 | ||
with: | ||
ref: main | ||
token: ${{ steps.github_app_token.outputs.token }} | ||
|
||
- name: Add bwc version to main branch | ||
run: | | ||
echo Adding bwc version $NEXT_VERSION after $CURRENT_VERSION | ||
sed -i "s/- \"$CURRENT_VERSION\"/\0\n - \"$NEXT_VERSION\"/g" .ci/bwcVersions | ||
echo Adding $NEXT_VERSION_UNDERSCORE after $CURRENT_VERSION_UNDERSCORE | ||
sed -i "s/public static final Version $CURRENT_VERSION_UNDERSCORE = new Version(\([[:digit:]]\+\)\(.*\));/\0\n public static final Version $NEXT_VERSION_UNDERSCORE = new Version($NEXT_VERSION_ID\2);/g" libs/core/src/main/java/org/opensearch/Version.java | ||
- name: Add Patch Version on main branch | ||
uses: peternied/opensearch-core-version-updater@v1 | ||
with: | ||
previous-version: ${{ env.CURRENT_VERSION }} | ||
new-version: ${{ env.NEXT_VERSION }} | ||
update-current: false | ||
|
||
- name: Create Pull Request | ||
- name: Create PR for main | ||
id: main_pr | ||
uses: peter-evans/create-pull-request@v5 | ||
with: | ||
token: ${{ steps.github_app_token.outputs.token }} | ||
base: main | ||
branch: 'create-pull-request/patch-main' | ||
commit-message: Add bwc version ${{ env.NEXT_VERSION }} | ||
|
@@ -126,3 +126,32 @@ jobs: | |
title: '[AUTO] [main] Add bwc version ${{ env.NEXT_VERSION }}.' | ||
body: | | ||
I've noticed that a new tag ${{ env.TAG }} was pushed, and added a bwc version ${{ env.NEXT_VERSION }}. | ||
- name: Create tracking issue | ||
id: create-issue | ||
uses: actions/[email protected] | ||
with: | ||
script: | | ||
const body = ` | ||
### Description | ||
A new version of OpenSearch was released, to prepare for the next release new version numbers need to be updated in all active branches of development. | ||
### Exit Criteria | ||
Review and merged the following pull requests | ||
- [ ] ${{ steps.base_pr.outputs.pull-request-url }} | ||
- [ ] ${{ steps.base_x_pr.outputs.pull-request-url }} | ||
- [ ] ${{ steps.main_pr.outputs.pull-request-url }} | ||
### Additional Context | ||
See project wide guidance on branching and versions [[link]](https://github.com/opensearch-project/.github/blob/main/RELEASING.md). | ||
` | ||
const { data: issue }= await github.rest.issues.create({ | ||
owner: context.repo.owner, | ||
repo: context.repo.repo, | ||
labels: ["Build"], | ||
title: "Increment version for ${{ env.NEXT_VERSION }}", | ||
body: body | ||
}); | ||
console.error(JSON.stringify(issue)); | ||
return issue.number; | ||
result-encoding: string |