feat: build and docker image
This commit is contained in:
parent
2d75c7aa6f
commit
df3dd3fb34
10 changed files with 111 additions and 43 deletions
13
.github/workflows/build-linux.yml
vendored
13
.github/workflows/build-linux.yml
vendored
|
|
@ -2,24 +2,21 @@ name: Build Linux Artifacts
|
||||||
|
|
||||||
on:
|
on:
|
||||||
workflow_dispatch:
|
workflow_dispatch:
|
||||||
inputs:
|
push:
|
||||||
tags:
|
tags:
|
||||||
description: "Version tags"
|
- 'v*'
|
||||||
|
|
||||||
env:
|
|
||||||
VERSION: 0.9.0
|
|
||||||
|
|
||||||
jobs:
|
jobs:
|
||||||
build:
|
build:
|
||||||
|
runs-on: "ubuntu-latest"
|
||||||
strategy:
|
strategy:
|
||||||
matrix:
|
matrix:
|
||||||
go: [1.23.4]
|
go: [1.23.4]
|
||||||
runs-on: "ubuntu-latest"
|
|
||||||
steps:
|
steps:
|
||||||
- name: Setup Node.js
|
- name: Setup Node.js
|
||||||
uses: actions/setup-node@v4
|
uses: actions/setup-node@v4
|
||||||
with:
|
with:
|
||||||
node-version: 18
|
node-version: 20
|
||||||
|
|
||||||
- name: Install pnpm
|
- name: Install pnpm
|
||||||
run: npm install -g pnpm
|
run: npm install -g pnpm
|
||||||
|
|
@ -124,6 +121,8 @@ jobs:
|
||||||
- name: Make Artifacts Linux
|
- name: Make Artifacts Linux
|
||||||
run: |
|
run: |
|
||||||
make artifacts-linux
|
make artifacts-linux
|
||||||
|
mv dist/release/yao-${{ env.VERSION }}-unstable-linux-arm64 dist/release/yao-${{ env.VERSION }}-linux-arm64
|
||||||
|
mv dist/release/yao-${{ env.VERSION }}-unstable-linux-amd64 dist/release/yao-${{ env.VERSION }}-linux-amd64
|
||||||
|
|
||||||
- name: Archive production artifacts
|
- name: Archive production artifacts
|
||||||
uses: actions/upload-artifact@v4
|
uses: actions/upload-artifact@v4
|
||||||
|
|
|
||||||
15
.github/workflows/build-macos.yml
vendored
15
.github/workflows/build-macos.yml
vendored
|
|
@ -2,12 +2,9 @@ name: Build MacOS Artifacts
|
||||||
|
|
||||||
on:
|
on:
|
||||||
workflow_dispatch:
|
workflow_dispatch:
|
||||||
inputs:
|
push:
|
||||||
tags:
|
tags:
|
||||||
description: "Version tags"
|
- 'v*'
|
||||||
|
|
||||||
env:
|
|
||||||
VERSION: 0.9.0
|
|
||||||
|
|
||||||
jobs:
|
jobs:
|
||||||
build:
|
build:
|
||||||
|
|
@ -19,7 +16,7 @@ jobs:
|
||||||
- name: Setup Node.js
|
- name: Setup Node.js
|
||||||
uses: actions/setup-node@v4
|
uses: actions/setup-node@v4
|
||||||
with:
|
with:
|
||||||
node-version: 18
|
node-version: 20
|
||||||
|
|
||||||
- name: Install pnpm
|
- name: Install pnpm
|
||||||
run: npm install -g pnpm
|
run: npm install -g pnpm
|
||||||
|
|
@ -69,8 +66,6 @@ jobs:
|
||||||
done
|
done
|
||||||
|
|
||||||
- name: Checkout XGen v1.0
|
- name: Checkout XGen v1.0
|
||||||
# ** XGEN will be renamed to DUI in the feature. and move to the new repository. **
|
|
||||||
# ** new repository: https://github.com/YaoApp/dui.git **
|
|
||||||
uses: actions/checkout@v4
|
uses: actions/checkout@v4
|
||||||
with:
|
with:
|
||||||
repository: sjzsdu/xgen
|
repository: sjzsdu/xgen
|
||||||
|
|
@ -116,8 +111,8 @@ jobs:
|
||||||
- name: Make Artifacts MacOS
|
- name: Make Artifacts MacOS
|
||||||
run: |
|
run: |
|
||||||
make artifacts-macos
|
make artifacts-macos
|
||||||
mv dist/release/yao-$VERSION-dev-darwin-arm64 dist/release/yao-$VERSION-unstable-darwin-arm64
|
mv dist/release/yao-${{ env.VERSION }}-dev-darwin-arm64 dist/release/yao-${{ env.VERSION }}-darwin-arm64
|
||||||
mv dist/release/yao-$VERSION-dev-darwin-amd64 dist/release/yao-$VERSION-unstable-darwin-amd64
|
mv dist/release/yao-${{ env.VERSION }}-dev-darwin-amd64 dist/release/yao-${{ env.VERSION }}-darwin-amd64
|
||||||
|
|
||||||
- name: Archive production artifacts
|
- name: Archive production artifacts
|
||||||
uses: actions/upload-artifact@v4
|
uses: actions/upload-artifact@v4
|
||||||
|
|
|
||||||
59
.github/workflows/publish-docker.yml
vendored
Normal file
59
.github/workflows/publish-docker.yml
vendored
Normal file
|
|
@ -0,0 +1,59 @@
|
||||||
|
name: Publish Docker Image
|
||||||
|
|
||||||
|
on:
|
||||||
|
workflow_dispatch:
|
||||||
|
inputs:
|
||||||
|
run_id:
|
||||||
|
description: "Build Linux Artifacts Run ID"
|
||||||
|
required: false
|
||||||
|
type: string
|
||||||
|
workflow_run:
|
||||||
|
workflows: ["Build Linux Artifacts"]
|
||||||
|
types:
|
||||||
|
- completed
|
||||||
|
|
||||||
|
env:
|
||||||
|
DOCKER_IMAGE: yaoapp/yao
|
||||||
|
PLATFORMS: linux/amd64,linux/arm64
|
||||||
|
|
||||||
|
jobs:
|
||||||
|
publish:
|
||||||
|
if: ${{ github.event.workflow_run.conclusion == 'success' }}
|
||||||
|
runs-on: ubuntu-latest
|
||||||
|
steps:
|
||||||
|
- name: Download artifacts
|
||||||
|
uses: actions/download-artifact@v4
|
||||||
|
with:
|
||||||
|
name: yao-linux
|
||||||
|
path: dist/release
|
||||||
|
run-id: ${{ github.event.workflow_run.id || inputs.run_id }}
|
||||||
|
|
||||||
|
- name: Set up QEMU
|
||||||
|
uses: docker/setup-qemu-action@v3
|
||||||
|
|
||||||
|
- name: Set up Docker Buildx
|
||||||
|
uses: docker/setup-buildx-action@v3
|
||||||
|
|
||||||
|
- name: Login to Docker Hub
|
||||||
|
uses: docker/login-action@v3
|
||||||
|
with:
|
||||||
|
username: ${{ secrets.DOCKERHUB_USERNAME }}
|
||||||
|
password: ${{ secrets.DOCKERHUB_TOKEN }}
|
||||||
|
|
||||||
|
- name: Get Version
|
||||||
|
run: |
|
||||||
|
VERSION=$(ls dist/release/yao-*-linux-amd64 | sed 's/.*yao-\(.*\)-unstable-linux-amd64/\1/')
|
||||||
|
echo "VERSION=$VERSION" >> $GITHUB_ENV
|
||||||
|
|
||||||
|
- name: Build and push
|
||||||
|
uses: docker/build-push-action@v5
|
||||||
|
with:
|
||||||
|
context: .
|
||||||
|
file: docker/base/Dockerfile
|
||||||
|
platforms: ${{ env.PLATFORMS }}
|
||||||
|
push: true
|
||||||
|
tags: |
|
||||||
|
${{ env.DOCKER_IMAGE }}:latest
|
||||||
|
${{ env.DOCKER_IMAGE }}:${{ env.VERSION }}
|
||||||
|
build-args: |
|
||||||
|
VERSION=${{ env.VERSION }}
|
||||||
1
.gitignore
vendored
1
.gitignore
vendored
|
|
@ -43,3 +43,4 @@ docker/build/test
|
||||||
db
|
db
|
||||||
*.sh
|
*.sh
|
||||||
!get-yao.sh
|
!get-yao.sh
|
||||||
|
__debug*
|
||||||
11
.vscode/launch.json
vendored
11
.vscode/launch.json
vendored
|
|
@ -16,17 +16,6 @@
|
||||||
"yao.app.menu",
|
"yao.app.menu",
|
||||||
],
|
],
|
||||||
},
|
},
|
||||||
{
|
|
||||||
"name": "Launch Yao Project",
|
|
||||||
"type": "go",
|
|
||||||
"request": "launch",
|
|
||||||
"mode": "auto",
|
|
||||||
"program": "${workspaceFolder}/main.go",
|
|
||||||
"cwd": "/Users/juzhongsun/Works/yao-project",
|
|
||||||
"args": [
|
|
||||||
"start"
|
|
||||||
],
|
|
||||||
},
|
|
||||||
{
|
{
|
||||||
"name": "Launch Fabric Project",
|
"name": "Launch Fabric Project",
|
||||||
"type": "go",
|
"type": "go",
|
||||||
|
|
|
||||||
|
|
@ -1,7 +1,7 @@
|
||||||
## Install Yao
|
## Install Yao
|
||||||
|
|
||||||
```
|
```
|
||||||
curl -sSL https://github.com/sjzsdu/yao/raw/master/get-yao.sh | bash
|
curl -sSL https://raw.githubusercontent.com/sjzsdu/yao/refs/heads/main/get-yao.sh | bash
|
||||||
```
|
```
|
||||||
|
|
||||||
## What is Yao?
|
## What is Yao?
|
||||||
|
|
|
||||||
|
|
@ -3,7 +3,7 @@
|
||||||
## 安装 Yao
|
## 安装 Yao
|
||||||
|
|
||||||
```
|
```
|
||||||
curl -sSL https://github.com/sjzsdu/yao/raw/master/get-wn.sh | bash
|
curl -sSL https://raw.githubusercontent.com/sjzsdu/yao/refs/heads/main/get-yao.sh | bash
|
||||||
```
|
```
|
||||||
|
|
||||||
[](https://github.com/YaoApp/yao/actions/workflows/unit-test.yml)
|
[](https://github.com/YaoApp/yao/actions/workflows/unit-test.yml)
|
||||||
|
|
|
||||||
26
docker/base/Dockerfile
Normal file
26
docker/base/Dockerfile
Normal file
|
|
@ -0,0 +1,26 @@
|
||||||
|
# ===========================================
|
||||||
|
# Yao Base Image
|
||||||
|
# A minimal base image for running Yao applications
|
||||||
|
#
|
||||||
|
# Build:
|
||||||
|
# docker build --platform linux/amd64 --build-arg VERSION=0.10.4 --build-arg ARCH=amd64 -t yaoapp/yao-base:0.10.4-amd64 .
|
||||||
|
# docker build --platform linux/arm64 --build-arg VERSION=0.10.4 --build-arg ARCH=arm64 -t yaoapp/yao-base:0.10.4-arm64 .
|
||||||
|
#
|
||||||
|
# Tests:
|
||||||
|
# docker run --rm yaoapp/yao-base:0.10.4-amd64 yao version
|
||||||
|
#
|
||||||
|
# ===========================================
|
||||||
|
FROM alpine:latest
|
||||||
|
ARG VERSION
|
||||||
|
ARG ARCH
|
||||||
|
|
||||||
|
# Install minimal dependencies
|
||||||
|
RUN apk --no-cache add curl
|
||||||
|
|
||||||
|
# Copy and install Yao binary from build artifacts
|
||||||
|
COPY dist/yao-${VERSION}-linux-${ARCH} /usr/local/bin/yao
|
||||||
|
RUN chmod +x /usr/local/bin/yao && \
|
||||||
|
addgroup -S yao && adduser -S -G yao yao
|
||||||
|
|
||||||
|
# Switch to non-root user
|
||||||
|
USER yao
|
||||||
15
get-yao.sh
15
get-yao.sh
|
|
@ -2,12 +2,10 @@
|
||||||
|
|
||||||
# 定义 GitHub 仓库信息
|
# 定义 GitHub 仓库信息
|
||||||
REPO="sjzsdu/yao"
|
REPO="sjzsdu/yao"
|
||||||
API_URL="https://api.github.com/repos/$REPO/releases/latest"
|
CONST_URL="https://raw.githubusercontent.com/$REPO/main/share/const.go"
|
||||||
|
|
||||||
# 获取最新版本号
|
# 从 const.go 文件获取最新版本号
|
||||||
VERSION=$(curl -s $API_URL | grep '"tag_name":' | sed -E 's/.*"([^"]+)".*/\1/')
|
VERSION=$(curl -s $CONST_URL | grep 'const VERSION' | awk -F '"' '{print $2}')
|
||||||
# 获取最新版本号并移除 'v' 前缀(如果存在)
|
|
||||||
VERSION_NO=$(echo $VERSION | sed 's/^v//')
|
|
||||||
|
|
||||||
# 检测操作系统类型和架构
|
# 检测操作系统类型和架构
|
||||||
OS="unknown"
|
OS="unknown"
|
||||||
|
|
@ -35,12 +33,13 @@ else
|
||||||
fi
|
fi
|
||||||
|
|
||||||
# 构建下载 URL
|
# 构建下载 URL
|
||||||
DOWNLOAD_URL="https://github.com/$REPO/releases/download/$VERSION/yao-$VERSION_NO-unstable-$OS-$ARCH"
|
DOWNLOAD_URL="https://github.com/$REPO/releases/download/v$VERSION/yao-$VERSION-$OS-$ARCH"
|
||||||
|
|
||||||
# 下载文件
|
# 下载文件
|
||||||
echo "正在下载 yao-$OS-$ARCH ..."
|
echo "正在下载 yao-$OS-$ARCH 版本 $VERSION ..."
|
||||||
curl -L $DOWNLOAD_URL -o yao
|
curl -L $DOWNLOAD_URL -o yao
|
||||||
echo $DOWNLOAD_URL
|
echo "下载 URL: $DOWNLOAD_URL"
|
||||||
|
|
||||||
# 使文件可执行
|
# 使文件可执行
|
||||||
chmod +x yao
|
chmod +x yao
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -1,7 +1,7 @@
|
||||||
package share
|
package share
|
||||||
|
|
||||||
// VERSION 版本号
|
// VERSION 版本号
|
||||||
const VERSION = "0.10.4"
|
const VERSION = "0.10.4.1"
|
||||||
|
|
||||||
// PRVERSION PreRelease Version
|
// PRVERSION PreRelease Version
|
||||||
const PRVERSION = "DEV"
|
const PRVERSION = "DEV"
|
||||||
|
|
|
||||||
Loading…
Add table
Reference in a new issue