.goreleaser.yaml 7.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212
  1. version: 2
  2. project_name: sub2api
  3. before:
  4. hooks:
  5. - go mod tidy -C backend
  6. builds:
  7. - id: sub2api
  8. dir: backend
  9. main: ./cmd/server
  10. binary: sub2api
  11. flags:
  12. - -tags=embed
  13. env:
  14. - CGO_ENABLED=0
  15. goos:
  16. - linux
  17. - windows
  18. - darwin
  19. goarch:
  20. - amd64
  21. - arm64
  22. ignore:
  23. - goos: windows
  24. goarch: arm64
  25. ldflags:
  26. - -s -w
  27. - -X main.Commit={{.Commit}}
  28. - -X main.Date={{.Date}}
  29. - -X main.BuildType=release
  30. archives:
  31. - id: default
  32. format: tar.gz
  33. name_template: >-
  34. {{ .ProjectName }}_{{ .Version }}_{{ .Os }}_{{ .Arch }}
  35. format_overrides:
  36. - goos: windows
  37. format: zip
  38. files:
  39. - LICENSE*
  40. - README*
  41. - deploy/*
  42. checksum:
  43. name_template: 'checksums.txt'
  44. algorithm: sha256
  45. changelog:
  46. # 禁用自动 changelog,完全使用 tag 消息
  47. disable: true
  48. # Docker images
  49. dockers:
  50. # DockerHub images (skipped if DOCKERHUB_USERNAME is 'skip')
  51. - id: amd64
  52. goos: linux
  53. goarch: amd64
  54. skip_push: '{{ if eq .Env.DOCKERHUB_USERNAME "skip" }}true{{ else }}false{{ end }}'
  55. image_templates:
  56. - "{{ .Env.DOCKERHUB_USERNAME }}/sub2api:{{ .Version }}-amd64"
  57. dockerfile: Dockerfile.goreleaser
  58. use: buildx
  59. extra_files:
  60. - deploy/docker-entrypoint.sh
  61. - backend/resources
  62. build_flag_templates:
  63. - "--platform=linux/amd64"
  64. - "--label=org.opencontainers.image.version={{ .Version }}"
  65. - "--label=org.opencontainers.image.revision={{ .Commit }}"
  66. - id: arm64
  67. goos: linux
  68. goarch: arm64
  69. skip_push: '{{ if eq .Env.DOCKERHUB_USERNAME "skip" }}true{{ else }}false{{ end }}'
  70. image_templates:
  71. - "{{ .Env.DOCKERHUB_USERNAME }}/sub2api:{{ .Version }}-arm64"
  72. dockerfile: Dockerfile.goreleaser
  73. use: buildx
  74. extra_files:
  75. - deploy/docker-entrypoint.sh
  76. - backend/resources
  77. build_flag_templates:
  78. - "--platform=linux/arm64"
  79. - "--label=org.opencontainers.image.version={{ .Version }}"
  80. - "--label=org.opencontainers.image.revision={{ .Commit }}"
  81. # GHCR images (owner must be lowercase)
  82. - id: ghcr-amd64
  83. goos: linux
  84. goarch: amd64
  85. image_templates:
  86. - "ghcr.io/{{ .Env.GITHUB_REPO_OWNER_LOWER }}/sub2api:{{ .Version }}-amd64"
  87. dockerfile: Dockerfile.goreleaser
  88. use: buildx
  89. extra_files:
  90. - deploy/docker-entrypoint.sh
  91. - backend/resources
  92. build_flag_templates:
  93. - "--platform=linux/amd64"
  94. - "--label=org.opencontainers.image.version={{ .Version }}"
  95. - "--label=org.opencontainers.image.revision={{ .Commit }}"
  96. - "--label=org.opencontainers.image.source=https://github.com/{{ .Env.GITHUB_REPO_OWNER }}/{{ .Env.GITHUB_REPO_NAME }}"
  97. - id: ghcr-arm64
  98. goos: linux
  99. goarch: arm64
  100. image_templates:
  101. - "ghcr.io/{{ .Env.GITHUB_REPO_OWNER_LOWER }}/sub2api:{{ .Version }}-arm64"
  102. dockerfile: Dockerfile.goreleaser
  103. use: buildx
  104. extra_files:
  105. - deploy/docker-entrypoint.sh
  106. - backend/resources
  107. build_flag_templates:
  108. - "--platform=linux/arm64"
  109. - "--label=org.opencontainers.image.version={{ .Version }}"
  110. - "--label=org.opencontainers.image.revision={{ .Commit }}"
  111. - "--label=org.opencontainers.image.source=https://github.com/{{ .Env.GITHUB_REPO_OWNER }}/{{ .Env.GITHUB_REPO_NAME }}"
  112. # Docker manifests for multi-arch support
  113. docker_manifests:
  114. # DockerHub manifests (skipped if DOCKERHUB_USERNAME is 'skip')
  115. - name_template: "{{ .Env.DOCKERHUB_USERNAME }}/sub2api:{{ .Version }}"
  116. skip_push: '{{ if eq .Env.DOCKERHUB_USERNAME "skip" }}true{{ else }}false{{ end }}'
  117. image_templates:
  118. - "{{ .Env.DOCKERHUB_USERNAME }}/sub2api:{{ .Version }}-amd64"
  119. - "{{ .Env.DOCKERHUB_USERNAME }}/sub2api:{{ .Version }}-arm64"
  120. - name_template: "{{ .Env.DOCKERHUB_USERNAME }}/sub2api:latest"
  121. skip_push: '{{ if eq .Env.DOCKERHUB_USERNAME "skip" }}true{{ else }}false{{ end }}'
  122. image_templates:
  123. - "{{ .Env.DOCKERHUB_USERNAME }}/sub2api:{{ .Version }}-amd64"
  124. - "{{ .Env.DOCKERHUB_USERNAME }}/sub2api:{{ .Version }}-arm64"
  125. - name_template: "{{ .Env.DOCKERHUB_USERNAME }}/sub2api:{{ .Major }}.{{ .Minor }}"
  126. skip_push: '{{ if eq .Env.DOCKERHUB_USERNAME "skip" }}true{{ else }}false{{ end }}'
  127. image_templates:
  128. - "{{ .Env.DOCKERHUB_USERNAME }}/sub2api:{{ .Version }}-amd64"
  129. - "{{ .Env.DOCKERHUB_USERNAME }}/sub2api:{{ .Version }}-arm64"
  130. - name_template: "{{ .Env.DOCKERHUB_USERNAME }}/sub2api:{{ .Major }}"
  131. skip_push: '{{ if eq .Env.DOCKERHUB_USERNAME "skip" }}true{{ else }}false{{ end }}'
  132. image_templates:
  133. - "{{ .Env.DOCKERHUB_USERNAME }}/sub2api:{{ .Version }}-amd64"
  134. - "{{ .Env.DOCKERHUB_USERNAME }}/sub2api:{{ .Version }}-arm64"
  135. # GHCR manifests (owner must be lowercase)
  136. - name_template: "ghcr.io/{{ .Env.GITHUB_REPO_OWNER_LOWER }}/sub2api:{{ .Version }}"
  137. image_templates:
  138. - "ghcr.io/{{ .Env.GITHUB_REPO_OWNER_LOWER }}/sub2api:{{ .Version }}-amd64"
  139. - "ghcr.io/{{ .Env.GITHUB_REPO_OWNER_LOWER }}/sub2api:{{ .Version }}-arm64"
  140. - name_template: "ghcr.io/{{ .Env.GITHUB_REPO_OWNER_LOWER }}/sub2api:latest"
  141. image_templates:
  142. - "ghcr.io/{{ .Env.GITHUB_REPO_OWNER_LOWER }}/sub2api:{{ .Version }}-amd64"
  143. - "ghcr.io/{{ .Env.GITHUB_REPO_OWNER_LOWER }}/sub2api:{{ .Version }}-arm64"
  144. - name_template: "ghcr.io/{{ .Env.GITHUB_REPO_OWNER_LOWER }}/sub2api:{{ .Major }}.{{ .Minor }}"
  145. image_templates:
  146. - "ghcr.io/{{ .Env.GITHUB_REPO_OWNER_LOWER }}/sub2api:{{ .Version }}-amd64"
  147. - "ghcr.io/{{ .Env.GITHUB_REPO_OWNER_LOWER }}/sub2api:{{ .Version }}-arm64"
  148. - name_template: "ghcr.io/{{ .Env.GITHUB_REPO_OWNER_LOWER }}/sub2api:{{ .Major }}"
  149. image_templates:
  150. - "ghcr.io/{{ .Env.GITHUB_REPO_OWNER_LOWER }}/sub2api:{{ .Version }}-amd64"
  151. - "ghcr.io/{{ .Env.GITHUB_REPO_OWNER_LOWER }}/sub2api:{{ .Version }}-arm64"
  152. release:
  153. github:
  154. owner: "{{ .Env.GITHUB_REPO_OWNER }}"
  155. name: "{{ .Env.GITHUB_REPO_NAME }}"
  156. draft: false
  157. prerelease: auto
  158. name_template: "Sub2API {{.Version}}"
  159. # 完全使用 tag 消息作为 release 内容(通过环境变量传入)
  160. header: |
  161. > AI API Gateway Platform - 将 AI 订阅配额分发和管理
  162. {{ .Env.TAG_MESSAGE }}
  163. footer: |
  164. ---
  165. ## 📥 Installation
  166. **Docker:**
  167. ```bash
  168. {{ if ne .Env.DOCKERHUB_USERNAME "skip" -}}
  169. # Docker Hub
  170. docker pull {{ .Env.DOCKERHUB_USERNAME }}/sub2api:{{ .Version }}
  171. {{ end -}}
  172. # GitHub Container Registry
  173. docker pull ghcr.io/{{ .Env.GITHUB_REPO_OWNER_LOWER }}/sub2api:{{ .Version }}
  174. ```
  175. **One-line install (Linux):**
  176. ```bash
  177. curl -sSL https://raw.githubusercontent.com/{{ .Env.GITHUB_REPO_OWNER }}/{{ .Env.GITHUB_REPO_NAME }}/main/deploy/install.sh | sudo bash
  178. ```
  179. **Manual download:**
  180. Download the appropriate archive for your platform from the assets below.
  181. ## 📚 Documentation
  182. - [GitHub Repository](https://github.com/{{ .Env.GITHUB_REPO_OWNER }}/{{ .Env.GITHUB_REPO_NAME }})
  183. - [Installation Guide](https://github.com/{{ .Env.GITHUB_REPO_OWNER }}/{{ .Env.GITHUB_REPO_NAME }}/blob/main/deploy/README.md)