From cc008d8f792c6e7ae8be820e5d267b6553fb0662 Mon Sep 17 00:00:00 2001 From: Sayali Gaikawad Date: Mon, 7 Nov 2022 12:28:04 -0800 Subject: [PATCH 1/5] Add automation for backport and version increment Signed-off-by: Sayali Gaikawad --- .github/workflows/backport.yml | 28 ++++++++++++ .github/workflows/delete-backport-branch.yml | 15 +++++++ .github/workflows/version-increment.yml | 46 ++++++++++++++++++++ build.gradle | 14 ++++++ 4 files changed, 103 insertions(+) create mode 100644 .github/workflows/backport.yml create mode 100644 .github/workflows/delete-backport-branch.yml create mode 100644 .github/workflows/version-increment.yml diff --git a/.github/workflows/backport.yml b/.github/workflows/backport.yml new file mode 100644 index 000000000..bfd6b393e --- /dev/null +++ b/.github/workflows/backport.yml @@ -0,0 +1,28 @@ +name: Backport +on: + pull_request_target: + types: + - closed + - labeled + +jobs: + backport: + runs-on: ubuntu-latest + permissions: + contents: write + pull-requests: write + name: Backport + steps: + - name: GitHub App token + id: github_app_token + uses: tibdex/github-app-token@v1.5.0 + with: + app_id: ${{ secrets.APP_ID }} + private_key: ${{ secrets.APP_PRIVATE_KEY }} + installation_id: 22958780 + + - name: Backport + uses: VachaShah/backport@v2.1.0 + with: + github_token: ${{ steps.github_app_token.outputs.token }} + head_template: backport/backport-<%= number %>-to-<%= base %> \ No newline at end of file diff --git a/.github/workflows/delete-backport-branch.yml b/.github/workflows/delete-backport-branch.yml new file mode 100644 index 000000000..d654df6b4 --- /dev/null +++ b/.github/workflows/delete-backport-branch.yml @@ -0,0 +1,15 @@ +name: Delete merged branch of the backport PRs +on: + pull_request: + types: + - closed + +jobs: + delete-branch: + runs-on: ubuntu-latest + if: startsWith(github.event.pull_request.head.ref,'backport/') + steps: + - name: Delete merged branch + uses: SvanBoxel/delete-merged-branch@main + env: + GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} \ No newline at end of file diff --git a/.github/workflows/version-increment.yml b/.github/workflows/version-increment.yml new file mode 100644 index 000000000..ecc233901 --- /dev/null +++ b/.github/workflows/version-increment.yml @@ -0,0 +1,46 @@ +name: Backport +on: + push: + paths: + - build.gradle + workflow_dispatch: + +jobs: + version-increment: + runs-on: ubuntu-latest + permissions: + contents: write + pull-requests: write + name: version-increment + steps: + - name: Run gradle task + id: gradle + run: ./gradlew updateVersion + - name: GitHub App token + id: github_app_token + uses: tibdex/github-app-token@v1.6.0 + with: + app_id: ${{ secrets.APP_ID }} + private_key: ${{ secrets.APP_PRIVATE_KEY }} + installation_id: 22958780 + - name: Create Pull Request + id: cpr + uses: peter-evans/create-pull-request@v4 + with: + token: ${{ steps.github_app_token.outputs.token }} + base: '1.x' + committer: opensearch-ci-bot + author: opensearch-ci-bot + commit-message: | + Increment jenkins library version + + Signed-off-by: opensearch-ci-bot + delete-branch: true + branch: create-pull-request + title: '[AUTO] Increment jenkins library version' + body: | + - Increment jenkins library 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 }}" \ No newline at end of file diff --git a/build.gradle b/build.gradle index 5f17448eb..8d0632900 100644 --- a/build.gradle +++ b/build.gradle @@ -119,3 +119,17 @@ jacocoTestReport { xml.required = true } } + +String version = '1.1.2' + +task updateVersion { + doLast { + println "Setting version to ${version} in all libraries" + ant.replaceregexp(match:'jenkins@main', replace: 'jenkins@' + version, flags: 'g') { + fileset(dir: projectDir) { + include (name: "vars/**") + include (name: "tests/**") + } + } + } +} From 50fcefda76a107c95e86f900c311f9a7ad0d9331 Mon Sep 17 00:00:00 2001 From: Sayali Gaikawad Date: Mon, 7 Nov 2022 12:37:35 -0800 Subject: [PATCH 2/5] fix lint Signed-off-by: Sayali Gaikawad --- .github/workflows/backport.yml | 3 ++- .github/workflows/delete-backport-branch.yml | 5 +++-- .github/workflows/version-increment.yml | 8 +++++--- 3 files changed, 10 insertions(+), 6 deletions(-) diff --git a/.github/workflows/backport.yml b/.github/workflows/backport.yml index bfd6b393e..2105bae73 100644 --- a/.github/workflows/backport.yml +++ b/.github/workflows/backport.yml @@ -1,3 +1,4 @@ +--- name: Backport on: pull_request_target: @@ -25,4 +26,4 @@ jobs: uses: VachaShah/backport@v2.1.0 with: github_token: ${{ steps.github_app_token.outputs.token }} - head_template: backport/backport-<%= number %>-to-<%= base %> \ No newline at end of file + head_template: backport/backport-<%= number %>-to-<%= base %> diff --git a/.github/workflows/delete-backport-branch.yml b/.github/workflows/delete-backport-branch.yml index d654df6b4..a0ac0ec9d 100644 --- a/.github/workflows/delete-backport-branch.yml +++ b/.github/workflows/delete-backport-branch.yml @@ -1,9 +1,10 @@ +--- name: Delete merged branch of the backport PRs -on: +on: pull_request: types: - closed - + jobs: delete-branch: runs-on: ubuntu-latest diff --git a/.github/workflows/version-increment.yml b/.github/workflows/version-increment.yml index ecc233901..01cd9c1eb 100644 --- a/.github/workflows/version-increment.yml +++ b/.github/workflows/version-increment.yml @@ -1,4 +1,5 @@ -name: Backport +--- +name: Increment Version on: push: paths: @@ -15,7 +16,8 @@ jobs: steps: - name: Run gradle task id: gradle - run: ./gradlew updateVersion + run: | + ./gradlew updateVersion - name: GitHub App token id: github_app_token uses: tibdex/github-app-token@v1.6.0 @@ -43,4 +45,4 @@ jobs: - name: Check outputs run: |- echo "Pull Request Number - ${{ steps.cpr.outputs.pull-request-number }}" - echo "Pull Request URL - ${{ steps.cpr.outputs.pull-request-url }}" \ No newline at end of file + echo "Pull Request URL - ${{ steps.cpr.outputs.pull-request-url }}" From db96790e5b0bdee3e02d951db528c34a77193303 Mon Sep 17 00:00:00 2001 From: Sayali Gaikawad Date: Mon, 7 Nov 2022 12:38:48 -0800 Subject: [PATCH 3/5] fix lint Signed-off-by: Sayali Gaikawad --- .github/workflows/delete-backport-branch.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/delete-backport-branch.yml b/.github/workflows/delete-backport-branch.yml index a0ac0ec9d..2e34a76f5 100644 --- a/.github/workflows/delete-backport-branch.yml +++ b/.github/workflows/delete-backport-branch.yml @@ -13,4 +13,4 @@ jobs: - name: Delete merged branch uses: SvanBoxel/delete-merged-branch@main env: - GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} \ No newline at end of file + GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} From 021df3850ea70b3ca1d8a63f7777849dab4cae87 Mon Sep 17 00:00:00 2001 From: Sayali Gaikawad Date: Mon, 7 Nov 2022 13:06:20 -0800 Subject: [PATCH 4/5] Add checkout Signed-off-by: Sayali Gaikawad --- .github/workflows/version-increment.yml | 2 ++ 1 file changed, 2 insertions(+) diff --git a/.github/workflows/version-increment.yml b/.github/workflows/version-increment.yml index 01cd9c1eb..ea83fa626 100644 --- a/.github/workflows/version-increment.yml +++ b/.github/workflows/version-increment.yml @@ -14,6 +14,8 @@ jobs: pull-requests: write name: version-increment steps: + - name: Check out OpenSearch repo + uses: actions/checkout@v3 - name: Run gradle task id: gradle run: | From 6c823513aa0b562a81d4661c3752283ad23c602f Mon Sep 17 00:00:00 2001 From: Sayali Gaikawad Date: Mon, 7 Nov 2022 18:10:34 -0800 Subject: [PATCH 5/5] Update releasing.md Signed-off-by: Sayali Gaikawad --- RELEASING.md | 10 +++++++++- 1 file changed, 9 insertions(+), 1 deletion(-) diff --git a/RELEASING.md b/RELEASING.md index 4f234e470..142b982ab 100644 --- a/RELEASING.md +++ b/RELEASING.md @@ -1,4 +1,5 @@ - [Overview](#overview) +- [Backporting](#backporting) - [Versioning](#versioning) - [Releasing](#releasing) @@ -6,6 +7,10 @@ This document explains the release strategy for artifacts in this organization. +## Backporting +The tags are based on major.x branches. Hence each PR needs to be backported to respective major.x branch in order to included in next release. +The Github workflow [backport.yml](.github/workflows/backport.yml) creates backport PRs automatically when the original PR with an appropriate label backport is merged to main with the backport workflow run successfully on the PR. For example, if a PR on main needs to be backported to 1.x branch, add a label backport 1.x to the PR and make sure the backport workflow runs on the PR along with other checks. Once this PR is merged to main, the workflow will create a backport PR against 1.x branch. + ## Versioning This respository, as other in this organization follows semantic versioning. @@ -16,4 +21,7 @@ This respository, as other in this organization follows semantic versioning. ## Releasing -The release process includes a [maintainer](MAINTAINERS.md) pushing a tag to this repository which creates a release on GitHub via [release.yml](./.github/workflows/release.yml) workflow. \ No newline at end of file +The release process includes a [maintainer](MAINTAINERS.md) voluntering for the release. They need to follow the below steps: +* Changing the version number in [build.gradle](https://github.com/opensearch-project/opensearch-build-libraries/blob/main/build.gradle#L123). +* This trigger the [version increment workflow](.github/workflows/version-increment.yml) and creates a version increment PR across the 1.x branch. [Example](https://github.com/gaiksaya/opensearch-build-libraries-1/pull/1) +* Once merged, the maintainer needs to push a tag based on 1.x which creates a release on GitHub via [release.yml](./.github/workflows/release.yml) workflow. \ No newline at end of file