Skip to content

Commit

Permalink
Refine platform script. v1.0.299
Browse files Browse the repository at this point in the history
  • Loading branch information
winlinvip committed Jul 11, 2023
1 parent 31af260 commit 3acb40f
Show file tree
Hide file tree
Showing 6 changed files with 83 additions and 39 deletions.
2 changes: 1 addition & 1 deletion .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -129,4 +129,4 @@ mgmt/mgmt
platform/platform
mgmt/mgmt.*
srs.id

t.md
6 changes: 3 additions & 3 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -258,7 +258,7 @@ The software we depend on:

The optional environments defined by `mgmt/.env`:

* `CLOUD`: The cloud platform name, DEV for development.
* `CLOUD`: `dev|bt|aapanel|droplet|docker`, The cloud platform name, DEV for development.
* `REGION`: `ap-guangzhou|ap-singapore|sgp1`, The region for upgrade source.
* `SOURCE`: `github|gitee`, The source code for upgrading.
* `REGISTRY`: `docker.io|registry.cn-hangzhou.aliyuncs.com`, The docker registry.
Expand Down Expand Up @@ -302,10 +302,10 @@ Please restart service when `.env` changed.

## Develop All in macOS

Start redis by brew:
Start redis by docker:

```bash
brew services start redis
docker run --name redis -d --rm -it -v $HOME/db/redis:/data -p 6379:6379 redis
```

Start SRS in macOS:
Expand Down
102 changes: 71 additions & 31 deletions auto/mgmt_platform_pub.sh
Original file line number Diff line number Diff line change
Expand Up @@ -5,53 +5,93 @@ WORK_DIR=$(cd $(dirname $REALPATH)/.. && pwd)
echo "Run pub at $WORK_DIR from $0"
cd $WORK_DIR

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

while [[ "$#" -gt 0 ]]; do
case $1 in
-h|--help) help=true; shift ;;
-refresh|--refresh) refresh=true; shift ;;
*) 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"
exit 0
fi

# We increase version from the platform-v* base.
RELEASE=$(git describe --tags --abbrev=0 --match platform-v*) &&
REVISION=$(echo $RELEASE|awk -F . '{print $3}') &&
let NEXT=$REVISION+1 &&
echo "Last release is $RELEASE, revision is $REVISION, next is $NEXT"
REVISION=$(echo $RELEASE|awk -F . '{print $3}')
if [[ $? -ne 0 ]]; then echo "Release failed"; exit 1; fi

######################################################################
let NEXT=$REVISION+1
if [[ $refresh == true && $REVISION != "-1" ]]; then
let NEXT=$REVISION
fi
echo "Last release is $RELEASE, revision is $REVISION, next is $NEXT"

VERSION="1.0.$NEXT" &&
TAG="v$VERSION" &&
echo "publish version $VERSION as tag $TAG"
if [[ $? -ne 0 ]]; then echo "Release failed"; exit 1; fi

cat mgmt/version.go |sed "s|const\ version\ =.*|const version = \"v$VERSION\"|g" > tmp.go && mv tmp.go mgmt/version.go &&
cat platform/version.go |sed "s|const\ version\ =.*|const version = \"v$VERSION\"|g" > tmp.go && mv tmp.go platform/version.go &&
cat releases/version.go |sed "s|const\ latest\ =.*|const latest = \"v$VERSION\"|g" > tmp.go && mv tmp.go releases/version.go &&
git ci -am "Update mgmt version to $TAG"
if [[ $? -ne 0 ]]; then echo "Release failed"; exit 1; fi

######################################################################
# Note that the mgmt should always use v1.2.3 without any prefix, to be compatible with previous upgrade script.
echo -e "\n\n"
git push
git tag -d $TAG 2>/dev/null && (git push origin :$TAG; git push gitee :$TAG)
git tag $TAG; git push origin $TAG
if [[ $(grep -q "const version = \"$TAG\"" mgmt/version.go || echo no) == no ]]; then
echo "Failed: Please update mgmt/version.go to $TAG"
exit 1
fi
if [[ $(grep -q "const version = \"$TAG\"" platform/version.go || echo no) == no ]]; then
echo "Failed: Please update platform/version.go to $TAG"
exit 1
fi
if [[ $(grep -q "const latest = \"$TAG\"" releases/version.go || echo no) == no ]]; then
echo "Failed: Please update releases/version.go to $TAG"
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 fetch gitee
if [[ $(git diff origin/main gitee/main |grep -q diff && echo no) == no ]]; then
git diff origin/main gitee/main |grep -q diff
echo "Failed: Please sync gitee before release";
exit 1
fi
echo "Sync gitee OK"

git remote |grep -q gitee && git push gitee && git push gitee $TAG
git remote |grep -q cloud && git push cloud && git push cloud $TAG
######################################################################
git tag -d $TAG 2>/dev/null; git push origin :$TAG 2>/dev/null; git push gitee :$TAG 2>/dev/null
echo "Delete tag OK: $TAG"

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

######################################################################
echo -e "\n\n"
TAG="platform-v$VERSION"
git tag -d $TAG 2>/dev/null && (git push origin :$TAG; git push gitee :$TAG)
git tag $TAG; git push origin $TAG
PLATFORM_TAG="platform-v$VERSION"

git remote |grep -q gitee && git push gitee && git push gitee $TAG
git remote |grep -q cloud && git push cloud && git push cloud $TAG
git tag -d $PLATFORM_TAG 2>/dev/null; git push origin :$PLATFORM_TAG 2>/dev/null; git push gitee :$PLATFORM_TAG 2>/dev/null
echo "Delete tag OK: $PLATFORM_TAG"

echo "publish $TAG ok"
echo " Please test it after https://github.com/ossrs/srs-cloud/actions/workflows/platform.yml done"
echo " Then release new latest version by: ./auto/releases_pub.sh"
git tag $PLATFORM_TAG && git push origin $PLATFORM_TAG && git push gitee
echo "Publish OK: $PLATFORM_TAG"

echo -e "\n\n"
echo "Publish OK: $TAG $PLATFORM_TAG"
echo " https://github.com/ossrs/srs-cloud/actions/workflows/platform.yml"
2 changes: 1 addition & 1 deletion mgmt/version.go
Original file line number Diff line number Diff line change
Expand Up @@ -6,4 +6,4 @@
package main

// The version for mgmt.
const version = "v1.0.298"
const version = "v1.0.299"
2 changes: 1 addition & 1 deletion platform/version.go
Original file line number Diff line number Diff line change
Expand Up @@ -6,4 +6,4 @@
package main

// The version for platform.
const version = "v1.0.298"
const version = "v1.0.299"
8 changes: 6 additions & 2 deletions releases/version.go
Original file line number Diff line number Diff line change
Expand Up @@ -5,8 +5,12 @@
//
package main

// The latest version of SRS Cloud.
const latest = "v1.0.299"

// The api service version of SRS Cloud.
const api = "v1.0.374"

// We should keep the stable version as 193, because for new architecture, we don't support automatically upgrade, so
// this feature is actually not used, but we should keep a specified version for compatibility.
const stable = "v1.0.193"
const latest = "v1.0.298"
const api = "v1.0.374"

0 comments on commit 3acb40f

Please sign in to comment.