yao/.github/workflows/release-linux.yml
Max ee48f3a946 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
2026-03-16 09:40:36 +08:00

143 lines
4.7 KiB
YAML

name: Release Linux
on:
workflow_dispatch:
push:
tags:
- "v*"
permissions:
contents: write
env:
IMAGE_NAME: yaoapp/yao
jobs:
# ===================================================================
# Build Linux Binaries (amd64 + arm64)
# ===================================================================
build:
runs-on: ubuntu-latest
container:
image: yaoapp/yao-build:1.0.0
env:
CF_ACCESS_KEY_ID: ${{ secrets.CF_ACCESS_KEY_ID }}
CF_SECRET_ACCESS_KEY: ${{ secrets.CF_SECRET_ACCESS_KEY }}
R2_BUCKET: ${{ secrets.R2_BUCKET }}
R2_ACCOUNT_ID: ${{ secrets.R2_ACCOUNT_ID }}
steps:
- name: Configure R2 For Cloudflare
run: |
aws configure set aws_access_key_id $CF_ACCESS_KEY_ID
aws configure set aws_secret_access_key $CF_SECRET_ACCESS_KEY
aws configure set default.region us-east-1
aws configure set default.s3.signature_version s3v4
aws configure set default.s3.endpoint_url https://$R2_ACCOUNT_ID.r2.cloudflarestorage.com
- name: Build
run: |
export PATH=$PATH:/github/home/go/bin
# 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
run: |
for file in /data/*; do
aws s3 cp "$file" s3://$R2_BUCKET/archives/ \
--endpoint-url https://$R2_ACCOUNT_ID.r2.cloudflarestorage.com
done
- name: Upload Artifact
uses: actions/upload-artifact@v4
with:
name: yao-linux
path: /data/*
# ===================================================================
# Docker Images (multi-arch manifest: linux/amd64 + linux/arm64)
# ===================================================================
docker:
needs: build
runs-on: ubuntu-latest
steps:
- name: Checkout Code
uses: actions/checkout@v4
- name: Get Version
id: version
run: |
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
- name: Set up Docker Buildx
uses: docker/setup-buildx-action@v3
- name: Login to DockerHub
uses: docker/login-action@v3
with:
username: ${{ secrets.DOCKER_USER }}
password: ${{ secrets.DOCKER_TOKEN }}
- name: Build & Push Development (multi-arch)
uses: docker/build-push-action@v6
with:
context: ./docker/development
platforms: linux/amd64,linux/arm64
build-args: |
VERSION=${{ steps.version.outputs.version }}
push: true
tags: |
${{ env.IMAGE_NAME }}:${{ steps.version.outputs.version }}-dev
${{ env.IMAGE_NAME }}:dev
- name: Build & Push Production (multi-arch)
uses: docker/build-push-action@v6
with:
context: ./docker/production
platforms: linux/amd64,linux/arm64
build-args: |
VERSION=${{ steps.version.outputs.version }}
push: true
tags: |
${{ env.IMAGE_NAME }}:${{ steps.version.outputs.version }}
${{ env.IMAGE_NAME }}:latest