build-docker-image.yml 2.1 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970
  1. name: Build Image
  2. on:
  3. push:
  4. branches:
  5. - main
  6. tags:
  7. - "v*"
  8. jobs:
  9. build:
  10. runs-on: ubuntu-latest-16c64g
  11. steps:
  12. - uses: actions/checkout@v4
  13. - name: Set up Docker Buildx
  14. uses: docker/setup-buildx-action@v3
  15. - name: Get Version
  16. run: |
  17. if [[ $GITHUB_REF == refs/tags/v* ]]; then
  18. version=$(basename ${GITHUB_REF})
  19. else
  20. version=nightly
  21. fi
  22. echo "version=${version}" >> $GITHUB_ENV
  23. echo "Current version: ${version}"
  24. - name: Login to Docker Hub
  25. uses: docker/login-action@v3
  26. with:
  27. username: ${{ secrets.DOCKER_USER }}
  28. password: ${{ secrets.DOCKER_PAT }}
  29. - name: Build and Push Image
  30. uses: docker/build-push-action@v6
  31. with:
  32. context: .
  33. file: dockerfile
  34. platforms: linux/amd64
  35. push: true
  36. tags: |
  37. fishaudio/fish-speech:${{ env.version }}
  38. fishaudio/fish-speech:latest
  39. outputs: type=image,oci-mediatypes=true,compression=zstd,compression-level=3,force-compression=true
  40. cache-from: type=registry,ref=fishaudio/fish-speech:latest
  41. cache-to: type=inline
  42. - name: Build and Push Dev Image
  43. uses: docker/build-push-action@v6
  44. with:
  45. context: .
  46. file: dockerfile.dev
  47. platforms: linux/amd64
  48. push: true
  49. build-args: |
  50. VERSION=${{ env.version }}
  51. BASE_IMAGE=fishaudio/fish-speech:${{ env.version }}
  52. tags: |
  53. fishaudio/fish-speech:${{ env.version }}-dev
  54. fishaudio/fish-speech:latest-dev
  55. outputs: type=image,oci-mediatypes=true,compression=zstd,compression-level=3,force-compression=true
  56. cache-from: type=registry,ref=fishaudio/fish-speech:latest-dev
  57. cache-to: type=inline
  58. - name: Push README to Dockerhub
  59. uses: peter-evans/dockerhub-description@v4
  60. with:
  61. username: ${{ secrets.DOCKER_USER }}
  62. password: ${{ secrets.DOCKER_PAT }}
  63. repository: fishaudio/fish-speech