release.yml 2.3 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788
  1. name: release
  2. on:
  3. push:
  4. tags:
  5. - v*
  6. jobs:
  7. build:
  8. runs-on: ubuntu-latest
  9. strategy:
  10. matrix:
  11. go_version:
  12. - 1.19
  13. steps:
  14. - uses: actions/checkout@v3
  15. with:
  16. fetch-depth: 0
  17. - uses: actions/setup-go@v3
  18. with:
  19. go-version: ${{ matrix.go_version }}
  20. # Cache go build cache, used to speedup go test
  21. - name: Setup Golang caches
  22. uses: actions/cache@v3
  23. with:
  24. path: |
  25. /go/pkg/.cache/go-build
  26. /go/pkg/mod
  27. key: ${{ runner.os }}-golang-${{ hashFiles('**/go.sum') }}
  28. restore-keys: |
  29. ${{ runner.os }}-golang-
  30. - name: GoReleaser
  31. uses: goreleaser/goreleaser-action@v3
  32. with:
  33. version: latest
  34. args: release --rm-dist
  35. env:
  36. GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
  37. docker-release:
  38. runs-on: ubuntu-latest
  39. strategy:
  40. matrix:
  41. target:
  42. - Dockerfile: build/Dockerfile
  43. steps:
  44. - uses: actions/checkout@v3
  45. - name: Prepare
  46. id: prepare
  47. run: |
  48. TAG=${GITHUB_REF#refs/tags/}
  49. DATE=$(date +'%Y-%m-%d_%H-%M-%S')
  50. echo ::set-output name=full_tag_name::${TAG}
  51. echo ::set-output name=full_date_tag::${DATE}
  52. echo ::set-output name=latest_tag::latest
  53. - name: Set up QEMU
  54. uses: docker/setup-qemu-action@v1
  55. - name: Set up Docker Buildx
  56. id: buildx
  57. uses: docker/setup-buildx-action@master
  58. - name: Login to Docker Hub
  59. uses: docker/login-action@v1
  60. with:
  61. username: ${{ secrets.DOCKER_USER }}
  62. password: ${{ secrets.DOCKER_SECRET }}
  63. - name: Build and publish ${{ matrix.target.Dockerfile }}
  64. uses: docker/build-push-action@v2
  65. with:
  66. context: .
  67. push: true
  68. builder: ${{ steps.buildx.outputs.name }}
  69. file: ${{ matrix.target.Dockerfile }}
  70. platforms: linux/amd64,linux/arm64,linux/arm
  71. cache-from: type=gha,scope=${{ github.workflow }}
  72. cache-to: type=gha,mode=max,scope=${{ github.workflow }}
  73. tags: |
  74. zc2638/ylgy:${{ steps.prepare.outputs.full_tag_name }}
  75. zc2638/ylgy:${{ steps.prepare.outputs.full_date_tag }}
  76. zc2638/ylgy:${{ steps.prepare.outputs.latest_tag }}