# .woodpecker.yml kind: pipeline type: docker name: Fig CI clone: disable: false steps: - name: setup-deps image: ubuntu:24.04 commands: | apt-get update -y DEBIAN_FRONTEND=noninteractive apt-get install -y \ build-essential git curl wget python3 python3-pip unzip zip mingw-w64 xz-utils - name: install-xmake image: ubuntu:24.04 commands: | curl -fsSL https://xmake.io/shget.text | bash export PATH=$HOME/.xmake/bin:$PATH xmake --version - name: build-linux image: ubuntu:24.04 environment: TAG_VERSION: ${DRONE_TAG#v} commands: | export PATH=$HOME/.xmake/bin:$PATH xmake f -m release xmake build mkdir -p release mv build/ Fig-${TAG_VERSION}-linux-x86_64 - name: build-windows image: ubuntu:24.04 environment: TAG_VERSION: ${DRONE_TAG#v} commands: | export PATH=$HOME/.xmake/bin:$PATH xmake f -m release --plat=mingw --arch=x86_64 xmake build mkdir -p release mv build/ Fig-${TAG_VERSION}-windows-x86_64.exe - name: release image: alpine:latest environment: GITEA_TOKEN: from_secret: GITEA_TOKEN TAG_VERSION: ${DRONE_TAG#v} commands: | apk add --no-cache curl jq # 检查 release 是否存在 RELEASE_JSON=$(curl -s -H "Authorization: token ${GITEA_TOKEN}" \ "https://git.fig-lang.cn/api/v1/repos/PuqiAR/Fig/releases/tags/${TAG_VERSION}" || true) if [ "$(echo "$RELEASE_JSON" | jq -r .id)" = "null" ]; then curl -s -X POST -H "Content-Type: application/json" \ -H "Authorization: token ${GITEA_TOKEN}" \ -d "{\"tag_name\":\"${DRONE_TAG}\",\"name\":\"${TAG_VERSION}\",\"draft\":false,\"prerelease\":false}" \ https://git.fig-lang.cn/api/v1/repos/PuqiAR/Fig/releases fi # 获取 release id RELEASE_ID=$(curl -s -H "Authorization: token ${GITEA_TOKEN}" \ "https://git.fig-lang.cn/api/v1/repos/PuqiAR/Fig/releases/tags/${TAG_VERSION}" | jq -r .id) # 上传资产 curl -X POST -H "Content-Type: multipart/form-data" \ -F "file=@release/Fig-${TAG_VERSION}-linux-x86_64" \ -H "Authorization: token ${GITEA_TOKEN}" \ "https://git.fig-lang.cn/api/v1/repos/PuqiAR/Fig/releases/${RELEASE_ID}/assets" curl -X POST -H "Content-Type: multipart/form-data" \ -F "file=@release/Fig-${TAG_VERSION}-windows-x86_64.exe" \ -H "Authorization: token ${GITEA_TOKEN}" \ "https://git.fig-lang.cn/api/v1/repos/PuqiAR/Fig/releases/${RELEASE_ID}/assets" trigger: event: - tag