This commit is contained in:
2026-01-02 17:37:00 +08:00
parent a1aea72a45
commit f3492a4d28

View File

@@ -1,75 +1,48 @@
# Woodpecker CI for Fig project
# WSL2 Docker Runner, Linux + Windows cross compile
# 国内源 + apt cache
volumes:
- type: cache
name: apt-cache
path: /var/cache/apt
steps: steps:
- name: build-cross - name: build-cross
image: "ubuntu:24.04" image: "ubuntu:24.04"
environment:
# 如果你想加任何环境变量可以在这里,不留空
SHELL: "/bin/bash"
volumes: volumes:
- type: cache - "/var/cache/apt:/var/cache/apt"
name: apt-cache
path: /var/cache/apt
commands: commands:
# 使用国内源加速 - cp /etc/apt/sources.list /etc/apt/sources.list.backup
- cp /etc/apt/sources.list /etc/apt/sources.list.bak
- | - |
cat << EOF > /etc/apt/sources.list 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) 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)-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)-security main restricted universe multiverse
deb https://mirrors.tuna.tsinghua.edu.cn/ubuntu/ $(lsb_release -cs)-backports main restricted universe multiverse deb https://mirrors.tuna.tsinghua.edu.cn/ubuntu/ $(lsb_release -cs)-backports main restricted universe multiverse
EOF 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 curl git build-essential clang llvm mingw-w64 ninja-build jq
# 安装 xmake
- curl -fsSL https://xmake.io/shget.text | bash - curl -fsSL https://xmake.io/shget.text | bash
- export PATH=$PATH:/root/.xmake/bin - export PATH=$PATH:/root/.xmake/bin
# Linux build
# 构建 Linux release
- xmake f -m release - xmake f -m release
- xmake -v - xmake -v
- mkdir -p dist - mkdir -p dist
- cp `xmake u -o`/Fig dist/Fig-linux - cp `xmake u -o`/Fig dist/Fig-linux
# Windows cross-build
# 构建 Windows release
- xmake f -m release --plat=windows --arch=x86_64 --cc=x86_64-w64-mingw32-g++ --cxx=x86_64-w64-mingw32-g++ - xmake f -m release --plat=windows --arch=x86_64 --cc=x86_64-w64-mingw32-g++ --cxx=x86_64-w64-mingw32-g++
- xmake -v - xmake -v
- cp `xmake u -o`/Fig.exe dist/Fig-windows.exe - cp `xmake u -o`/Fig.exe dist/Fig-windows.exe
- name: gitea-release - name: upload-release
image: "ubuntu:24.04" image: "ubuntu:24.04"
volumes:
- type: cache
name: apt-cache
path: /var/cache/apt
when:
event: tag
environment: environment:
GITEA_TOKEN: GITEA_TOKEN:
from_secret: GITEA_TOKEN from_secret: GITEA_TOKEN
GITEA_REPO: "PuqiAR/Fig" when:
GITEA_URL: "https://git.fig-lang.cn" event: tag
commands: commands:
- TAG_NAME=${DRONE_TAG} - TAG=${DRONE_TAG}
- echo "Uploading Fig binaries for tag $TAG_NAME to Gitea"
# Linux binary
- | - |
curl -X POST -H "Authorization: token $GITEA_TOKEN" \ curl -X POST -H "Authorization: token ${GITEA_TOKEN}" \
-F "name=Fig-linux" \ -F "name=Fig-linux" -F "file=@dist/Fig-linux" \
-F "label=Fig Linux binary" \ "https://git.fig-lang.cn/api/v1/repos/PuqiAR/Fig/releases/${TAG}/assets"
-F "file=@dist/Fig-linux" \
"$GITEA_URL/api/v1/repos/$GITEA_REPO/releases/$TAG_NAME/assets"
# Windows binary
- | - |
curl -X POST -H "Authorization: token $GITEA_TOKEN" \ curl -X POST -H "Authorization: token ${GITEA_TOKEN}" \
-F "name=Fig-windows.exe" \ -F "name=Fig-windows.exe" -F "file=@dist/Fig-windows.exe" \
-F "label=Fig Windows binary" \ "https://git.fig-lang.cn/api/v1/repos/PuqiAR/Fig/releases/${TAG}/assets"
-F "file=@dist/Fig-windows.exe" \
"$GITEA_URL/api/v1/repos/$GITEA_REPO/releases/$TAG_NAME/assets"