diff --git a/.github/workflows/build-linux.yml b/.github/workflows/build-linux.yml index e9b3ed4e..b68d5890 100644 --- a/.github/workflows/build-linux.yml +++ b/.github/workflows/build-linux.yml @@ -2,24 +2,21 @@ name: Build Linux Artifacts on: workflow_dispatch: - inputs: - tags: - description: "Version tags" - -env: - VERSION: 0.9.0 + push: + tags: + - 'v*' jobs: build: + runs-on: "ubuntu-latest" strategy: matrix: go: [1.23.4] - runs-on: "ubuntu-latest" steps: - name: Setup Node.js uses: actions/setup-node@v4 with: - node-version: 18 + node-version: 20 - name: Install pnpm run: npm install -g pnpm @@ -124,6 +121,8 @@ jobs: - name: Make Artifacts Linux run: | 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 uses: actions/upload-artifact@v4 @@ -141,4 +140,4 @@ jobs: name: Release v${{ env.VERSION }} draft: false prerelease: false - files: dist/release/* \ No newline at end of file + files: dist/release/* diff --git a/.github/workflows/build-macos.yml b/.github/workflows/build-macos.yml index 3242ac88..c9daa640 100644 --- a/.github/workflows/build-macos.yml +++ b/.github/workflows/build-macos.yml @@ -2,12 +2,9 @@ name: Build MacOS Artifacts on: workflow_dispatch: - inputs: - tags: - description: "Version tags" - -env: - VERSION: 0.9.0 + push: + tags: + - 'v*' jobs: build: @@ -19,7 +16,7 @@ jobs: - name: Setup Node.js uses: actions/setup-node@v4 with: - node-version: 18 + node-version: 20 - name: Install pnpm run: npm install -g pnpm @@ -69,8 +66,6 @@ jobs: done - 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 with: repository: sjzsdu/xgen @@ -116,8 +111,8 @@ jobs: - name: Make Artifacts MacOS run: | make artifacts-macos - mv dist/release/yao-$VERSION-dev-darwin-arm64 dist/release/yao-$VERSION-unstable-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-arm64 dist/release/yao-${{ env.VERSION }}-darwin-arm64 + mv dist/release/yao-${{ env.VERSION }}-dev-darwin-amd64 dist/release/yao-${{ env.VERSION }}-darwin-amd64 - name: Archive production artifacts uses: actions/upload-artifact@v4 diff --git a/.github/workflows/publish-docker.yml b/.github/workflows/publish-docker.yml new file mode 100644 index 00000000..509506f6 --- /dev/null +++ b/.github/workflows/publish-docker.yml @@ -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 }} \ No newline at end of file diff --git a/.gitignore b/.gitignore index 23a73603..5c6d5461 100644 --- a/.gitignore +++ b/.gitignore @@ -42,4 +42,5 @@ xgen/v1.0/* docker/build/test db *.sh -!get-yao.sh \ No newline at end of file +!get-yao.sh +__debug* \ No newline at end of file diff --git a/.vscode/launch.json b/.vscode/launch.json index f817c94a..862adcfb 100644 --- a/.vscode/launch.json +++ b/.vscode/launch.json @@ -16,17 +16,6 @@ "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", "type": "go", diff --git a/README.md b/README.md index 6b4af279..35e6f55e 100644 --- a/README.md +++ b/README.md @@ -1,7 +1,7 @@ ## 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? diff --git a/README.zh-CN.md b/README.zh-CN.md index f25ee572..b8bfe063 100644 --- a/README.zh-CN.md +++ b/README.zh-CN.md @@ -3,7 +3,7 @@ ## 安装 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 ``` [![UnitTest](https://github.com/YaoApp/yao/actions/workflows/unit-test.yml/badge.svg)](https://github.com/YaoApp/yao/actions/workflows/unit-test.yml) diff --git a/docker/base/Dockerfile b/docker/base/Dockerfile new file mode 100644 index 00000000..a84154c5 --- /dev/null +++ b/docker/base/Dockerfile @@ -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 \ No newline at end of file diff --git a/get-yao.sh b/get-yao.sh index 34a2332c..dcf9891f 100644 --- a/get-yao.sh +++ b/get-yao.sh @@ -2,12 +2,10 @@ # 定义 GitHub 仓库信息 REPO="sjzsdu/yao" -API_URL="https://api.github.com/repos/$REPO/releases/latest" +CONST_URL="https://raw.githubusercontent.com/$REPO/main/share/const.go" -# 获取最新版本号 -VERSION=$(curl -s $API_URL | grep '"tag_name":' | sed -E 's/.*"([^"]+)".*/\1/') -# 获取最新版本号并移除 'v' 前缀(如果存在) -VERSION_NO=$(echo $VERSION | sed 's/^v//') +# 从 const.go 文件获取最新版本号 +VERSION=$(curl -s $CONST_URL | grep 'const VERSION' | awk -F '"' '{print $2}') # 检测操作系统类型和架构 OS="unknown" @@ -35,12 +33,13 @@ else fi # 构建下载 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 -echo $DOWNLOAD_URL +echo "下载 URL: $DOWNLOAD_URL" + # 使文件可执行 chmod +x yao diff --git a/share/const.go b/share/const.go index 64ca66f3..36d4b2c4 100644 --- a/share/const.go +++ b/share/const.go @@ -1,7 +1,7 @@ package share // VERSION 版本号 -const VERSION = "0.10.4" +const VERSION = "0.10.4.1" // PRVERSION PreRelease Version const PRVERSION = "DEV"