Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add automation for backport and version increment #30

Merged
merged 5 commits into from
Nov 11, 2022
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
29 changes: 29 additions & 0 deletions .github/workflows/backport.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@
---
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 %>
16 changes: 16 additions & 0 deletions .github/workflows/delete-backport-branch.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
---
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 }}
50 changes: 50 additions & 0 deletions .github/workflows/version-increment.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,50 @@
---
name: Increment Version
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: Check out OpenSearch repo
uses: actions/checkout@v3
- 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 <opensearch-infra@amazon.com>
author: opensearch-ci-bot <opensearch-infra@amazon.com>
commit-message: |
Increment jenkins library version

Signed-off-by: opensearch-ci-bot <opensearch-infra@amazon.com>
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 }}"
10 changes: 9 additions & 1 deletion RELEASING.md
Original file line number Diff line number Diff line change
@@ -1,11 +1,16 @@
- [Overview](#overview)
- [Backporting](#backporting)
- [Versioning](#versioning)
- [Releasing](#releasing)

## Overview

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 <backport-branch-name> 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.
Expand All @@ -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.
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.
14 changes: 14 additions & 0 deletions build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -119,3 +119,17 @@ jacocoTestReport {
xml.required = true
}
}

String version = '1.1.2'
peterzhuamazon marked this conversation as resolved.
Show resolved Hide resolved

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/**")
}
}
}
}