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

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869
  1. name: build-and-push-release-image
  2. on:
  3. push:
  4. branches:
  5. # Run on pushing branches like `release/1.0.0`
  6. - "release/*.*.*"
  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@v2
  17. - name: Extract build args
  18. # Extract version from branch name
  19. # Example: branch name `release/1.0.0` sets up env.VERSION=1.0.0
  20. run: |
  21. echo "VERSION=${GITHUB_REF_NAME#release/}" >> $GITHUB_ENV
  22. - name: Login to Docker Hub
  23. uses: docker/login-action@v2
  24. with:
  25. username: neosmemo
  26. password: ${{ secrets.DOCKER_NEOSMEMO_TOKEN }}
  27. - name: Login to GitHub Container Registry
  28. uses: docker/login-action@v2
  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@v2
  36. with:
  37. install: true
  38. version: v0.9.1
  39. - name: Docker meta
  40. id: meta
  41. uses: docker/metadata-action@v4
  42. with:
  43. images: |
  44. neosmemo/memos
  45. ghcr.io/usememos/memos
  46. tags: |
  47. type=raw,value=latest
  48. type=semver,pattern={{version}},value=${{ env.VERSION }}
  49. type=semver,pattern={{major}}.{{minor}},value=${{ env.VERSION }}
  50. type=semver,pattern={{major}},value=${{ env.VERSION }}
  51. - name: Build and Push
  52. id: docker_build
  53. uses: docker/build-push-action@v3
  54. with:
  55. context: ./
  56. file: ./Dockerfile
  57. platforms: linux/amd64,linux/arm64
  58. push: true
  59. tags: ${{ steps.meta.outputs.tags }}
  60. labels: ${{ steps.meta.outputs.labels }}