build-and-push-stable-image.yml 1.9 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071
  1. name: Build and Push Release Image by Tag
  2. on:
  3. push:
  4. tags:
  5. # Match stable versions, such as 'v1.0.0'.
  6. - "v*.*.*"
  7. jobs:
  8. build-and-push-stable-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 number and check if it's an rc version
  19. run: |
  20. echo "VERSION=${GITHUB_REF_NAME#v}" >> $GITHUB_ENV
  21. - name: Login to Docker Hub
  22. uses: docker/login-action@v3
  23. with:
  24. username: stevenlgtm
  25. password: ${{ secrets.DOCKER_HUB_TOKEN }}
  26. - name: Login to GitHub Container Registry
  27. uses: docker/login-action@v3
  28. with:
  29. registry: ghcr.io
  30. username: ${{ github.actor }}
  31. password: ${{ github.token }}
  32. - name: Set up Docker Buildx
  33. id: buildx
  34. uses: docker/setup-buildx-action@v3
  35. with:
  36. install: true
  37. version: v0.9.1
  38. - name: Docker meta
  39. id: meta
  40. uses: docker/metadata-action@v5
  41. with:
  42. images: |
  43. neosmemo/memos
  44. ghcr.io/usememos/memos
  45. tags: |
  46. type=semver,pattern={{version}},value=${{ env.VERSION }}
  47. type=semver,pattern={{major}}.{{minor}},value=${{ env.VERSION }}
  48. type=raw,value=stable
  49. flavor: |
  50. latest=false
  51. labels: |
  52. org.opencontainers.image.version=${{ env.VERSION }}
  53. - name: Build and Push
  54. id: docker_build
  55. uses: docker/build-push-action@v6
  56. with:
  57. context: ./
  58. file: ./Dockerfile
  59. platforms: linux/amd64,linux/arm64
  60. push: true
  61. tags: ${{ steps.meta.outputs.tags }}
  62. labels: ${{ steps.meta.outputs.labels }}