Skip to content

Commit

Permalink
chore: support additional version postfixes (#5096)
Browse files Browse the repository at this point in the history
* chore: support additional version postfixes

* chore: change default version

* chore: add comment
  • Loading branch information
PeterSchafer committed Mar 8, 2024
1 parent 2fa7192 commit 14f31dd
Show file tree
Hide file tree
Showing 2 changed files with 54 additions and 2 deletions.
36 changes: 36 additions & 0 deletions release-scripts/determine-release-channel.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,36 @@
#!/usr/bin/env bash
set -euo pipefail

# This script determines the appropriate release channel for a project based on
# the current Git branch. The script should always return a string value that
# matches one of the supported channels.
#
# The following release channels are supported:
# - stable
# - rc
# - preview
# - dev


# enable support for stable, preview and other release channels
ENABLE_STABLE_CHANNELS=false

CURRENT_BRANCH="$(git rev-parse --abbrev-ref HEAD)"
if [ $ENABLE_STABLE_CHANNELS == true ]; then # support for stable, preview and release candidate
if [ "$CURRENT_BRANCH" == "main" ]; then
echo "preview"
elif [ "$CURRENT_BRANCH" == "release-candidate" ]; then
echo "rc"
elif [[ "$CURRENT_BRANCH" == release/* ]]; then
echo "stable"
else
echo "dev"
fi
else # legacy release channels
if [ "$CURRENT_BRANCH" == "main" ]; then
echo "stable"
else
echo "dev"
fi
fi

20 changes: 18 additions & 2 deletions release-scripts/next-version.sh
Original file line number Diff line number Diff line change
Expand Up @@ -6,11 +6,27 @@ set -euo pipefail
RELEASE_BRANCH="main"
NEXT_VERSION="$(convco version --bump)"
CURRENT_TAG="$(git describe --tags `git rev-list --tags --max-count=1`)"
RELEASE_CHANNEL="$($(dirname "$0")/determine-release-channel.sh)"

if [ "${CIRCLE_BRANCH:-}" != "${RELEASE_BRANCH}" ]; then
NEXT_VERSION="${NEXT_VERSION}-dev.$(git rev-parse HEAD)"
valid_version_postfixes=("preview" "rc")
postfix="-dev.$(git rev-parse HEAD)"

if [ "$RELEASE_CHANNEL" != "" ]; then
# Check if the input string is in the list of valid strings
for valid_str in "${valid_version_postfixes[@]}"; do
if [ "$RELEASE_CHANNEL" == "$valid_str" ]; then
postfix="-$RELEASE_CHANNEL"
break
fi
done
fi

if [ "$RELEASE_CHANNEL" == "stable" ]; then
postfix=""
fi

NEXT_VERSION="${NEXT_VERSION}${postfix}"

echo "Current version: ${CURRENT_TAG/v/}" 1>&2
echo "Next version: ${NEXT_VERSION}" 1>&2

Expand Down

0 comments on commit 14f31dd

Please sign in to comment.