feat(ci): 增加 SIMPLE_RELEASE 参数支持简化发布
This commit is contained in:
40
.github/workflows/release.yml
vendored
40
.github/workflows/release.yml
vendored
@@ -4,6 +4,17 @@ on:
|
|||||||
push:
|
push:
|
||||||
tags:
|
tags:
|
||||||
- 'v*'
|
- 'v*'
|
||||||
|
workflow_dispatch:
|
||||||
|
inputs:
|
||||||
|
tag:
|
||||||
|
description: 'Tag to release (e.g., v1.0.0)'
|
||||||
|
required: true
|
||||||
|
type: string
|
||||||
|
simple_release:
|
||||||
|
description: 'Simple release: only x86_64 GHCR image, skip other artifacts'
|
||||||
|
required: false
|
||||||
|
type: boolean
|
||||||
|
default: false
|
||||||
|
|
||||||
permissions:
|
permissions:
|
||||||
contents: write
|
contents: write
|
||||||
@@ -19,7 +30,12 @@ jobs:
|
|||||||
|
|
||||||
- name: Update VERSION file
|
- name: Update VERSION file
|
||||||
run: |
|
run: |
|
||||||
VERSION=${GITHUB_REF#refs/tags/v}
|
if [ "${{ github.event_name }}" = "workflow_dispatch" ]; then
|
||||||
|
VERSION=${{ github.event.inputs.tag }}
|
||||||
|
VERSION=${VERSION#v}
|
||||||
|
else
|
||||||
|
VERSION=${GITHUB_REF#refs/tags/v}
|
||||||
|
fi
|
||||||
echo "$VERSION" > backend/cmd/server/VERSION
|
echo "$VERSION" > backend/cmd/server/VERSION
|
||||||
echo "Updated VERSION file to: $VERSION"
|
echo "Updated VERSION file to: $VERSION"
|
||||||
|
|
||||||
@@ -32,6 +48,7 @@ jobs:
|
|||||||
|
|
||||||
build-frontend:
|
build-frontend:
|
||||||
runs-on: ubuntu-latest
|
runs-on: ubuntu-latest
|
||||||
|
if: ${{ github.event.inputs.simple_release != 'true' }}
|
||||||
steps:
|
steps:
|
||||||
- name: Checkout
|
- name: Checkout
|
||||||
uses: actions/checkout@v4
|
uses: actions/checkout@v4
|
||||||
@@ -60,12 +77,15 @@ jobs:
|
|||||||
|
|
||||||
release:
|
release:
|
||||||
needs: [update-version, build-frontend]
|
needs: [update-version, build-frontend]
|
||||||
|
# 等待 build-frontend 完成(除非是 simple_release 则跳过检查)
|
||||||
|
if: ${{ always() && needs.update-version.result == 'success' && (github.event.inputs.simple_release == 'true' || needs.build-frontend.result == 'success') }}
|
||||||
runs-on: ubuntu-latest
|
runs-on: ubuntu-latest
|
||||||
steps:
|
steps:
|
||||||
- name: Checkout
|
- name: Checkout
|
||||||
uses: actions/checkout@v4
|
uses: actions/checkout@v4
|
||||||
with:
|
with:
|
||||||
fetch-depth: 0
|
fetch-depth: 0
|
||||||
|
ref: ${{ github.event.inputs.tag || github.ref }}
|
||||||
|
|
||||||
- name: Download VERSION artifact
|
- name: Download VERSION artifact
|
||||||
uses: actions/download-artifact@v4
|
uses: actions/download-artifact@v4
|
||||||
@@ -74,6 +94,7 @@ jobs:
|
|||||||
path: backend/cmd/server/
|
path: backend/cmd/server/
|
||||||
|
|
||||||
- name: Download frontend artifact
|
- name: Download frontend artifact
|
||||||
|
if: ${{ github.event.inputs.simple_release != 'true' }}
|
||||||
uses: actions/download-artifact@v4
|
uses: actions/download-artifact@v4
|
||||||
with:
|
with:
|
||||||
name: frontend-dist
|
name: frontend-dist
|
||||||
@@ -116,7 +137,11 @@ jobs:
|
|||||||
- name: Get tag message
|
- name: Get tag message
|
||||||
id: tag_message
|
id: tag_message
|
||||||
run: |
|
run: |
|
||||||
TAG_NAME=${GITHUB_REF#refs/tags/}
|
if [ "${{ github.event_name }}" = "workflow_dispatch" ]; then
|
||||||
|
TAG_NAME=${{ github.event.inputs.tag }}
|
||||||
|
else
|
||||||
|
TAG_NAME=${GITHUB_REF#refs/tags/}
|
||||||
|
fi
|
||||||
echo "Processing tag: $TAG_NAME"
|
echo "Processing tag: $TAG_NAME"
|
||||||
|
|
||||||
# 获取完整的 tag message(跳过第一行标题)
|
# 获取完整的 tag message(跳过第一行标题)
|
||||||
@@ -140,7 +165,7 @@ jobs:
|
|||||||
uses: goreleaser/goreleaser-action@v6
|
uses: goreleaser/goreleaser-action@v6
|
||||||
with:
|
with:
|
||||||
version: '~> v2'
|
version: '~> v2'
|
||||||
args: release --clean --skip=validate
|
args: release --clean --skip=validate ${{ github.event.inputs.simple_release == 'true' && '--config=.goreleaser.simple.yaml' || '' }}
|
||||||
env:
|
env:
|
||||||
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
|
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
|
||||||
TAG_MESSAGE: ${{ steps.tag_message.outputs.message }}
|
TAG_MESSAGE: ${{ steps.tag_message.outputs.message }}
|
||||||
@@ -151,7 +176,7 @@ jobs:
|
|||||||
|
|
||||||
# Update DockerHub description
|
# Update DockerHub description
|
||||||
- name: Update DockerHub description
|
- name: Update DockerHub description
|
||||||
if: ${{ env.DOCKERHUB_USERNAME != '' }}
|
if: ${{ github.event.inputs.simple_release != 'true' && env.DOCKERHUB_USERNAME != '' }}
|
||||||
uses: peter-evans/dockerhub-description@v4
|
uses: peter-evans/dockerhub-description@v4
|
||||||
env:
|
env:
|
||||||
DOCKERHUB_USERNAME: ${{ secrets.DOCKERHUB_USERNAME }}
|
DOCKERHUB_USERNAME: ${{ secrets.DOCKERHUB_USERNAME }}
|
||||||
@@ -164,6 +189,7 @@ jobs:
|
|||||||
|
|
||||||
# Send Telegram notification
|
# Send Telegram notification
|
||||||
- name: Send Telegram Notification
|
- name: Send Telegram Notification
|
||||||
|
if: ${{ github.event.inputs.simple_release != 'true' }}
|
||||||
env:
|
env:
|
||||||
TELEGRAM_BOT_TOKEN: ${{ secrets.TELEGRAM_BOT_TOKEN }}
|
TELEGRAM_BOT_TOKEN: ${{ secrets.TELEGRAM_BOT_TOKEN }}
|
||||||
TELEGRAM_CHAT_ID: ${{ secrets.TELEGRAM_CHAT_ID }}
|
TELEGRAM_CHAT_ID: ${{ secrets.TELEGRAM_CHAT_ID }}
|
||||||
@@ -176,7 +202,11 @@ jobs:
|
|||||||
exit 0
|
exit 0
|
||||||
fi
|
fi
|
||||||
|
|
||||||
TAG_NAME=${GITHUB_REF#refs/tags/}
|
if [ "${{ github.event_name }}" = "workflow_dispatch" ]; then
|
||||||
|
TAG_NAME=${{ github.event.inputs.tag }}
|
||||||
|
else
|
||||||
|
TAG_NAME=${GITHUB_REF#refs/tags/}
|
||||||
|
fi
|
||||||
VERSION=${TAG_NAME#v}
|
VERSION=${TAG_NAME#v}
|
||||||
REPO="${{ github.repository }}"
|
REPO="${{ github.repository }}"
|
||||||
GHCR_IMAGE="ghcr.io/${REPO,,}" # ${,,} converts to lowercase
|
GHCR_IMAGE="ghcr.io/${REPO,,}" # ${,,} converts to lowercase
|
||||||
|
|||||||
86
.goreleaser.simple.yaml
Normal file
86
.goreleaser.simple.yaml
Normal file
@@ -0,0 +1,86 @@
|
|||||||
|
# 简化版 GoReleaser 配置 - 仅发布 x86_64 GHCR 镜像
|
||||||
|
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
|
||||||
|
goarch:
|
||||||
|
- amd64
|
||||||
|
ldflags:
|
||||||
|
- -s -w
|
||||||
|
- -X main.Commit={{.Commit}}
|
||||||
|
- -X main.Date={{.Date}}
|
||||||
|
- -X main.BuildType=release
|
||||||
|
|
||||||
|
# 跳过 archives
|
||||||
|
archives: []
|
||||||
|
|
||||||
|
# 跳过 checksum
|
||||||
|
checksum:
|
||||||
|
disable: true
|
||||||
|
|
||||||
|
changelog:
|
||||||
|
disable: true
|
||||||
|
|
||||||
|
# 仅 GHCR x86_64 镜像
|
||||||
|
dockers:
|
||||||
|
- id: ghcr-amd64
|
||||||
|
goos: linux
|
||||||
|
goarch: amd64
|
||||||
|
image_templates:
|
||||||
|
- "ghcr.io/{{ .Env.GITHUB_REPO_OWNER_LOWER }}/sub2api:{{ .Version }}-amd64"
|
||||||
|
- "ghcr.io/{{ .Env.GITHUB_REPO_OWNER_LOWER }}/sub2api:{{ .Version }}"
|
||||||
|
- "ghcr.io/{{ .Env.GITHUB_REPO_OWNER_LOWER }}/sub2api:latest"
|
||||||
|
dockerfile: Dockerfile.goreleaser
|
||||||
|
use: buildx
|
||||||
|
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 }}"
|
||||||
|
|
||||||
|
# 跳过 manifests(单架构不需要)
|
||||||
|
docker_manifests: []
|
||||||
|
|
||||||
|
release:
|
||||||
|
github:
|
||||||
|
owner: "{{ .Env.GITHUB_REPO_OWNER }}"
|
||||||
|
name: "{{ .Env.GITHUB_REPO_NAME }}"
|
||||||
|
draft: false
|
||||||
|
prerelease: auto
|
||||||
|
name_template: "Sub2API {{.Version}} (Simple)"
|
||||||
|
# 跳过上传二进制包
|
||||||
|
skip_upload: true
|
||||||
|
header: |
|
||||||
|
> AI API Gateway Platform - 将 AI 订阅配额分发和管理
|
||||||
|
> ⚡ Simple Release: 仅包含 x86_64 GHCR 镜像
|
||||||
|
|
||||||
|
{{ .Env.TAG_MESSAGE }}
|
||||||
|
|
||||||
|
footer: |
|
||||||
|
---
|
||||||
|
|
||||||
|
## 📥 Installation
|
||||||
|
|
||||||
|
**Docker (x86_64 only):**
|
||||||
|
```bash
|
||||||
|
docker pull ghcr.io/{{ .Env.GITHUB_REPO_OWNER_LOWER }}/sub2api:{{ .Version }}
|
||||||
|
```
|
||||||
|
|
||||||
|
## 📚 Documentation
|
||||||
|
|
||||||
|
- [GitHub Repository](https://github.com/{{ .Env.GITHUB_REPO_OWNER }}/{{ .Env.GITHUB_REPO_NAME }})
|
||||||
Reference in New Issue
Block a user