feat(apk): 增加公开APK管理接口和CI/CD工作流
- 新增获取最新APK版本信息和下载APK的公开接口 - 更新README文档,添加APK管理接口的使用说明 - 实现CI/CD工作流,支持自动构建和部署 - 优化APK存储逻辑,确保只保留最新APK文件
This commit is contained in:
95
.gitea/workflows/build.yml
Normal file
95
.gitea/workflows/build.yml
Normal file
@@ -0,0 +1,95 @@
|
||||
name: Build Updates Server
|
||||
|
||||
on:
|
||||
push:
|
||||
branches:
|
||||
- master
|
||||
- main
|
||||
pull_request:
|
||||
branches:
|
||||
- master
|
||||
- main
|
||||
|
||||
env:
|
||||
GO_VERSION: '1.25'
|
||||
|
||||
jobs:
|
||||
build:
|
||||
runs-on: ubuntu-latest
|
||||
steps:
|
||||
- name: Checkout
|
||||
uses: actions/checkout@v4
|
||||
|
||||
- name: Set up Go
|
||||
uses: actions/setup-go@v5
|
||||
with:
|
||||
go-version: ${{ env.GO_VERSION }}
|
||||
cache: true
|
||||
|
||||
- name: Go cache info
|
||||
run: |
|
||||
echo "Go cache directory:"
|
||||
go env GOCACHE
|
||||
echo "Go module cache directory:"
|
||||
go env GOMODCACHE
|
||||
|
||||
- name: Download dependencies
|
||||
run: go mod download
|
||||
|
||||
- name: Build
|
||||
env:
|
||||
GOOS: linux
|
||||
GOARCH: amd64
|
||||
CGO_ENABLED: 0
|
||||
run: go build -v -ldflags="-s -w" -o server ./cmd/server
|
||||
|
||||
- name: Upload artifacts
|
||||
uses: actions/upload-artifact@v3
|
||||
with:
|
||||
name: updates-server-linux-amd64
|
||||
path: server
|
||||
|
||||
build-docker:
|
||||
runs-on: ubuntu-latest
|
||||
needs: build
|
||||
if: github.event_name == 'push'
|
||||
steps:
|
||||
- name: Checkout
|
||||
uses: actions/checkout@v4
|
||||
|
||||
- name: Set up Docker Buildx
|
||||
uses: docker/setup-buildx-action@v3
|
||||
|
||||
- name: Login to Gitea Container Registry
|
||||
uses: docker/login-action@v3
|
||||
with:
|
||||
registry: code.littlelan.cn
|
||||
username: ${{ secrets.GIT_USERNAME }}
|
||||
password: ${{ secrets.GIT_TOKEN }}
|
||||
|
||||
- name: Download artifact
|
||||
uses: actions/download-artifact@v3
|
||||
with:
|
||||
name: updates-server-linux-amd64
|
||||
|
||||
- name: Ensure binary executable
|
||||
run: chmod +x ./server
|
||||
|
||||
- name: Build and push Docker image
|
||||
uses: docker/build-push-action@v5
|
||||
with:
|
||||
context: .
|
||||
push: true
|
||||
tags: |
|
||||
code.littlelan.cn/carrot_bbs/updates-server:latest
|
||||
code.littlelan.cn/carrot_bbs/updates-server:${{ github.sha }}
|
||||
platforms: linux/amd64
|
||||
cache-from: type=registry,ref=code.littlelan.cn/carrot_bbs/updates-server:buildcache
|
||||
cache-to: type=registry,ref=code.littlelan.cn/carrot_bbs/updates-server:buildcache,mode=max
|
||||
|
||||
- name: Summary
|
||||
run: |
|
||||
echo "## Build Summary" >> $GITHUB_STEP_SUMMARY
|
||||
echo "" >> $GITHUB_STEP_SUMMARY
|
||||
echo "**Image:** code.littlelan.cn/carrot_bbs/updates-server" >> $GITHUB_STEP_SUMMARY
|
||||
echo "**Tags:** latest, ${{ github.sha }}" >> $GITHUB_STEP_SUMMARY
|
||||
Reference in New Issue
Block a user