build-tuic.yml 2.7 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182
  1. name: Build TUIC
  2. on:
  3. # push:
  4. # branches: [ master ]
  5. # paths:
  6. # - 'tuic/**'
  7. # - '.github/workflows/build-tuic.yml'
  8. # pull_request:
  9. # branches: [ master ]
  10. # UTC +8
  11. # schedule:
  12. # - cron: "0 20 * * *"
  13. workflow_dispatch:
  14. jobs:
  15. build-tuic:
  16. runs-on: ubuntu-latest
  17. steps:
  18. - name: Set Variables
  19. run: |
  20. echo "XRAYR_PRE_VERSION=$(curl -fsSL https://api.github.com/repos/EAimTY/tuic/tags | grep '"name":' | head -n 1 | awk -F ":" '{print $2}' | sed 's/\"//g;s/v//g;s/,//g;s/ //g')" >> $GITHUB_ENV
  21. echo "XRAYR_VERSION=$(curl -fsSL https://api.github.com/repos/EAimTY/tuic/releases/latest | grep '"tag_name":' | head -n 1 | awk -F ":" '{print $2}' | sed 's/\"//g;s/v//g;s/,//g;s/ //g')" >> $GITHUB_ENV
  22. shell: bash
  23. - name: Check Out Repo
  24. uses: actions/checkout@v3
  25. - name: Set up Docker Buildx
  26. uses: docker/setup-buildx-action@v2
  27. id: buildx
  28. - name: Cache Docker layers
  29. uses: actions/cache@v3
  30. with:
  31. path: /tmp/.buildx-cache
  32. key: ${{ runner.os }}-buildx-${{ github.sha }}
  33. restore-keys: |
  34. ${{ runner.os }}-buildx-
  35. - name: Login to Docker Hub
  36. uses: docker/login-action@v2
  37. with:
  38. username: ${{ secrets.DOCKER_HUB_USERNAME }}
  39. password: ${{ secrets.DOCKER_HUB_ACCESS_TOKEN }}
  40. # - name: Build and push Docker images
  41. # uses: docker/build-push-action@v3
  42. # id: docker_build_tuic_core_pre
  43. # with:
  44. # context: ./tuic
  45. # file: ./tuic/Dockerfile
  46. # push: true
  47. # tags: |
  48. # ${{ secrets.DOCKER_HUB_USERNAME }}/tuic:${{ env.XRAYR_PRE_VERSION }}
  49. # builder: ${{ steps.buildx.outputs.name }}
  50. # cache-from: type=local,src=/tmp/.buildx-cache
  51. # cache-to: type=local,dest=/tmp/.buildx-cache-new
  52. - name: Build and push Docker images
  53. uses: docker/build-push-action@v3
  54. id: docker_build_tuic_core
  55. with:
  56. context: ./tuic
  57. file: ./tuic/Dockerfile.latest
  58. push: true
  59. tags: |
  60. ${{ secrets.DOCKER_HUB_USERNAME }}/tuic:latest
  61. ${{ secrets.DOCKER_HUB_USERNAME }}/tuic:${{ env.XRAYR_VERSION }}
  62. builder: ${{ steps.buildx.outputs.name }}
  63. cache-from: type=local,src=/tmp/.buildx-cache
  64. cache-to: type=local,dest=/tmp/.buildx-cache-new
  65. - name: Move cache
  66. run: |
  67. rm -rf /tmp/.buildx-cache
  68. mv /tmp/.buildx-cache-new /tmp/.buildx-cache
  69. - name: Image digest
  70. run: |
  71. echo ${{ steps.docker_build_tuic_core_pre.outputs.digest }}
  72. echo ${{ steps.docker_build_tuic_core.outputs.digest }}