From 93ee7c9418d63f08fa0b2c50ad861ee9dbe63304 Mon Sep 17 00:00:00 2001 From: Gerard Casas Saez Date: Thu, 2 Feb 2023 10:58:43 -0700 Subject: [PATCH] Experimental minor_release workflow (#204) * experimental minor_release workflow * Update minor_release.yml * Update RELEASE.md * Update minor_release.yml * Update minor_release.yml * Create update_main.py * update release.md * add more details to release.md --- .github/workflows/minor_release.yml | 64 ++++++++++++++++++++++ .github/workflows/prepare_minor_release.py | 41 ++++++++++++++ .github/workflows/update_main.py | 42 ++++++++++++++ RELEASE.md | 14 ++++- 4 files changed, 160 insertions(+), 1 deletion(-) create mode 100644 .github/workflows/minor_release.yml create mode 100644 .github/workflows/prepare_minor_release.py create mode 100644 .github/workflows/update_main.py diff --git a/.github/workflows/minor_release.yml b/.github/workflows/minor_release.yml new file mode 100644 index 00000000..0223b62f --- /dev/null +++ b/.github/workflows/minor_release.yml @@ -0,0 +1,64 @@ +name: Create Minor Release +on: + workflow_dispatch: + +jobs: + createrelease: + runs-on: ubuntu-latest + + steps: + - name: Check out code + uses: actions/checkout@v2 + - name: Set minor version + id: set-version + run: | + echo "::set-output name=version::$(python ./.github/workflows/prepare_minor_release.py)" + - name: Create release branch + run: git checkout -b r${{ steps.set-version.outputs.version }} + - name: Initialize mandatory git config + run: | + git config user.name "GitHub Actions" + git config user.email noreply@github.com + - name: Commit changelog and manifest files + id: make-commit + run: | + git add tfx_addons/version.py + git commit --message "Prepare release ${{ steps.set-version.outputs.version }}" + echo "::set-output name=commit::$(git rev-parse HEAD)" + - name: Push new branch + run: git push origin r${{ steps.set-version.outputs.version }} + - uses: ncipollo/release-action@v1 + with: + name: v${{ steps.set-version.outputs.version }}.0rc0 + commit: ${{ steps.make-commit.outputs.commit }} + prerelease: true + draft: true + generateReleaseNotes: true + skipIfReleaseExists: true + tag: v${{ steps.set-version.outputs.version }}.0rc0 + - name: Update main + id: update-main + run: | + git checkout main + echo "::set-output name=new_version::$(python ./.github/workflows/update_main.py)" + - name: Commit main change + run: | + git checkout -b ${{ github.triggering_actor }}/update-${{ steps.update-main.outputs.new_version }} + git add tfx_addons/version.py + git commit --message "Update main to ${{ steps.update-main.outputs.new_version }}" + git push origin ${{ github.triggering_actor }}/update-${{ steps.update-main.outputs.new_version }} + + - name: Create pull request into main + uses: thomaseizinger/create-pull-request@1.0.0 + with: + GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} + head: ${{ github.triggering_actor }}/update-${{ steps.update-main.outputs.new_version }} + base: main + title: Update minor version to ${{ steps.update-main.outputs.new_version }} + reviewers: ${{ github.triggering_actor }} + body: | + This is an automatic PR triggered by ${{ github.triggering_actor }} to prepare for ${{ steps.set-version.outputs.version }} release. + + Approve and merge in order to update main branch to ${{ steps.update-main.outputs.new_version }}. + + Check out [RELEASE.md](https://github.com/tensorflow/tfx-addons/blob/main/RELEASE.md) for more details. diff --git a/.github/workflows/prepare_minor_release.py b/.github/workflows/prepare_minor_release.py new file mode 100644 index 00000000..88d8d2a3 --- /dev/null +++ b/.github/workflows/prepare_minor_release.py @@ -0,0 +1,41 @@ +# Copyright 2022 The TensorFlow Authors. All Rights Reserved. +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. +# ============================================================================== +"""Internal script to perform a minor release""" +import logging +import os +import sys + +logging.getLogger().setLevel(logging.INFO) +# Dynamically load root as module so that we can import version +BASE_DIR = os.path.dirname( + os.path.dirname(os.path.dirname(os.path.abspath(__file__)))) +sys.path.append(BASE_DIR) + +import tfx_addons as tfxa # pylint: disable=wrong-import-position + +current_version = tfxa.__version__ +major, minor, patch = current_version.split(".") + +with open(os.path.join(BASE_DIR, "tfx_addons", "version.py")) as f: + lines = f.readlines() + +with open(os.path.join(BASE_DIR, "tfx_addons", "version.py"), "w") as f: + for l in lines: + if l.startswith("_VERSION_SUFFIX"): + f.write('_VERSION_SUFFIX = "rc0"\n') + else: + f.write(l) + +print(".".join([major, minor])) diff --git a/.github/workflows/update_main.py b/.github/workflows/update_main.py new file mode 100644 index 00000000..dd7452e3 --- /dev/null +++ b/.github/workflows/update_main.py @@ -0,0 +1,42 @@ +# Copyright 2022 The TensorFlow Authors. All Rights Reserved. +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. +# ============================================================================== +"""Internal script to perform a minor release""" +import logging +import os +import sys + +logging.getLogger().setLevel(logging.INFO) +# Dynamically load root as module so that we can import version +BASE_DIR = os.path.dirname( + os.path.dirname(os.path.dirname(os.path.abspath(__file__)))) +sys.path.append(BASE_DIR) + +import tfx_addons as tfxa # pylint: disable=wrong-import-position + +current_version = tfxa.__version__ +major, minor, patch = current_version.split(".") + +with open(os.path.join(BASE_DIR, "tfx_addons", "version.py")) as f: + lines = f.readlines() + +with open(os.path.join(BASE_DIR, "tfx_addons", "version.py"), "w") as f: + for l in lines: + if l.startswith("_MINOR_VERSION"): + next_minor = int(minor) + 1 + f.write(f'_MINOR_VERSION = "{next_minor}"\n') + else: + f.write(l) + +print(".".join([major, str(next_minor)])) diff --git a/RELEASE.md b/RELEASE.md index c867b0b5..2e23c2c1 100644 --- a/RELEASE.md +++ b/RELEASE.md @@ -4,10 +4,22 @@ TFX Addons follows [Semantic Versioning 2.0](https://semver.org/) strategy. * See the [Release Notes](https://github.com/tensorflow/tfx-addons/releases) for current and past releases. +## Minor automatic release from main + +1. Trigger [Create Minor Release](https://github.com/tensorflow/tfx-addons/actions/workflows/minor_release.yml] workflow and ensure it runs to completion. +2. Find created [draft release](https://github.com/tensorflow/tfx-addons/releases). + * Add updates for new features, enhancements, bug fixes + * Add contributors using `git shortlog ..HEAD -s` +3. Publish release. + * Check PyPI to ensure release candidate has been released. + * Send email to mailing list for vote. +4. Find the minor version PR created above and merge it. + + ## Major/Minor releases 1. Create new `rX.Y` branch on https://github.com/tensorflow/tfx-addons from `main`. -2. Create new PR with updates to `version.py` against `rX.Y` branch. +2. Update `version.py` in `rX.Y` branch. * Set the correct version and suffix in [version.py](https://github.com/tensorflow/tfx-addons/blob/main/tfx_addons/version.py). * Ensure the proper minimum and maximum tested versions of TFX are set in [version.py](https://github.com/tensorflow/tfx-addons/blob/main/tfx_addons/version.py). * Ensure proper supported python libraries are set in [version.py](https://github.com/tensorflow/tfx-addons/blob/main/tfx_addons/version.py).