From 1e29bf0b9bd8118e718f98a7e9c1c943c1f49b4d Mon Sep 17 00:00:00 2001 From: Yury-Fridlyand Date: Fri, 23 Jun 2023 09:43:32 -0700 Subject: [PATCH] Onboard 1-click release process (#52) * Add release drafter and jenkins workflows. Signed-off-by: Yury-Fridlyand * Add RELEASING. Signed-off-by: Yury-Fridlyand * Typo fix. Signed-off-by: Yury-Fridlyand * Minor fix. Signed-off-by: Yury-Fridlyand * Pack artifacts into single archive. Signed-off-by: Yury-Fridlyand * Apply suggestions from code review Co-authored-by: Sayali Gaikawad <61760125+gaiksaya@users.noreply.github.com> Signed-off-by: Yury-Fridlyand * Rename artifacts. Signed-off-by: Yury-Fridlyand * Add auto-release approval mechanism. Signed-off-by: Yury-Fridlyand * Fix getting version. Signed-off-by: Yury-Fridlyand --------- Signed-off-by: Yury-Fridlyand Co-authored-by: Sayali Gaikawad <61760125+gaiksaya@users.noreply.github.com> --- .../draft-release-notes-workflow.yml | 2 +- .github/workflows/release-drafter.yml | 45 +++++++++++++++++++ RELEASING.md | 40 +++++++++++++++++ jenkins/release.jenkinsFile | 35 +++++++++++++++ ...l-odbc.OpenSearch.release-notes-1.5.0.0.md | 2 + 5 files changed, 123 insertions(+), 1 deletion(-) create mode 100644 .github/workflows/release-drafter.yml create mode 100644 RELEASING.md create mode 100644 jenkins/release.jenkinsFile diff --git a/.github/workflows/draft-release-notes-workflow.yml b/.github/workflows/draft-release-notes-workflow.yml index 2c4567d..f169710 100644 --- a/.github/workflows/draft-release-notes-workflow.yml +++ b/.github/workflows/draft-release-notes-workflow.yml @@ -1,4 +1,4 @@ -name: Release Drafter +name: Release Notes Drafter on: push: diff --git a/.github/workflows/release-drafter.yml b/.github/workflows/release-drafter.yml new file mode 100644 index 0000000..731a193 --- /dev/null +++ b/.github/workflows/release-drafter.yml @@ -0,0 +1,45 @@ +name: Release drafter + +# Push events to every tag not containing "/" +on: + push: + tags: + - "*" + +jobs: + draft-a-release: + name: Draft a release + runs-on: ubuntu-latest + steps: + - id: get_data + run: | + echo "approvers=$(cat .github/CODEOWNERS | grep @ | tr -d '*\n ' | sed 's/@/,/g' | sed 's/,//1')" >> $GITHUB_OUTPUT + echo "version=$(grep DRIVER_PACKAGE_VERSION src/CMakeLists.txt | grep -o -P '\d+\.\d+\.\d+\.\d+')" >> $GITHUB_OUTPUT + - uses: trstringer/manual-approval@v1 + with: + secret: ${{ github.TOKEN }} + approvers: ${{ steps.get_data.outputs.approvers }} + minimum-approvals: 2 + issue-title: 'Release ODBC driver version ${{ steps.get_data.outputs.version }}' + issue-body: "Please approve or deny the release of ODBC Driver **TAG**: ${{ github.ref_name }} **COMMIT**: ${{ github.sha }} **VERSION** : ${{ steps.get_data.outputs.version }} " + exclude-workflow-initiator-as-approver: true + + - name: Download artifacts + uses: dawidd6/action-download-artifact@v2.27.0 + with: + workflow: sql-odbc-main.yml + commit: ${{github.sha}} + workflow_conclusion: success + + - name: Rename and pack artifacts + run: | + # replace spaces by dashes in file names + for i in *-installer/*; do mv "$i" "${i//\ /-}"; done + tar -cvf artifacts.tar.gz *-installer + + - name: Draft a release + uses: softprops/action-gh-release@v1 + with: + draft: true + generate_release_notes: true + files: artifacts.tar.gz diff --git a/RELEASING.md b/RELEASING.md new file mode 100644 index 0000000..8ee6cce --- /dev/null +++ b/RELEASING.md @@ -0,0 +1,40 @@ +- [Overview](#overview) +- [Branching](#branching) + - [Release Branching](#release-branching) + - [Feature Branches](#feature-branches) +- [Release Labels](#release-labels) +- [Releasing](#releasing) + +## Overview + +This document explains the release strategy for artifacts in this organization. + +## Branching + +### Release Branching + +Given the current major release of 1.0, projects in this organization maintain the following active branches. + +* **main**: The next _major_ release. This is the branch where all merges take place and code moves fast. +* **1.x**: The next _minor_ release. Once a change is merged into `main`, decide whether to backport it to `1.x`. +* **1.0**: The _current_ release. In between minor releases, only hotfixes (e.g. security) are backported to `1.0`. + +Label PRs with the next major version label (e.g. `v2.0.0.0`) and merge changes into `main`. Label PRs that you believe need to be backported as `backport 1.x` and `backport 1.0`. Backport PRs by checking out the versioned branch, cherry-pick changes and open a PR against each target backport branch. + +### Feature Branches + +Do not create branches in the upstream repo, use your fork, for the exception of long lasting feature branches that require active collaboration from multiple developers. Name feature branches `feature/`. Once the work is merged to `main`, please make sure to delete the feature branch. + +## Release Labels + +Repositories create consistent release labels, such as `v1.0.0`, `v1.1.0` and `v2.0.0`, as well as `patch` and `backport`. Use release labels to target an issue or a PR for a given release. + +## Releasing + +The release process is standard across repositories in this org and is run by a release manager volunteering from amongst [maintainers](MAINTAINERS.md). + +1. Create a tag, e.g. 1.0.0.0, and push it to this GitHub repository. +2. The [release-drafter.yml](.github/workflows/release-drafter.yml) will be automatically kicked off and a draft release will be created. +3. This draft release triggers the [jenkins release workflow](https://build.ci.opensearch.org/job/sql-odbc-release) as a result of which the driver is released and published on artifacts (https://artifacts.opensearch.org/opensearch-clients/odbc/). Please note, that the release workflow is triggered only if created release is in draft state. Manual update on the [download page](https://opensearch.org/downloads.html#drivers) is required after that, see [website repo](https://github.com/opensearch-project/project-website/tree/main/_artifacts/opensearch-drivers). +4. Once the above release workflow is successful, the drafted release on GitHub is published automatically. +5. Increment `DRIVER_PACKAGE_VERSION` in [src/CMakeLists.txt](src/CMakeLists.txt) to the next iteration, e.g. 1.0.0.1 See [example](https://github.com/opensearch-project/sql-odbc/pull/47). diff --git a/jenkins/release.jenkinsFile b/jenkins/release.jenkinsFile new file mode 100644 index 0000000..6d68eaf --- /dev/null +++ b/jenkins/release.jenkinsFile @@ -0,0 +1,35 @@ +lib = library(identifier: 'jenkins@4.2.2', retriever: modernSCM([ + $class: 'GitSCMSource', + remote: 'https://github.com/opensearch-project/opensearch-build-libraries.git', +])) + +standardReleasePipelineWithGenericTrigger( + tokenIdCredential: 'jenkins-sql-odbc-generic-webhook-token', + causeString: 'A tag was cut on opensearch-project/sql-odbc repository causing this workflow to run', + downloadReleaseAsset: true, + publishRelease: true) { + publishToArtifactsProdBucket( + assumedRoleName: 'sql-odbc-upload-role', + source: 'windows32-installer/OpenSearch-SQL-ODBC-Driver-32-bit-1.5.0.0-Windows.msi', + destination: 'opensearch-clients/odbc/opensearch-sql-odbc-driver-32-bit-1.5.0.0-Windows.msi', + signingPlatform: 'windows', + sigType: 'null', + sigOverwrite: true + ) + publishToArtifactsProdBucket( + assumedRoleName: 'sql-odbc-upload-role', + source: 'windows64-installer/OpenSearch-SQL-ODBC-Driver-64-bit-1.5.0.0-Windows.msi', + destination: 'opensearch-clients/odbc/opensearch-sql-odbc-driver-64-bit-1.5.0.0-Windows.msi', + signingPlatform: 'windows', + sigType: 'null', + sigOverwrite: true + ) + publishToArtifactsProdBucket( + assumedRoleName: 'sql-odbc-upload-role', + source: 'mac64-installer/OpenSearch-SQL-ODBC-Driver-64-bit-1.5.0.0-Darwin.pkg', + destination: 'opensearch-clients/odbc/opensearch-sql-odbc-driver-64-bit-1.5.0.0-Darwin.pkg', + signingPlatform: 'macos', + sigType: 'null', + sigOverwrite: true + ) + } diff --git a/release-notes/sql-odbc.OpenSearch.release-notes-1.5.0.0.md b/release-notes/sql-odbc.OpenSearch.release-notes-1.5.0.0.md index 6f61351..e92c4e4 100644 --- a/release-notes/sql-odbc.OpenSearch.release-notes-1.5.0.0.md +++ b/release-notes/sql-odbc.OpenSearch.release-notes-1.5.0.0.md @@ -41,3 +41,5 @@ * Bump version and update vendor. ([#47](https://github.com/opensearch-project/sql-odbc/pull/47)) * Add release notes for version 1.5. ([#49](https://github.com/opensearch-project/sql-odbc/pull/49)) * Update `.gitignore`. ([#50](https://github.com/opensearch-project/sql-odbc/pull/50)) +* Update maintainer list. ([#51](https://github.com/opensearch-project/sql-odbc/pull/51)) +* Onboard 1 click release process. ([#52](https://github.com/opensearch-project/sql-odbc/pull/52)