build-and-push-release-image.yml 1.8 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970
  1. name: build-and-push-release-image
  2. on:
  3. push:
  4. branches:
  5. # Run on pushing branches like 'v1.0.0', 'v0.22.2rc'
  6. - "v*"
  7. jobs:
  8. build-and-push-release-image:
  9. runs-on: ubuntu-latest
  10. permissions:
  11. contents: read
  12. packages: write
  13. steps:
  14. - uses: actions/checkout@v4
  15. - name: Set up QEMU
  16. uses: docker/setup-qemu-action@v3
  17. - name: Extract build args
  18. # Extract version from tag name
  19. # Example: tag name `v1.0.0` sets up env.VERSION=1.0.0
  20. run: |
  21. echo "VERSION=${GITHUB_REF_NAME#v}" >> $GITHUB_ENV
  22. - name: Login to Docker Hub
  23. uses: docker/login-action@v3
  24. with:
  25. username: stevenlgtm
  26. password: ${{ secrets.DOCKER_HUB_TOKEN }}
  27. - name: Login to GitHub Container Registry
  28. uses: docker/login-action@v3
  29. with:
  30. registry: ghcr.io
  31. username: ${{ github.actor }}
  32. password: ${{ github.token }}
  33. - name: Set up Docker Buildx
  34. id: buildx
  35. uses: docker/setup-buildx-action@v3
  36. with:
  37. install: true
  38. version: v0.9.1
  39. - name: Docker meta
  40. id: meta
  41. uses: docker/metadata-action@v5
  42. with:
  43. images: |
  44. neosmemo/memos
  45. ghcr.io/usememos/memos
  46. tags: |
  47. type=raw,value=${{ env.VERSION }}
  48. flavor: |
  49. latest=true
  50. labels: |
  51. org.opencontainers.image.version=${{ env.VERSION }}
  52. - name: Build and Push
  53. id: docker_build
  54. uses: docker/build-push-action@v6
  55. with:
  56. context: ./
  57. file: ./Dockerfile
  58. platforms: linux/amd64,linux/arm64
  59. push: true
  60. tags: ${{ steps.meta.outputs.tags }}
  61. labels: ${{ steps.meta.outputs.labels }}