feat: try build linux workflow

This commit is contained in:
sunjuzhong 2025-03-07 16:26:17 +08:00
parent 88636c8f0e
commit 2d75c7aa6f
6 changed files with 183 additions and 48 deletions

View file

@ -5,51 +5,140 @@ on:
inputs: inputs:
tags: tags:
description: "Version tags" description: "Version tags"
required: true
type: string env:
VERSION: 0.9.0
jobs: jobs:
build: build:
strategy:
matrix:
go: [1.23.4]
runs-on: "ubuntu-latest" runs-on: "ubuntu-latest"
container:
image: sjzsdu/yao-build:0.10.4
options: --privileged
volumes:
- /data:/data
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
GO111MODULE: on
GOPROXY: https://goproxy.cn,direct
steps: steps:
- name: Checkout code - name: Setup Node.js
uses: actions/setup-node@v4
with:
node-version: 18
- name: Install pnpm
run: npm install -g pnpm
- name: Setup Cache
uses: actions/cache@v4
with:
path: |
~/.cache/go-build
~/go/pkg/mod
key: ${{ runner.os }}-go-${{ hashFiles('**/go.sum') }}
restore-keys: |
${{ runner.os }}-go-
- name: Install Cross Compilers
run: |
sudo apt-get update
sudo apt-get install -y libc6-armel-cross libc6-dev-armel-cross binutils-arm-linux-gnueabi libncurses5-dev build-essential bison flex libssl-dev bc
sudo apt-get install -y gcc-arm-linux-gnueabi g++-arm-linux-gnueabi
sudo apt-get install -y gcc-arm-linux-gnueabihf g++-arm-linux-gnueabihf
sudo apt-get install -y g++-aarch64-linux-gnu crossbuild-essential-arm64
sudo apt-get install -y gcc-13-aarch64-linux-gnu
sudo apt-get install -y g++-13-aarch64-linux-gnu
- name: Checkout Kun
uses: actions/checkout@v4 uses: actions/checkout@v4
with: with:
path: /app/yao repository: yaoapp/kun
path: kun
- name: Build - name: Checkout Xun
uses: actions/checkout@v4
with:
repository: yaoapp/xun
path: xun
- name: Checkout Gou
uses: actions/checkout@v4
with:
repository: sjzsdu/gou
path: gou
- name: Checkout V8Go
uses: actions/checkout@v4
with:
repository: yaoapp/v8go
path: v8go
- name: Unzip libv8
run: | run: |
export PATH=$PATH:/github/home/go/bin files=$(find ./v8go -name "libv8*.zip")
cd /app for file in $files; do
/app/build.sh dir=$(dirname "$file")
ls -l /data echo "Extracting $file to directory $dir"
unzip -o -d $dir $file
rm -rf $dir/__MACOSX
done
- name: Checkout XGen v1.0
uses: actions/checkout@v4
with:
repository: sjzsdu/xgen
path: xgen-v1.0
- name: Checkout Yao-Init
uses: actions/checkout@v4
with:
repository: yaoapp/yao-init
path: yao-init
- name: Move Kun, Xun, Gou, UI, V8Go
run: |
mv kun ../
mv xun ../
mv gou ../
mv v8go ../
mv xgen-v1.0 ../
mv yao-init ../
rm -f ../xgen-v1.0/packages/setup/vite.config.ts.*
ls -l .
ls -l ../
ls -l ../xgen-v1.0/packages/setup/
- name: Checkout Code
uses: actions/checkout@v4
with:
repository: sjzsdu/yao
- name: Setup Go ${{ matrix.go }}
uses: actions/setup-go@v5
with:
go-version: ${{ matrix.go }}
- name: Setup Go Tools
run: |
make tools
- name: Get Version
run: |
echo VERSION=$(cat share/const.go |grep 'const VERSION' | awk '{print $4}' | sed "s/\"//g") >> $GITHUB_ENV
- name: Make Artifacts Linux
run: |
make artifacts-linux
- name: Archive production artifacts - name: Archive production artifacts
uses: actions/upload-artifact@v4 uses: actions/upload-artifact@v4
with: with:
name: yao-linux name: yao-linux
path: | path: |
/data/* dist/release/*
- name: Create Release - name: Create Release
id: create_release
uses: softprops/action-gh-release@v1 uses: softprops/action-gh-release@v1
if: success()
continue-on-error: true continue-on-error: true
with: with:
tag_name: ${{ github.event.inputs.tags }} tag_name: v${{ env.VERSION }}
name: Release ${{ github.event.inputs.tags }} name: Release v${{ env.VERSION }}
files: /data/*
draft: false draft: false
prerelease: false prerelease: false
env: files: dist/release/*
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}

1
.gitignore vendored
View file

@ -42,3 +42,4 @@ xgen/v1.0/*
docker/build/test docker/build/test
db db
*.sh *.sh
!get-yao.sh

View file

@ -1,7 +1,7 @@
## Install Yao ## Install Yao
``` ```
curl -sSL https://github.com/sjzsdu/yao/raw/master/get-wn.sh | bash curl -sSL https://github.com/sjzsdu/yao/raw/master/get-yao.sh | bash
``` ```
## What is Yao? ## What is Yao?

View file

@ -1,14 +0,0 @@
# 使用 yaoapp/yao-build:0.10 作为基础镜像
FROM yaoapp/yao-build:0.10.4
# 将 entrypoint.sh 复制到容器内的 /app/ 目录
COPY ../build/build.sh /app/
# 设置工作目录
WORKDIR /app
# 确保 build.sh 具有执行权限
RUN chmod +x /app/build.sh
# 设置容器启动时执行的命令
CMD ["/app/build.sh"]

View file

@ -1,10 +1,4 @@
#!/bin/bash #!/bin/bash
set -e
# 确保目录存在并设置权限
mkdir -p /data
chmod 777 /data
cd /app && \ cd /app && \
git clone https://github.com/yaoapp/kun.git /app/kun && \ git clone https://github.com/yaoapp/kun.git /app/kun && \
git clone https://github.com/yaoapp/xun.git /app/xun && \ git clone https://github.com/yaoapp/xun.git /app/xun && \

65
get-yao.sh Normal file
View file

@ -0,0 +1,65 @@
#!/bin/bash
# 定义 GitHub 仓库信息
REPO="sjzsdu/yao"
API_URL="https://api.github.com/repos/$REPO/releases/latest"
# 获取最新版本号
VERSION=$(curl -s $API_URL | grep '"tag_name":' | sed -E 's/.*"([^"]+)".*/\1/')
# 获取最新版本号并移除 'v' 前缀(如果存在)
VERSION_NO=$(echo $VERSION | sed 's/^v//')
# 检测操作系统类型和架构
OS="unknown"
ARCH="unknown"
# 检测操作系统
if [[ "$OSTYPE" == "linux-gnu"* ]]; then
OS="linux"
elif [[ "$OSTYPE" == "darwin"* ]]; then
OS="darwin"
else
echo "不支持的操作系统类型: $OSTYPE"
exit 1
fi
# 检测架构
MACHINE_TYPE=$(uname -m)
if [[ "$MACHINE_TYPE" == "x86_64" ]]; then
ARCH="amd64"
elif [[ "$MACHINE_TYPE" == "arm64" ]] || [[ "$MACHINE_TYPE" == "aarch64" ]]; then
ARCH="arm64"
else
echo "不支持的系统架构: $MACHINE_TYPE"
exit 1
fi
# 构建下载 URL
DOWNLOAD_URL="https://github.com/$REPO/releases/download/$VERSION/yao-$VERSION_NO-unstable-$OS-$ARCH"
# 下载文件
echo "正在下载 yao-$OS-$ARCH ..."
curl -L $DOWNLOAD_URL -o yao
echo $DOWNLOAD_URL
# 使文件可执行
chmod +x yao
# 确定安装目录
INSTALL_DIR="/usr/local/bin"
if [[ ! -w "$INSTALL_DIR" ]]; then
INSTALL_DIR="$HOME/.local/bin"
mkdir -p "$INSTALL_DIR"
fi
# 移动文件到安装目录
echo "正在安装 yao 到 $INSTALL_DIR ..."
mv yao "$INSTALL_DIR/yao"
# 检查安装目录是否在 PATH 中
if [[ ":$PATH:" != *":$INSTALL_DIR:"* ]]; then
echo "请将 $INSTALL_DIR 添加到你的 PATH 环境变量中。"
echo "你可以通过在 ~/.bashrc 或 ~/.zshrc 中添加以下行来实现:"
echo "export PATH=\"\$PATH:$INSTALL_DIR\""
fi
echo "yao 安装完成!"