diff --git a/.github/workflows/build-linux.yml b/.github/workflows/build-linux.yml index baf4b2c1..e9b3ed4e 100644 --- a/.github/workflows/build-linux.yml +++ b/.github/workflows/build-linux.yml @@ -5,51 +5,140 @@ on: inputs: tags: description: "Version tags" - required: true - type: string + +env: + VERSION: 0.9.0 jobs: build: + strategy: + matrix: + go: [1.23.4] 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: - - 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 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: | - export PATH=$PATH:/github/home/go/bin - cd /app - /app/build.sh - ls -l /data + files=$(find ./v8go -name "libv8*.zip") + for file in $files; do + dir=$(dirname "$file") + 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 uses: actions/upload-artifact@v4 with: name: yao-linux path: | - /data/* + dist/release/* - name: Create Release + id: create_release uses: softprops/action-gh-release@v1 - if: success() continue-on-error: true with: - tag_name: ${{ github.event.inputs.tags }} - name: Release ${{ github.event.inputs.tags }} - files: /data/* + tag_name: v${{ env.VERSION }} + name: Release v${{ env.VERSION }} draft: false prerelease: false - env: - GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} + files: dist/release/* \ No newline at end of file diff --git a/.gitignore b/.gitignore index 38df4f34..23a73603 100644 --- a/.gitignore +++ b/.gitignore @@ -41,4 +41,5 @@ xgen/v1.0/* *-unit-test docker/build/test db -*.sh \ No newline at end of file +*.sh +!get-yao.sh \ No newline at end of file diff --git a/README.md b/README.md index ea9e9e6a..6b4af279 100644 --- a/README.md +++ b/README.md @@ -1,7 +1,7 @@ ## 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? diff --git a/docker/build-indirect/Dockerfile b/docker/build-indirect/Dockerfile deleted file mode 100644 index 8a49dd90..00000000 --- a/docker/build-indirect/Dockerfile +++ /dev/null @@ -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"] diff --git a/docker/build/build.sh b/docker/build/build.sh index f469e3f0..a8f456d5 100644 --- a/docker/build/build.sh +++ b/docker/build/build.sh @@ -1,10 +1,4 @@ #!/bin/bash -set -e - -# 确保目录存在并设置权限 -mkdir -p /data -chmod 777 /data - cd /app && \ git clone https://github.com/yaoapp/kun.git /app/kun && \ git clone https://github.com/yaoapp/xun.git /app/xun && \ diff --git a/get-yao.sh b/get-yao.sh new file mode 100644 index 00000000..34a2332c --- /dev/null +++ b/get-yao.sh @@ -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 安装完成!"