|
2 | 2 |
|
3 | 3 | REALPATH=$(realpath $0)
|
4 | 4 | WORK_DIR=$(cd $(dirname $REALPATH)/.. && pwd)
|
| 5 | +echo "Run pub at $WORK_DIR from $0" |
5 | 6 | cd $WORK_DIR
|
6 | 7 |
|
7 |
| -# Please update the release version for each major version. |
8 |
| -TAG=publication-v4.6.16 |
9 |
| -echo "Publication TAG=$TAG, WORK_DIR=$WORK_DIR" |
| 8 | +help=false |
| 9 | +refresh=false |
10 | 10 |
|
11 |
| -RELEASE=$(git describe --tags --abbrev=0 --match publication-*) |
12 |
| -if [[ $TAG == $RELEASE ]]; then |
13 |
| - echo "Failed: Release $TAG already published." |
14 |
| - echo "Please update the TAG in $0 then run again."; |
15 |
| - exit 1 |
| 11 | +while [[ "$#" -gt 0 ]]; do |
| 12 | + case $1 in |
| 13 | + -h|--help) help=true; shift ;; |
| 14 | + -refresh|--refresh) refresh=true; shift ;; |
| 15 | + *) echo "Unknown parameter passed: $1"; exit 1 ;; |
| 16 | + esac |
| 17 | +done |
| 18 | + |
| 19 | +if [ "$help" = true ]; then |
| 20 | + echo "Usage: $0 [OPTIONS]" |
| 21 | + echo "Options:" |
| 22 | + echo " -h, --help Show this help message and exit" |
| 23 | + echo " -refresh, --refresh Refresh current tag. Default: false" |
| 24 | + exit 0 |
| 25 | +fi |
| 26 | + |
| 27 | +# We increase version from the publication-v* base. |
| 28 | +RELEASE=$(git describe --tags --abbrev=0 --match publication-v*) && |
| 29 | +REVISION=$(echo $RELEASE|awk -F . '{print $3}') |
| 30 | +if [[ $? -ne 0 ]]; then echo "Release failed"; exit 1; fi |
| 31 | + |
| 32 | +let NEXT=$REVISION+1 |
| 33 | +if [[ $refresh == true ]]; then |
| 34 | + let NEXT=$REVISION |
16 | 35 | fi
|
| 36 | +echo "Last release is $RELEASE, revision is $REVISION, next is $NEXT" |
| 37 | + |
| 38 | +VERSION="4.6.$NEXT" && |
| 39 | +TAG="publication-v$VERSION" && |
| 40 | +echo "publish version $VERSION as tag $TAG" |
| 41 | +if [[ $? -ne 0 ]]; then echo "Release failed"; exit 1; fi |
17 | 42 |
|
18 |
| -VERSION=$(echo $TAG| sed 's/publication-v//g') |
19 |
| -cat scripts/setup-aapanel/info.json |sed "s|\"versions\": .*|\"versions\": \"$VERSION\",|g" > tmp.json && mv tmp.json scripts/setup-aapanel/info.json && |
20 |
| -cat scripts/setup-bt/info.json |sed "s|\"versions\": .*|\"versions\": \"$VERSION\",|g" > tmp.json && mv tmp.json scripts/setup-bt/info.json |
| 43 | +###################################################################### |
| 44 | +if [[ $(grep versions scripts/setup-aapanel/info.json | grep -q $VERSION || echo no) == no ]]; then |
| 45 | + echo "Failed: Please update scripts/setup-aapanel/info.json to $VERSION" |
| 46 | + echo " sed -i '' 's|\"versions\": \".*\"|\"versions\": \"$VERSION\"|g' scripts/setup-aapanel/info.json" |
| 47 | + exit 1 |
| 48 | +fi |
| 49 | +if [[ $(grep versions scripts/setup-bt/info.json | grep -q $VERSION || echo no) == no ]]; then |
| 50 | + echo "Failed: Please update scripts/setup-bt/info.json to $VERSION" |
| 51 | + echo " sed -i '' 's|\"versions\": \".*\"|\"versions\": \"$VERSION\"|g' scripts/setup-bt/info.json" |
| 52 | + exit 1 |
| 53 | +fi |
21 | 54 |
|
22 | 55 | git st |grep -q 'nothing to commit'
|
23 | 56 | if [[ $? -ne 0 ]]; then
|
24 | 57 | echo "Failed: Please commit before release";
|
25 | 58 | exit 1
|
26 | 59 | fi
|
27 | 60 |
|
28 |
| -git tag -d $TAG 2>/dev/null |
29 |
| -git push origin :$TAG 2>/dev/null |
30 |
| -git push gitee :$TAG 2>/dev/null |
31 |
| -git tag $TAG |
32 |
| -git push origin $TAG |
33 |
| -git push gitee $TAG |
| 61 | +git fetch origin |
| 62 | +if [[ $(git status |grep -q 'Your branch is up to date' || echo 'no') == no ]]; then |
| 63 | + git status |
| 64 | + echo "Failed: Please sync before release"; |
| 65 | + exit 1 |
| 66 | +fi |
| 67 | +echo "Sync OK" |
| 68 | + |
| 69 | +git fetch gitee |
| 70 | +if [[ $(git diff origin/main gitee/main |grep -q diff && echo no) == no ]]; then |
| 71 | + git diff origin/main gitee/main |grep diff |
| 72 | + echo "Failed: Please sync gitee before release"; |
| 73 | + exit 1 |
| 74 | +fi |
| 75 | +echo "Sync gitee OK" |
| 76 | + |
| 77 | +###################################################################### |
| 78 | +git tag -d $TAG 2>/dev/null; git push origin :$TAG 2>/dev/null; git push gitee :$TAG 2>/dev/null |
| 79 | +echo "Delete tag OK: $TAG" |
| 80 | + |
| 81 | +git tag $TAG && git push origin $TAG && git push gitee $TAG |
| 82 | +echo "Publish OK: $TAG" |
| 83 | + |
| 84 | +echo -e "\n\n" |
34 | 85 | echo "Publication ok, please visit"
|
35 | 86 | echo " Please test it after https://github.com/ossrs/srs-cloud/actions/workflows/publication.yml done"
|
36 | 87 | echo " Download bt-srs_cloud.zip from https://github.com/ossrs/srs-cloud/releases"
|
|
0 commit comments