From f5edd4fcf43602f57d7a3e2e31f6a48cf013f180 Mon Sep 17 00:00:00 2001 From: Aaron <29749331+aarnphm@users.noreply.github.com> Date: Thu, 8 Jun 2023 17:52:39 -0400 Subject: [PATCH] feat(script): add easy script to release Signed-off-by: Aaron <29749331+aarnphm@users.noreply.github.com> --- .github/CODEOWNERS | 2 +- .pre-commit-config.yaml | 5 +++ DEVELOPMENT.md | 12 ++----- tools/assert-license-headers | 3 +- tools/run-release-action | 65 ++++++++++++++++++++++++++++++++++++ 5 files changed, 76 insertions(+), 11 deletions(-) create mode 100755 tools/run-release-action diff --git a/.github/CODEOWNERS b/.github/CODEOWNERS index aa8a63dc..5eb6637f 100644 --- a/.github/CODEOWNERS +++ b/.github/CODEOWNERS @@ -1 +1 @@ -* @aarnphm @parano @ssheng +* @aarnphm @parano @ssheng diff --git a/.pre-commit-config.yaml b/.pre-commit-config.yaml index 1bdc73cf..598781f4 100644 --- a/.pre-commit-config.yaml +++ b/.pre-commit-config.yaml @@ -33,6 +33,11 @@ repos: - 'markdown' - 'toml' - 'json' + exclude: | + (?x)^( + tools/.*| + .github/.* + )$ - repo: local hooks: - id: check-models-table-update diff --git a/DEVELOPMENT.md b/DEVELOPMENT.md index 3e0ee070..49b88a51 100644 --- a/DEVELOPMENT.md +++ b/DEVELOPMENT.md @@ -137,17 +137,11 @@ hatch run test ## Releasing a New Version -To release a new version, use `gh workflow run`: +To release a new version, use `./tools/run-release-action`. It requires `gh`, +`jq` and `hatch`: ```bash -gh workflow run create-releases.yml -``` - -After the release CI finishes, then run the following: - -```bash -git pull --rebase -gh workflow run release-notes.yml --ref "v$(hatch version)" +./tools/run-release-action ``` > Note that currently this workflow can only be run by the BentoML team. diff --git a/tools/assert-license-headers b/tools/assert-license-headers index 37295869..6c9aa132 100755 --- a/tools/assert-license-headers +++ b/tools/assert-license-headers @@ -1,7 +1,8 @@ #!/bin/bash # License header pattern -LICENSE_HEADER=$(cat << 'EOF' +LICENSE_HEADER=$( + cat << 'EOF' # Copyright [0-9]{4} BentoML Team. All rights reserved. EOF ) diff --git a/tools/run-release-action b/tools/run-release-action new file mode 100755 index 00000000..326d6e18 --- /dev/null +++ b/tools/run-release-action @@ -0,0 +1,65 @@ +#!/usr/bin/env bash + +set -o errexit -o nounset -o pipefail + +if ! command -v gh @ >&1 > /dev/null; then + echo "ERROR: gh not installed. Aborting..." + exit 1 +fi + +if ! command -v jq @ >&1 > /dev/null; then + echo "ERROR: jq not installed. Aborting..." + exit 1 +fi + +if ! command -v hatch @ >&1 > /dev/null; then + echo "ERROR: hatch not installed. Aborting..." + exit 1 +fi + +echo "Running release actions (create-releases.yml)..." +gh workflow run create-releases.yml --repo bentoml/openllm + +echo "Getting 'create-releases.yml' workflow id..." +WORKFLOW_ID=$(gh run list -w release --repo bentoml/openllm -L 1 --json databaseId | jq '.[]| .databaseId') + +echo "Waiting for workflow create-releases.yml to complete..." +while true; do + status=$(gh run view "$WORKFLOW_ID" --json status --jq '.status') + if [[ $status == "completed" ]]; then + break + fi + sleep 10 +done + +# Set the maximum timeout (in seconds) +timeout=600 + +echo "Generating release notes (release-notes.yml)..." +git pull --rebase +gh workflow run release-notes.yml --repo bentoml/openllm --ref "v$(hatch version)" + +echo "Getting 'release-notes.yml' workflow id..." +WORKFLOW_ID=$(gh run list -w release-notes --repo bentoml/openllm -L 1 --json databaseId | jq '.[]| .databaseId') +start_time=$(date +%s) +while true; do + status=$(gh run view "$WORKFLOW_ID" --json status --jq '.status') + if [[ $status == "completed" ]]; then + break + fi + current_time=$(date +%s) + elapsed_time=$((current_time - start_time)) + if [[ $elapsed_time -gt $timeout ]]; then + echo "Timeout reached. Cancelling the check." + break + fi + sleep 10 +done + +# Run the second workflow (b.yml) if the first workflow completed +if [[ $status != "completed" ]]; then + echo "Failed to generate release notes. Check the logs at GitHub Actions." + exit 1 +else + exit 0 +fi