From ee48f3a946dc01a3566f4acb3c177836c3f2e4fa Mon Sep 17 00:00:00 2001 From: Max Date: Mon, 16 Mar 2026 09:40:36 +0800 Subject: [PATCH] feat(workflow): enhance release workflows with version tagging and dependency management - Added steps to clone necessary dependencies in the Linux release workflow, ensuring all components are available for the build. - Implemented version setting from Git tags in both Linux and macOS workflows, improving version management consistency. - Updated the build script to extract and set the version from the YAO_VERSION environment variable, enhancing clarity in version handling. - Streamlined artifact creation steps to ensure proper versioning and organization of release artifacts. Made-with: Cursor --- .github/workflows/release-linux.yml | 41 +++++++++++++++++++++++++++-- .github/workflows/release-macos.yml | 12 +++++++++ .github/workflows/release.yml | 3 ++- 3 files changed, 53 insertions(+), 3 deletions(-) diff --git a/.github/workflows/release-linux.yml b/.github/workflows/release-linux.yml index 173d8b3d..db057837 100644 --- a/.github/workflows/release-linux.yml +++ b/.github/workflows/release-linux.yml @@ -37,7 +37,39 @@ jobs: - name: Build run: | export PATH=$PATH:/github/home/go/bin - /app/build.sh + + # Clone dependencies + cd /app + 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/gou.git /app/gou + git clone https://github.com/yaoapp/v8go.git /app/v8go + git clone https://github.com/yaoapp/cui.git /app/cui-v1.0 + git clone https://github.com/yaoapp/yao-init.git /app/yao-init + git clone https://github.com/yaoapp/yao.git /app/yao + + # Extract libv8 + files=$(find /app/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 + + # Set VERSION from git tag (required) + cd /app/yao + if [[ "$GITHUB_REF" != refs/tags/v* ]]; then + echo "::error::This workflow requires a tag (refs/tags/v*). Got: $GITHUB_REF" + exit 1 + fi + TAG_VERSION="${GITHUB_REF#refs/tags/v}" + echo "Setting VERSION to $TAG_VERSION" + sed -i "s/const VERSION = \".*\"/const VERSION = \"${TAG_VERSION}\"/g" share/const.go + grep 'const VERSION' share/const.go + + make tools && make artifacts-linux + mv /app/yao/dist/release/* /data/ ls -l /data - name: Push To R2 @@ -66,8 +98,13 @@ jobs: - name: Get Version id: version run: | - VERSION=$(grep 'const VERSION =' share/const.go | awk '{print $4}' | sed 's/"//g') + if [[ "$GITHUB_REF" != refs/tags/v* ]]; then + echo "::error::This workflow requires a tag (refs/tags/v*). Got: $GITHUB_REF" + exit 1 + fi + VERSION="${GITHUB_REF#refs/tags/v}" echo "version=${VERSION}" >> $GITHUB_OUTPUT + echo "VERSION=${VERSION}" - name: Set up QEMU uses: docker/setup-qemu-action@v3 diff --git a/.github/workflows/release-macos.yml b/.github/workflows/release-macos.yml index 69748d1c..68e07d51 100644 --- a/.github/workflows/release-macos.yml +++ b/.github/workflows/release-macos.yml @@ -93,6 +93,18 @@ jobs: - name: Checkout Yao uses: actions/checkout@v4 + - name: Set Version from Tag + run: | + if [[ "$GITHUB_REF" != refs/tags/v* ]]; then + echo "::error::This workflow requires a tag (refs/tags/v*). Got: $GITHUB_REF" + exit 1 + fi + TAG="${GITHUB_REF#refs/tags/v}" + echo "Setting VERSION to $TAG" + sed -i.bak "s/const VERSION = \".*\"/const VERSION = \"${TAG}\"/g" share/const.go + rm -f share/const.go.bak + grep 'const VERSION' share/const.go + - name: Setup Go uses: actions/setup-go@v5 with: diff --git a/.github/workflows/release.yml b/.github/workflows/release.yml index f955ccf7..030a7600 100644 --- a/.github/workflows/release.yml +++ b/.github/workflows/release.yml @@ -26,9 +26,10 @@ jobs: id: version run: | TAG="${{ github.event.workflow_run.head_branch }}" - VERSION=$(grep 'const VERSION =' share/const.go | awk '{print $4}' | sed 's/"//g') + VERSION="${TAG#v}" echo "version=${VERSION}" >> $GITHUB_OUTPUT echo "tag=${TAG}" >> $GITHUB_OUTPUT + echo "TAG=${TAG} VERSION=${VERSION}" - name: Wait for Both Workflows env: