谁会CI帮我下我要死了 4

This commit is contained in:
2026-01-03 12:10:34 +08:00
parent e14c86744f
commit 8c21113917

View File

@@ -1,64 +1,77 @@
steps: steps:
- name: build-cross
image: "ubuntu:24.04" # -------------------------------
shell: /bin/bash # 强制 bash避免 dash 解析错误 # Linux Build
when: # -------------------------------
event: - name: build-linux
- push image: ubuntu:24.04
- tag shell: /bin/sh
commands: commands:
# 1⃣ 国内源加速 # 安装依赖
- cp /etc/apt/sources.list /etc/apt/sources.list.backup
- |
cat <<EOF > /etc/apt/sources.list
deb https://mirrors.tuna.tsinghua.edu.cn/ubuntu/ $(lsb_release -cs) main restricted universe multiverse
deb https://mirrors.tuna.tsinghua.edu.cn/ubuntu/ $(lsb_release -cs)-updates main restricted universe multiverse
deb https://mirrors.tuna.tsinghua.edu.cn/ubuntu/ $(lsb_release -cs)-security main restricted universe multiverse
deb https://mirrors.tuna.tsinghua.edu.cn/ubuntu/ $(lsb_release -cs)-backports main restricted universe multiverse
EOF
- apt-get update -y - apt-get update -y
- apt-get install -y curl git build-essential clang llvm mingw-w64 ninja-build jq - apt-get install -y git build-essential curl
# 2⃣ 下载并安装 xmake 到全局 PATH稳定 # 安装 xmake
- curl -fsSL https://xmake.io/shget.text -o /tmp/xmake-get.sh - git clone --depth=1 https://github.com/xmake-io/xmake.git /tmp/xmake
- chmod +x /tmp/xmake-get.sh - cd /tmp/xmake && make install PREFIX=/usr/local
- bash /tmp/xmake-get.sh --install-to=/usr/local/bin - xmake --version
# 3⃣ 获取真实版本号 # 构建项目
- VERSION=$(git describe --tags --always --dirty) - cd /woodpecker/src
- xmake f -p linux -a x86_64 -m release -y
- xmake build -y
# 4⃣ Linux 构建 # 获取版本号
- xmake f -m release - VERSION=$(grep -R "__FCORE_VERSION" src/Core/core.hpp | sed -E 's/.*"(.+)".*/\1/')
- xmake -v
- mkdir -p dist
- cp `xmake u -o`/Fig dist/Fig-${VERSION}-linux-x86_64
# 5⃣ Windows cross-build # 生成文件名
- xmake f -m release --plat=windows --arch=x86_64 --cc=x86_64-w64-mingw32-g++ --cxx=x86_64-w64-mingw32-g++ - cp build/linux/x86_64/release/Fig Fig-${VERSION}-linux-x86_64
- xmake -v
- cp `xmake u -o`/Fig.exe dist/Fig-${VERSION}-windows-x86_64.exe
- name: gitea-release # 上传到 Gitea Release
image: "ubuntu:24.04" - |
shell: /bin/bash if [ -n "$GITEA_TOKEN" ]; then
when: curl -X POST "https://git.fig-lang.cn/api/v1/repos/PuqiAR/Fig/releases" \
event: -H "Authorization: token $GITEA_TOKEN" \
- tag -F "tag_name=${VERSION}" \
environment: -F "name=Fig-${VERSION}-linux-x86_64" \
GITEA_TOKEN: -F "body=Linux x86_64 release" \
from_secret: GITEA_TOKEN -F "assets=@Fig-${VERSION}-linux-x86_64"
fi
# -------------------------------
# Windows Build (cross compile)
# -------------------------------
- name: build-windows
image: ubuntu:24.04
shell: /bin/sh
commands: commands:
- TAG=$(git describe --tags --exact-match 2>/dev/null || echo ${DRONE_TAG}) # 安装依赖
- echo "Uploading Fig binaries for tag $TAG to Gitea" - apt-get update -y
- apt-get install -y git build-essential curl mingw-w64
# Linux binary # 安装 xmake
- | - git clone --depth=1 https://github.com/xmake-io/xmake.git /tmp/xmake
curl -X POST -H "Authorization: token ${GITEA_TOKEN}" \ - cd /tmp/xmake && make install PREFIX=/usr/local
-F "name=Fig-${TAG}-linux-x86_64" -F "file=@dist/Fig-${TAG}-linux-x86_64" \ - xmake --version
"https://git.fig-lang.cn/api/v1/repos/PuqiAR/Fig/releases/${TAG}/assets"
# Windows binary # 构建项目
- cd /woodpecker/src
- xmake f -p mingw -a x86_64 -m release -y
- xmake build -y
# 获取版本号
- VERSION=$(grep -R "__FCORE_VERSION" src/Core/core.hpp | sed -E 's/.*"(.+)".*/\1/')
# 生成文件名
- cp build/mingw/x86_64/release/Fig.exe Fig-${VERSION}-windows-x86_64.exe
# 上传到 Gitea Release
- | - |
curl -X POST -H "Authorization: token ${GITEA_TOKEN}" \ if [ -n "$GITEA_TOKEN" ]; then
-F "name=Fig-${TAG}-windows-x86_64.exe" -F "file=@dist/Fig-${TAG}-windows-x86_64.exe" \ curl -X POST "https://git.fig-lang.cn/api/v1/repos/PuqiAR/Fig/releases" \
"https://git.fig-lang.cn/api/v1/repos/PuqiAR/Fig/releases/${TAG}/assets" -H "Authorization: token $GITEA_TOKEN" \
-F "tag_name=${VERSION}" \
-F "name=Fig-${VERSION}-windows-x86_64.exe" \
-F "body=Windows x86_64 release" \
-F "assets=@Fig-${VERSION}-windows-x86_64.exe"
fi