| 123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212 |
- version: 2
- project_name: sub2api
- before:
- hooks:
- - go mod tidy -C backend
- builds:
- - id: sub2api
- dir: backend
- main: ./cmd/server
- binary: sub2api
- flags:
- - -tags=embed
- env:
- - CGO_ENABLED=0
- goos:
- - linux
- - windows
- - darwin
- goarch:
- - amd64
- - arm64
- ignore:
- - goos: windows
- goarch: arm64
- ldflags:
- - -s -w
- - -X main.Commit={{.Commit}}
- - -X main.Date={{.Date}}
- - -X main.BuildType=release
- archives:
- - id: default
- format: tar.gz
- name_template: >-
- {{ .ProjectName }}_{{ .Version }}_{{ .Os }}_{{ .Arch }}
- format_overrides:
- - goos: windows
- format: zip
- files:
- - LICENSE*
- - README*
- - deploy/*
- checksum:
- name_template: 'checksums.txt'
- algorithm: sha256
- changelog:
- # 禁用自动 changelog,完全使用 tag 消息
- disable: true
- # Docker images
- dockers:
- # DockerHub images (skipped if DOCKERHUB_USERNAME is 'skip')
- - id: amd64
- goos: linux
- goarch: amd64
- skip_push: '{{ if eq .Env.DOCKERHUB_USERNAME "skip" }}true{{ else }}false{{ end }}'
- image_templates:
- - "{{ .Env.DOCKERHUB_USERNAME }}/sub2api:{{ .Version }}-amd64"
- dockerfile: Dockerfile.goreleaser
- use: buildx
- extra_files:
- - deploy/docker-entrypoint.sh
- - backend/resources
- build_flag_templates:
- - "--platform=linux/amd64"
- - "--label=org.opencontainers.image.version={{ .Version }}"
- - "--label=org.opencontainers.image.revision={{ .Commit }}"
- - id: arm64
- goos: linux
- goarch: arm64
- skip_push: '{{ if eq .Env.DOCKERHUB_USERNAME "skip" }}true{{ else }}false{{ end }}'
- image_templates:
- - "{{ .Env.DOCKERHUB_USERNAME }}/sub2api:{{ .Version }}-arm64"
- dockerfile: Dockerfile.goreleaser
- use: buildx
- extra_files:
- - deploy/docker-entrypoint.sh
- - backend/resources
- build_flag_templates:
- - "--platform=linux/arm64"
- - "--label=org.opencontainers.image.version={{ .Version }}"
- - "--label=org.opencontainers.image.revision={{ .Commit }}"
- # GHCR images (owner must be lowercase)
- - id: ghcr-amd64
- goos: linux
- goarch: amd64
- image_templates:
- - "ghcr.io/{{ .Env.GITHUB_REPO_OWNER_LOWER }}/sub2api:{{ .Version }}-amd64"
- dockerfile: Dockerfile.goreleaser
- use: buildx
- extra_files:
- - deploy/docker-entrypoint.sh
- - backend/resources
- build_flag_templates:
- - "--platform=linux/amd64"
- - "--label=org.opencontainers.image.version={{ .Version }}"
- - "--label=org.opencontainers.image.revision={{ .Commit }}"
- - "--label=org.opencontainers.image.source=https://github.com/{{ .Env.GITHUB_REPO_OWNER }}/{{ .Env.GITHUB_REPO_NAME }}"
- - id: ghcr-arm64
- goos: linux
- goarch: arm64
- image_templates:
- - "ghcr.io/{{ .Env.GITHUB_REPO_OWNER_LOWER }}/sub2api:{{ .Version }}-arm64"
- dockerfile: Dockerfile.goreleaser
- use: buildx
- extra_files:
- - deploy/docker-entrypoint.sh
- - backend/resources
- build_flag_templates:
- - "--platform=linux/arm64"
- - "--label=org.opencontainers.image.version={{ .Version }}"
- - "--label=org.opencontainers.image.revision={{ .Commit }}"
- - "--label=org.opencontainers.image.source=https://github.com/{{ .Env.GITHUB_REPO_OWNER }}/{{ .Env.GITHUB_REPO_NAME }}"
- # Docker manifests for multi-arch support
- docker_manifests:
- # DockerHub manifests (skipped if DOCKERHUB_USERNAME is 'skip')
- - name_template: "{{ .Env.DOCKERHUB_USERNAME }}/sub2api:{{ .Version }}"
- skip_push: '{{ if eq .Env.DOCKERHUB_USERNAME "skip" }}true{{ else }}false{{ end }}'
- image_templates:
- - "{{ .Env.DOCKERHUB_USERNAME }}/sub2api:{{ .Version }}-amd64"
- - "{{ .Env.DOCKERHUB_USERNAME }}/sub2api:{{ .Version }}-arm64"
- - name_template: "{{ .Env.DOCKERHUB_USERNAME }}/sub2api:latest"
- skip_push: '{{ if eq .Env.DOCKERHUB_USERNAME "skip" }}true{{ else }}false{{ end }}'
- image_templates:
- - "{{ .Env.DOCKERHUB_USERNAME }}/sub2api:{{ .Version }}-amd64"
- - "{{ .Env.DOCKERHUB_USERNAME }}/sub2api:{{ .Version }}-arm64"
- - name_template: "{{ .Env.DOCKERHUB_USERNAME }}/sub2api:{{ .Major }}.{{ .Minor }}"
- skip_push: '{{ if eq .Env.DOCKERHUB_USERNAME "skip" }}true{{ else }}false{{ end }}'
- image_templates:
- - "{{ .Env.DOCKERHUB_USERNAME }}/sub2api:{{ .Version }}-amd64"
- - "{{ .Env.DOCKERHUB_USERNAME }}/sub2api:{{ .Version }}-arm64"
- - name_template: "{{ .Env.DOCKERHUB_USERNAME }}/sub2api:{{ .Major }}"
- skip_push: '{{ if eq .Env.DOCKERHUB_USERNAME "skip" }}true{{ else }}false{{ end }}'
- image_templates:
- - "{{ .Env.DOCKERHUB_USERNAME }}/sub2api:{{ .Version }}-amd64"
- - "{{ .Env.DOCKERHUB_USERNAME }}/sub2api:{{ .Version }}-arm64"
- # GHCR manifests (owner must be lowercase)
- - name_template: "ghcr.io/{{ .Env.GITHUB_REPO_OWNER_LOWER }}/sub2api:{{ .Version }}"
- image_templates:
- - "ghcr.io/{{ .Env.GITHUB_REPO_OWNER_LOWER }}/sub2api:{{ .Version }}-amd64"
- - "ghcr.io/{{ .Env.GITHUB_REPO_OWNER_LOWER }}/sub2api:{{ .Version }}-arm64"
- - name_template: "ghcr.io/{{ .Env.GITHUB_REPO_OWNER_LOWER }}/sub2api:latest"
- image_templates:
- - "ghcr.io/{{ .Env.GITHUB_REPO_OWNER_LOWER }}/sub2api:{{ .Version }}-amd64"
- - "ghcr.io/{{ .Env.GITHUB_REPO_OWNER_LOWER }}/sub2api:{{ .Version }}-arm64"
- - name_template: "ghcr.io/{{ .Env.GITHUB_REPO_OWNER_LOWER }}/sub2api:{{ .Major }}.{{ .Minor }}"
- image_templates:
- - "ghcr.io/{{ .Env.GITHUB_REPO_OWNER_LOWER }}/sub2api:{{ .Version }}-amd64"
- - "ghcr.io/{{ .Env.GITHUB_REPO_OWNER_LOWER }}/sub2api:{{ .Version }}-arm64"
- - name_template: "ghcr.io/{{ .Env.GITHUB_REPO_OWNER_LOWER }}/sub2api:{{ .Major }}"
- image_templates:
- - "ghcr.io/{{ .Env.GITHUB_REPO_OWNER_LOWER }}/sub2api:{{ .Version }}-amd64"
- - "ghcr.io/{{ .Env.GITHUB_REPO_OWNER_LOWER }}/sub2api:{{ .Version }}-arm64"
- release:
- github:
- owner: "{{ .Env.GITHUB_REPO_OWNER }}"
- name: "{{ .Env.GITHUB_REPO_NAME }}"
- draft: false
- prerelease: auto
- name_template: "Sub2API {{.Version}}"
- # 完全使用 tag 消息作为 release 内容(通过环境变量传入)
- header: |
- > AI API Gateway Platform - 将 AI 订阅配额分发和管理
- {{ .Env.TAG_MESSAGE }}
- footer: |
- ---
- ## 📥 Installation
- **Docker:**
- ```bash
- {{ if ne .Env.DOCKERHUB_USERNAME "skip" -}}
- # Docker Hub
- docker pull {{ .Env.DOCKERHUB_USERNAME }}/sub2api:{{ .Version }}
- {{ end -}}
- # GitHub Container Registry
- docker pull ghcr.io/{{ .Env.GITHUB_REPO_OWNER_LOWER }}/sub2api:{{ .Version }}
- ```
- **One-line install (Linux):**
- ```bash
- curl -sSL https://raw.githubusercontent.com/{{ .Env.GITHUB_REPO_OWNER }}/{{ .Env.GITHUB_REPO_NAME }}/main/deploy/install.sh | sudo bash
- ```
- **Manual download:**
- Download the appropriate archive for your platform from the assets below.
- ## 📚 Documentation
- - [GitHub Repository](https://github.com/{{ .Env.GITHUB_REPO_OWNER }}/{{ .Env.GITHUB_REPO_NAME }})
- - [Installation Guide](https://github.com/{{ .Env.GITHUB_REPO_OWNER }}/{{ .Env.GITHUB_REPO_NAME }}/blob/main/deploy/README.md)
|