From 283ab7f7fe5cccf9fa11b8d15e9198909bac3b8e Mon Sep 17 00:00:00 2001 From: winlin Date: Sun, 14 Nov 2021 15:49:07 +0800 Subject: [PATCH] Auto relese docker --- .github/workflows/release.yml | 51 +++++++++++++++++++++++++++++++++++ .idea/.gitignore | 8 ++++++ .idea/modules.xml | 8 ++++++ .idea/signaling.iml | 9 +++++++ .idea/vcs.xml | 6 +++++ README.md | 2 +- auto/pub.sh | 16 +++++++++++ auto/release.sh | 3 +++ 8 files changed, 102 insertions(+), 1 deletion(-) create mode 100644 .github/workflows/release.yml create mode 100644 .idea/.gitignore create mode 100644 .idea/modules.xml create mode 100644 .idea/signaling.iml create mode 100644 .idea/vcs.xml create mode 100755 auto/pub.sh diff --git a/.github/workflows/release.yml b/.github/workflows/release.yml new file mode 100644 index 0000000..adae532 --- /dev/null +++ b/.github/workflows/release.yml @@ -0,0 +1,51 @@ +name: "Release" + +on: + push: + tags: + - v1* + +jobs: + docker: + name: release-docker + runs-on: ubuntu-20.04 + + steps: + ################################################################ + # Git checkout + - name: Checkout repository + uses: actions/checkout@v2 + + ################################################################ + # Build + # The github.ref is, for example, refs/tags/v1.0.52 + # Generate variables like: + # SRS_TAG=v1.0.52 + # SRS_MAJOR=1 + # @see https://docs.github.com/en/actions/reference/workflow-commands-for-github-actions#setting-an-environment-variable + - name: Generate varaiables + run: | + SRS_TAG=$(echo ${{ github.ref }}| awk -F '/' '{print $3}') + echo "SRS_TAG=$SRS_TAG" >> $GITHUB_ENV + SRS_MAJOR=$(echo $SRS_TAG| cut -c 2) + echo "SRS_MAJOR=$SRS_MAJOR" >> $GITHUB_ENV + # Build SRS image + - name: Build SRS docker image + run: | + echo "Release ossrs/signaling:$SRS_TAG" + docker build --tag ossrs/signaling:$SRS_TAG . + + ################################################################ + # Aliyun ACR + - name: Login Aliyun docker hub + uses: aliyun/acr-login@v1 + with: + login-server: https://registry.cn-hangzhou.aliyuncs.com + username: "${{ secrets.ACR_USERNAME }}" + password: "${{ secrets.ACR_PASSWORD }}" + - name: Push to Aliyun docker hub + run: | + docker tag ossrs/signaling:$SRS_TAG registry.cn-hangzhou.aliyuncs.com/ossrs/signaling:$SRS_TAG + docker tag ossrs/signaling:$SRS_TAG registry.cn-hangzhou.aliyuncs.com/ossrs/signaling:$SRS_MAJOR + docker push --all-tags registry.cn-hangzhou.aliyuncs.com/ossrs/signaling + diff --git a/.idea/.gitignore b/.idea/.gitignore new file mode 100644 index 0000000..73f69e0 --- /dev/null +++ b/.idea/.gitignore @@ -0,0 +1,8 @@ +# Default ignored files +/shelf/ +/workspace.xml +# Datasource local storage ignored files +/dataSources/ +/dataSources.local.xml +# Editor-based HTTP Client requests +/httpRequests/ diff --git a/.idea/modules.xml b/.idea/modules.xml new file mode 100644 index 0000000..61e8404 --- /dev/null +++ b/.idea/modules.xml @@ -0,0 +1,8 @@ + + + + + + + + \ No newline at end of file diff --git a/.idea/signaling.iml b/.idea/signaling.iml new file mode 100644 index 0000000..5e764c4 --- /dev/null +++ b/.idea/signaling.iml @@ -0,0 +1,9 @@ + + + + + + + + + \ No newline at end of file diff --git a/.idea/vcs.xml b/.idea/vcs.xml new file mode 100644 index 0000000..94a25f7 --- /dev/null +++ b/.idea/vcs.xml @@ -0,0 +1,6 @@ + + + + + + \ No newline at end of file diff --git a/README.md b/README.md index b534457..eb14c9a 100644 --- a/README.md +++ b/README.md @@ -18,7 +18,7 @@ docker run --rm --env CANDIDATE=$(ifconfig en0 inet| grep 'inet '|awk '{print $2 Run signaling in docker: ```bash -docker run --rm -p 1989:1989 registry.cn-hangzhou.aliyuncs.com/ossrs/signaling:v1.0.4 +docker run --rm -p 1989:1989 registry.cn-hangzhou.aliyuncs.com/ossrs/signaling:1 ``` > Note: More images and version is [here](https://cr.console.aliyun.com/repository/cn-hangzhou/ossrs/signaling/images). diff --git a/auto/pub.sh b/auto/pub.sh new file mode 100755 index 0000000..c194bd4 --- /dev/null +++ b/auto/pub.sh @@ -0,0 +1,16 @@ +#!/bin/bash + +RELEASE=$(git describe --tags --abbrev=0 --exclude release-*) +REVISION=$(echo $RELEASE|awk -F . '{print $3}') +let NEXT=$REVISION+1 +echo "Last release is $RELEASE, revision is $REVISION, next is $NEXT" + +TAG="v1.0.$NEXT" +echo "publish $TAG" + +git push +git tag -d $TAG 2>/dev/null && git push origin :$TAG +git tag $TAG +git push origin $TAG +echo "publish $TAG ok" +echo " https://github.com/ossrs/signaling/actions" diff --git a/auto/release.sh b/auto/release.sh index c63c9e7..c1aecca 100755 --- a/auto/release.sh +++ b/auto/release.sh @@ -1,5 +1,8 @@ #!/bin/bash +echo "Please use: ./auto/pub.sh" +exit 1; + SRS_GIT=$HOME/git/signaling SRS_TAG=