Skip to content

Commit

Permalink
Add srs-server release script.
Browse files Browse the repository at this point in the history
  • Loading branch information
winlinvip committed Oct 27, 2023
1 parent 64c2008 commit a1f217d
Show file tree
Hide file tree
Showing 3 changed files with 112 additions and 43 deletions.
15 changes: 15 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -107,3 +107,18 @@ helm repo add srs http://localhost:3000/stable
```

Now, you can utilize SRS HELM. For more information, refer to the [Usage](#usage) section.

## Release Chart Release

To release chart new release, for example, release srs-server v1.0.6, firstly create new chart resource
file by following command:

```bash
./auto/srs-server.sh -target v1.0.6
```

Then, release the chart web server image and refresh official website by:

```bash
./auto/pub.sh
```
49 changes: 6 additions & 43 deletions auto/pub.sh
Original file line number Diff line number Diff line change
@@ -1,18 +1,18 @@
#!/bin/bash

REALPATH=$(realpath $0)
WORK_DIR=$(cd $(dirname $REALPATH)/.. && pwd)
echo "Run pub at $WORK_DIR from $0"
cd $WORK_DIR
# Execute by: bash xxx.sh or bash zzz/yyy/xxx.sh or ./xxx.sh or ./zzz/yyy/xxx.sh source xxx.sh
REALPATH=$(realpath ${BASH_SOURCE[0]})
SCRIPT_DIR=$(cd $(dirname ${REALPATH}) && pwd)
WORK_DIR=$(cd $(dirname ${REALPATH})/.. && pwd)
echo "BASH_SOURCE=${BASH_SOURCE}, REALPATH=${REALPATH}, SCRIPT_DIR=${SCRIPT_DIR}, WORK_DIR=${WORK_DIR}"
cd ${WORK_DIR}

help=false
no_sync=false
refresh=false

while [[ "$#" -gt 0 ]]; do
case $1 in
-h|--help) help=true; shift ;;
-no-sync|--no-sync) no_sync=true; shift ;;
-refresh|--refresh) refresh=true; shift ;;
*) echo "Unknown parameter passed: $1"; exit 1 ;;
esac
Expand All @@ -22,7 +22,6 @@ if [ "$help" = true ]; then
echo "Usage: $0 [OPTIONS]"
echo "Options:"
echo " -h, --help Show this help message and exit"
echo " -no-sync, --no-sync Disable sync option. Default: false"
echo " -refresh, --refresh Refresh current tag. Default: false"
exit 0
fi
Expand All @@ -40,48 +39,12 @@ REPO_TAG="v1.0.$REPO_NEXT"
REPO_VERSION="1.0.$REPO_NEXT"
echo "repo: Last is $REPO_RELEASE $REPO_REVISION, release as NEXT:$REPO_NEXT TAG:$REPO_TAG VERION:$REPO_VERSION"

SRS_SERVER_PREFIX=srs-server
SRS_SERVER_RELEASE=$(git describe --tags --abbrev=0 --match ${SRS_SERVER_PREFIX}-v* 2>/dev/null || echo "${SRS_SERVER_PREFIX}-v1.0.-1")
SRS_SERVER_REVISION=$(echo $SRS_SERVER_RELEASE|awk -F . '{print $3}')
let SRS_SERVER_NEXT=$SRS_SERVER_REVISION+1
if [[ $refresh == true && $SRS_SERVER_REVISION != "-1" ]]; then
let SRS_SERVER_NEXT=$SRS_SERVER_REVISION
fi
SRS_SERVER_TAG="${SRS_SERVER_PREFIX}-v1.0.$SRS_SERVER_NEXT"
SRS_SERVER_VERSION="1.0.$SRS_SERVER_NEXT"
echo "$SRS_SERVER_PREFIX: Last is $SRS_SERVER_RELEASE $SRS_SERVER_REVISION, release as NEXT:$SRS_SERVER_NEXT TAG:$SRS_SERVER_TAG VERSION:$SRS_SERVER_VERSION"

if [[ $(grep -q "version: $SRS_SERVER_VERSION" $SRS_SERVER_PREFIX/Chart.yaml || echo 'no') == no ]]; then
echo "Failed: Please update Chart.yaml to version: $SRS_SERVER_VERSION"
exit 1
fi
echo "Check $SRS_SERVER_PREFIX/Chart.yaml OK, version: $SRS_SERVER_VERSION"

CHARTS_HOME=stable
if [[ ! -f $CHARTS_HOME/$SRS_SERVER_PREFIX-$SRS_SERVER_VERSION.tgz ]]; then
echo "Failed: No package at $CHARTS_HOME/$SRS_SERVER_PREFIX-$SRS_SERVER_VERSION.tgz"
echo "Please run:"
echo " helm package $SRS_SERVER_PREFIX -d $CHARTS_HOME && \\"
echo " helm repo index $CHARTS_HOME"
exit 1
fi

git status |grep -q 'nothing to commit'
if [[ $? -ne 0 ]]; then
echo "Failed: Please commit before release";
exit 1
fi

if [[ $no_sync == false ]]; then
git fetch origin
if [[ $(git status |grep -q 'Your branch is up to date' || echo 'no') == no ]]; then
git status
echo "Failed: Please sync before release";
exit 1
fi
echo "Sync OK"
fi

git tag -d $REPO_TAG 2>/dev/null; git push origin :$REPO_TAG 2>/dev/null
git tag -d $SRS_SERVER_TAG 2>/dev/null; git push origin :$SRS_SERVER_TAG 2>/dev/null
echo "Delete tag OK: $REPO_TAG $SRS_SERVER_TAG"
Expand Down
91 changes: 91 additions & 0 deletions auto/srs-server.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,91 @@
#!/bin/bash

# Execute by: bash xxx.sh or bash zzz/yyy/xxx.sh or ./xxx.sh or ./zzz/yyy/xxx.sh source xxx.sh
REALPATH=$(realpath ${BASH_SOURCE[0]})
SCRIPT_DIR=$(cd $(dirname ${REALPATH}) && pwd)
WORK_DIR=$(cd $(dirname ${REALPATH})/.. && pwd)
echo "BASH_SOURCE=${BASH_SOURCE}, REALPATH=${REALPATH}, SCRIPT_DIR=${SCRIPT_DIR}, WORK_DIR=${WORK_DIR}"
cd ${WORK_DIR}

help=false
refresh=false
target=

while [[ "$#" -gt 0 ]]; do
case $1 in
-h|--help) help=true; shift ;;
-refresh|--refresh) refresh=true; shift ;;
-target|--target) target="$2"; shift 2;;
*) echo "Unknown parameter passed: $1"; exit 1 ;;
esac
done

if [ "$help" = true ]; then
echo "Usage: $0 [OPTIONS]"
echo "Options:"
echo " -h, --help Show this help message and exit"
echo " -refresh, --refresh Refresh current tag. Default: false"
echo " -target, --target The target version to release, for example, v5.7.28"
exit 0
fi

if [[ ! -z $target ]]; then
RELEASE=$target
refresh=yes
else
RELEASE=$(git describe --tags --abbrev=0 --match srs-server-v* |sed 's/srs-server-//g')
fi
if [[ $? -ne 0 ]]; then echo "Release failed"; exit 1; fi

REVISION=$(echo $RELEASE |awk -F . '{print $3}')
if [[ $? -ne 0 ]]; then echo "Release failed"; exit 1; fi

let NEXT=$REVISION+1
if [[ $refresh == yes ]]; then
let NEXT=$REVISION
fi
VERSION=$(echo $RELEASE |sed 's/v//g')
TAG=$RELEASE
echo "RELEASE=$RELEASE, VERSION=$VERSION, TAG=$TAG, REVISION=$REVISION, NEXT=$NEXT"

if [[ $(grep -q "version: $VERSION" srs-server/Chart.yaml || echo no) == no ]]; then
VERSION0="sed -i '' 's/^version:.*/version: $VERSION/g' srs-server/Chart.yaml"
fi
if [[ ! -z $VERSION0 ]]; then
echo "Please update version to $VERSION"
if [[ ! -z $VERSION0 ]]; then echo " $VERSION0 &&"; fi
echo " echo ok"
exit 1
fi

if [[ ! -f stable/srs-server-$VERSION.tgz ]]; then
echo "Failed: No package at stable/srs-server-$VERSION.tgz"
echo "Please run:"
echo " helm package srs-server -d stable && \\"
echo " helm repo index stable"
exit 1
fi

git st |grep -q 'nothing to commit'
if [[ $? -ne 0 ]]; then
echo "Failed: Please commit before release";
exit 1
fi

git fetch origin
if [[ $(git status |grep -q 'Your branch is up to date' || echo 'no') == no ]]; then
git status
echo "Failed: Please sync before release";
exit 1
fi
echo "Sync OK"

git tag -d $TAG 2>/dev/null; git push origin :$TAG 2>/dev/null
echo "Delete tag OK: $TAG"

git tag $TAG && git push origin $TAG
echo "Publish OK: $TAG"

echo -e "\n\n"
echo "Publication ok, please visit"
echo " Please test it after https://github.com/ossrs/srs-helm/actions/workflows/docker.yml done"

0 comments on commit a1f217d

Please sign in to comment.