2
0

release.yml 2.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475
  1. name: "Release"
  2. on:
  3. push:
  4. tags:
  5. - v3*
  6. jobs:
  7. k8s:
  8. name: actions-release-k8s
  9. runs-on: ubuntu-20.04
  10. steps:
  11. - name: Checkout repository
  12. uses: actions/checkout@v2
  13. # The github.ref is, for example, refs/tags/v3.0.145 or refs/tags/v3.0-r8
  14. # Generate variables like:
  15. # SRS_TAG=v3.0.145
  16. # SRS_TAG=v3.0-r8
  17. # SRS_MAJOR=3
  18. # @see https://docs.github.com/en/actions/reference/workflow-commands-for-github-actions#setting-an-environment-variable
  19. - name: Generate varaiables
  20. shell: bash
  21. run: |
  22. SRS_TAG=$(echo ${{ github.ref }}| awk -F '/' '{print $3}')
  23. echo "SRS_TAG=$SRS_TAG" >> $GITHUB_ENV
  24. SRS_MAJOR=$(echo $SRS_TAG| cut -c 2)
  25. echo "SRS_MAJOR=$SRS_MAJOR" >> $GITHUB_ENV
  26. - name: Build SRS
  27. shell: bash
  28. run: |
  29. echo "Release ossrs/srs:$SRS_TAG"
  30. docker build --tag ossrs/srs:$SRS_TAG -f trunk/Dockerfile .
  31. - name: Login docker hub
  32. uses: docker/login-action@v1
  33. with:
  34. username: "${{ secrets.DOCKER_USERNAME }}"
  35. password: "${{ secrets.DOCKER_PASSWORD }}"
  36. - name: Push to docker hub
  37. shell: bash
  38. run: |
  39. docker push ossrs/srs:$SRS_TAG
  40. docker tag ossrs/srs:$SRS_TAG ossrs/srs:$SRS_MAJOR
  41. docker push ossrs/srs:$SRS_MAJOR
  42. - name: Login Aliyun docker hub
  43. uses: aliyun/acr-login@v1
  44. with:
  45. login-server: https://registry.cn-hangzhou.aliyuncs.com
  46. username: "${{ secrets.ACR_USERNAME }}"
  47. password: "${{ secrets.ACR_PASSWORD }}"
  48. - name: Push to Aliyun docker hub
  49. shell: bash
  50. run: |
  51. docker tag ossrs/srs:$SRS_TAG registry.cn-hangzhou.aliyuncs.com/ossrs/srs:$SRS_TAG
  52. docker push registry.cn-hangzhou.aliyuncs.com/ossrs/srs:$SRS_TAG
  53. docker tag ossrs/srs:$SRS_TAG registry.cn-hangzhou.aliyuncs.com/ossrs/srs:$SRS_MAJOR
  54. docker push registry.cn-hangzhou.aliyuncs.com/ossrs/srs:$SRS_MAJOR
  55. - name: Setup KUBCONFIG for Aliyun ACK
  56. shell: bash
  57. run: |-
  58. KUBECONFIG=$RUNNER_TEMP/kubeconfig_$(date +%s)
  59. echo "${{ secrets.KUBCONFIG }}" > $KUBECONFIG
  60. echo "KUBECONFIG=$KUBECONFIG" >> $GITHUB_ENV
  61. - name: Release SRS 3.0 to Aliyun ACK
  62. shell: bash
  63. if: ${{ startsWith(github.ref, 'refs/tags/v3') }}
  64. run: |-
  65. kubectl set image deploy/srs3-deploy srs=registry.cn-hangzhou.aliyuncs.com/ossrs/srs:$SRS_TAG
  66. kubectl describe deploy/srs3-deploy