86
.gitea/workflows/cicd.yaml
Normal file
86
.gitea/workflows/cicd.yaml
Normal file
@@ -0,0 +1,86 @@
|
||||
name: Files Release
|
||||
run-name: ${{ gitea.actor }} 发布 Files
|
||||
|
||||
on:
|
||||
push:
|
||||
tags:
|
||||
- 'v*'
|
||||
|
||||
jobs:
|
||||
release:
|
||||
runs-on: ubuntu-latest
|
||||
steps:
|
||||
- name: 清理临时目录
|
||||
run: rm -rf *
|
||||
|
||||
- name: 设置 Go
|
||||
uses: https://git.apinb.com/github/setup-go@v5
|
||||
with:
|
||||
go-version: '1.25.1'
|
||||
|
||||
- name: 检出代码
|
||||
uses: https://git.apinb.com/github/checkout@v4
|
||||
|
||||
- name: 缓存 Go 模块
|
||||
uses: https://git.apinb.com/github/cache@v4
|
||||
with:
|
||||
path: |
|
||||
~/.cache/go-build
|
||||
~/go/pkg/mod
|
||||
key: ${{ runner.os }}-go-${{ hashFiles('**/go.sum') }}
|
||||
restore-keys: |
|
||||
${{ runner.os }}-go-
|
||||
|
||||
- name: 提取发布版本
|
||||
id: version
|
||||
run: echo "tag_name=$(echo ${{ gitea.ref }} | sed 's/^refs\/tags\///')" >> $GITHUB_OUTPUT
|
||||
|
||||
- name: 写入版本信息
|
||||
run: echo "export srv_version='${{ steps.version.outputs.tag_name }}';export srv_name='ops-files'" > files_last_version.sh
|
||||
|
||||
- name: 配置 Go 模块代理
|
||||
run: |
|
||||
go env -w GOPROXY=https://goproxy.cn
|
||||
go env -w GOPRIVATE=git.apinb.com/*
|
||||
go env -w GONOPROXY=git.apinb.com/*
|
||||
go env -w GOINSECURE=git.apinb.com/*
|
||||
go env -w GONOSUMDB=git.apinb.com/*
|
||||
go env -w GOEXPERIMENT=jsonv2
|
||||
|
||||
- name: 构建 Files 服务
|
||||
run: go build -o ops-files ./cmd/main/main.go
|
||||
|
||||
- name: 上传版本信息
|
||||
uses: https://git.apinb.com/github/minio-upload@main
|
||||
with:
|
||||
endpoint: ${{ secrets.DEPLOY_STORAGE_ENDPOINT }}
|
||||
access-key-id: ${{ secrets.DEPLOY_STORAGE_ACCESS_KEY_ID }}
|
||||
access-key-secret: ${{ secrets.DEPLOY_STORAGE_ACCESS_KEY_SECRET }}
|
||||
bucket: ${{ secrets.DEPLOY_STORAGE_BUCKET }}
|
||||
source: ./files_last_version.sh
|
||||
insecure: true
|
||||
recursive: true
|
||||
|
||||
- name: 上传服务二进制
|
||||
uses: https://git.apinb.com/github/minio-upload@main
|
||||
with:
|
||||
endpoint: ${{ secrets.DEPLOY_STORAGE_ENDPOINT }}
|
||||
access-key-id: ${{ secrets.DEPLOY_STORAGE_ACCESS_KEY_ID }}
|
||||
access-key-secret: ${{ secrets.DEPLOY_STORAGE_ACCESS_KEY_SECRET }}
|
||||
bucket: ${{ secrets.DEPLOY_STORAGE_BUCKET }}
|
||||
source: ./ops-files
|
||||
target: /ops-files@${{ steps.version.outputs.tag_name }}/
|
||||
insecure: true
|
||||
recursive: false
|
||||
|
||||
- name: 上传部署文件
|
||||
uses: https://git.apinb.com/github/minio-upload@main
|
||||
with:
|
||||
endpoint: ${{ secrets.DEPLOY_STORAGE_ENDPOINT }}
|
||||
access-key-id: ${{ secrets.DEPLOY_STORAGE_ACCESS_KEY_ID }}
|
||||
access-key-secret: ${{ secrets.DEPLOY_STORAGE_ACCESS_KEY_SECRET }}
|
||||
bucket: ${{ secrets.DEPLOY_STORAGE_BUCKET }}
|
||||
source: ./etc
|
||||
target: /ops-files@${{ steps.version.outputs.tag_name }}/
|
||||
insecure: true
|
||||
recursive: true
|
||||
Reference in New Issue
Block a user