|
| 1 | +# |
| 2 | +# Copyright (c) 2023 Project CHIP Authors |
| 3 | +# |
| 4 | +# Licensed under the Apache License, Version 2.0 (the "License"); |
| 5 | +# you may not use this file except in compliance with the License. |
| 6 | +# You may obtain a copy of the License at |
| 7 | +# |
| 8 | +# http://www.apache.org/licenses/LICENSE-2.0 |
| 9 | +# |
| 10 | +# Unless required by applicable law or agreed to in writing, software |
| 11 | +# distributed under the License is distributed on an "AS IS" BASIS, |
| 12 | +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. |
| 13 | +# See the License for the specific language governing permissions and |
| 14 | +# limitations under the License. |
| 15 | +# |
| 16 | + |
| 17 | +#!/bin/bash |
| 18 | + |
| 19 | +CURRENT_SPEC_VERSION=$(cat SPECIFICATION_VERSION) |
| 20 | + |
| 21 | +# Pulls the most recent release from gihub, matching the spec version on the current tree |
| 22 | +CURRENT_RELEASE=$(gh release list --exclude-pre-releases | grep -Fi "$CURRENT_SPEC_VERSION" | awk '{print $1}' | head -n1) |
| 23 | + |
| 24 | +if [ -z "$CURRENT_RELEASE" ]; then |
| 25 | + # If there are no releases, this is our first one for this Spec version |
| 26 | + SDK_RELEASE_REVISIONS=0 |
| 27 | + echo "No revision found for current release" |
| 28 | +else |
| 29 | + # Otherwise pull the SDK revision (4th item) from the release |
| 30 | + SDK_RELEASE_REVISIONS="$(echo "$CURRENT_RELEASE" | cut -d'.' -f4)" |
| 31 | +fi |
| 32 | + |
| 33 | +if [ ! -z "$CURRENT_RELEASE" ]; then |
| 34 | + # If there is current release, construct a string like 1.2.0.0 based o the current one |
| 35 | + CURRENT_RELEASE="v$CURRENT_SPEC_VERSION.$SDK_RELEASE_REVISIONS" |
| 36 | + # Then revise the SDK release to be +1 |
| 37 | + SDK_RELEASE_REVISIONS=$(($SDK_RELEASE_REVISIONS + 1)) |
| 38 | +fi |
| 39 | + |
| 40 | +# Construct a final tag, eg: 1.2.0.5 (MAJOR.MINOR.PATCH.SDK_REVISION) |
| 41 | +NEW_RELEASE_TAG="v$CURRENT_SPEC_VERSION.$SDK_RELEASE_REVISIONS" |
| 42 | + |
| 43 | +ADDITIONAL_ARGS="" |
| 44 | + |
| 45 | +# Look for any prerelease information in the spec version (eg: 1.3.0-sve), and target the prerelease channel |
| 46 | +case "$NEW_RELEASE_TAG" in |
| 47 | + *alpha* | *beta* | *prerelease* | *testevent* | *te* | *sve*) |
| 48 | + ADDITIONAL_ARGS="$ADDITIONAL_ARGS --prerelease" |
| 49 | + ;; |
| 50 | +esac |
| 51 | + |
| 52 | +echo "Current release: $CURRENT_RELEASE" |
| 53 | +echo "SDK release revisions: $SDK_RELEASE_REVISIONS" |
| 54 | +echo "New release: $NEW_RELEASE_TAG" |
| 55 | +echo "Additional arguments: $ADDITIONAL_ARGS" |
| 56 | + |
| 57 | +gh release create "$ADDITIONAL_ARGS" --notes-start-tag "$CURRENT_RELEASE" "$NEW_RELEASE_TAG" "$@" |
0 commit comments