Skip to content

Commit

Permalink
Refine focal script.
Browse files Browse the repository at this point in the history
  • Loading branch information
winlinvip committed Jul 12, 2023
1 parent f17f696 commit 3a09b7e
Show file tree
Hide file tree
Showing 4 changed files with 90 additions and 21 deletions.
1 change: 0 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -393,7 +393,6 @@ Release bugfix:
Release version for BT and aaPanel:

* MUST update the version manually in `auto/bt_aapanel_pub.sh`
* Then run `./auto/bt_aapanel_pub.sh`
* Finally, download [bt-srs_cloud.zip](https://github.com/ossrs/srs-cloud/releases) then submit to [bt.cn](https://www.bt.cn/developer/details.html?id=600801805)

Expand Down
85 changes: 68 additions & 17 deletions auto/bt_aapanel_pub.sh
Original file line number Diff line number Diff line change
Expand Up @@ -2,35 +2,86 @@

REALPATH=$(realpath $0)
WORK_DIR=$(cd $(dirname $REALPATH)/.. && pwd)
echo "Run pub at $WORK_DIR from $0"
cd $WORK_DIR

# Please update the release version for each major version.
TAG=publication-v4.6.16
echo "Publication TAG=$TAG, WORK_DIR=$WORK_DIR"
help=false
refresh=false

RELEASE=$(git describe --tags --abbrev=0 --match publication-*)
if [[ $TAG == $RELEASE ]]; then
echo "Failed: Release $TAG already published."
echo "Please update the TAG in $0 then run again.";
exit 1
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 publication-v* base.
RELEASE=$(git describe --tags --abbrev=0 --match publication-v*) &&
REVISION=$(echo $RELEASE|awk -F . '{print $3}')
if [[ $? -ne 0 ]]; then echo "Release failed"; exit 1; fi

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

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

VERSION=$(echo $TAG| sed 's/publication-v//g')
cat scripts/setup-aapanel/info.json |sed "s|\"versions\": .*|\"versions\": \"$VERSION\",|g" > tmp.json && mv tmp.json scripts/setup-aapanel/info.json &&
cat scripts/setup-bt/info.json |sed "s|\"versions\": .*|\"versions\": \"$VERSION\",|g" > tmp.json && mv tmp.json scripts/setup-bt/info.json
######################################################################
if [[ $(grep versions scripts/setup-aapanel/info.json | grep -q $VERSION || echo no) == no ]]; then
echo "Failed: Please update scripts/setup-aapanel/info.json to $VERSION"
echo " sed -i '' 's|\"versions\": \".*\"|\"versions\": \"$VERSION\"|g' scripts/setup-aapanel/info.json"
exit 1
fi
if [[ $(grep versions scripts/setup-bt/info.json | grep -q $VERSION || echo no) == no ]]; then
echo "Failed: Please update scripts/setup-bt/info.json to $VERSION"
echo " sed -i '' 's|\"versions\": \".*\"|\"versions\": \"$VERSION\"|g' scripts/setup-bt/info.json"
exit 1
fi

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

git tag -d $TAG 2>/dev/null
git push origin :$TAG 2>/dev/null
git push gitee :$TAG 2>/dev/null
git tag $TAG
git push origin $TAG
git push gitee $TAG
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 diff
echo "Failed: Please sync gitee before release";
exit 1
fi
echo "Sync gitee OK"

######################################################################
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"

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

echo -e "\n\n"
echo "Publication ok, please visit"
echo " Please test it after https://github.com/ossrs/srs-cloud/actions/workflows/publication.yml done"
echo " Download bt-srs_cloud.zip from https://github.com/ossrs/srs-cloud/releases"
Expand Down
19 changes: 18 additions & 1 deletion auto/focal_pub.sh
Original file line number Diff line number Diff line change
Expand Up @@ -30,17 +30,34 @@ VERSION="1.0.$NEXT"
TAG="focal-v$VERSION"
echo "publish version $VERSION as tag $TAG"

######################################################################
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 diff
echo "Failed: Please sync gitee before release";
exit 1
fi
echo "Sync gitee OK"

######################################################################
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"

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

echo "publish $TAG ok"
Expand Down
6 changes: 4 additions & 2 deletions auto/mgmt_platform_pub.sh
Original file line number Diff line number Diff line change
Expand Up @@ -43,10 +43,12 @@ if [[ $? -ne 0 ]]; then echo "Release failed"; exit 1; fi
######################################################################
if [[ $(grep -q "const version = \"$TAG\"" mgmt/version.go || echo no) == no ]]; then
echo "Failed: Please update mgmt/version.go to $TAG"
echo " sed -i '' 's|const version = \".*\"|const version = \"$TAG\"|g' mgmt/version.go"
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"
echo " sed -i '' 's|const version = \".*\"|const version = \"$TAG\"|g' platform/version.go"
exit 1
fi

Expand Down Expand Up @@ -76,7 +78,7 @@ echo "Sync gitee OK"
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"

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

######################################################################
Expand All @@ -85,7 +87,7 @@ PLATFORM_TAG="platform-v$VERSION"
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"

git tag $PLATFORM_TAG && git push origin $PLATFORM_TAG && git push gitee
git tag $PLATFORM_TAG && git push origin $PLATFORM_TAG && git push gitee $PLATFORM_TAG
echo "Publish OK: $PLATFORM_TAG"

echo -e "\n\n"
Expand Down

0 comments on commit 3a09b7e

Please sign in to comment.