forked from PuqiAR/Fig-TreeWalker
谁会CI帮我下我要死了 7
This commit is contained in:
103
.woodpecker.yml
103
.woodpecker.yml
@@ -1,70 +1,83 @@
|
|||||||
# .woodpecker.yml
|
# .woodpecker.yml
|
||||||
# Auto-build Fig only on new git tags
|
|
||||||
# Linux + Windows cross-build using xmake
|
|
||||||
# Output files: Fig-version-plat-arch
|
|
||||||
# Upload release to Gitea automatically
|
|
||||||
|
|
||||||
kind: pipeline
|
kind: pipeline
|
||||||
name: tag-build
|
type: docker
|
||||||
|
name: Fig CI
|
||||||
|
|
||||||
trigger:
|
clone:
|
||||||
event:
|
disable: false
|
||||||
- tag # 只在 tag 创建时触发
|
|
||||||
|
|
||||||
steps:
|
steps:
|
||||||
- name: setup
|
- name: setup-deps
|
||||||
image: ubuntu:24.04
|
image: ubuntu:24.04
|
||||||
shell: /bin/sh
|
commands: |
|
||||||
commands:
|
apt-get update -y
|
||||||
- apt-get update -y
|
DEBIAN_FRONTEND=noninteractive apt-get install -y \
|
||||||
- DEBIAN_FRONTEND=noninteractive apt-get install -y git curl build-essential mingw-w64 python3 zip
|
build-essential git curl wget python3 python3-pip unzip zip mingw-w64 xz-utils
|
||||||
- curl -fsSL https://xmake.io/shget.text | bash
|
|
||||||
- export PATH=$HOME/.xmake/bin:$PATH
|
- name: install-xmake
|
||||||
- xmake --version
|
image: ubuntu:24.04
|
||||||
|
commands: |
|
||||||
|
curl -fsSL https://xmake.io/shget.text | bash
|
||||||
|
export PATH=$HOME/.xmake/bin:$PATH
|
||||||
|
xmake --version
|
||||||
|
|
||||||
- name: build-linux
|
- name: build-linux
|
||||||
image: ubuntu:24.04
|
image: ubuntu:24.04
|
||||||
shell: /bin/sh
|
environment:
|
||||||
commands:
|
TAG_VERSION: ${DRONE_TAG#v}
|
||||||
- export PATH=$HOME/.xmake/bin:$PATH
|
commands: |
|
||||||
- TAG_VERSION=${DRONE_TAG#v} # 去掉前缀 v
|
export PATH=$HOME/.xmake/bin:$PATH
|
||||||
- xmake f -p linux -a x86_64 -m release -y
|
xmake f -m release
|
||||||
- xmake b -y
|
xmake build
|
||||||
- mv build/linux/x86_64/release/Fig "Fig-${TAG_VERSION}-linux-x86_64"
|
mkdir -p release
|
||||||
|
mv build/ Fig-${TAG_VERSION}-linux-x86_64
|
||||||
|
|
||||||
- name: build-windows
|
- name: build-windows
|
||||||
image: ubuntu:24.04
|
image: ubuntu:24.04
|
||||||
shell: /bin/sh
|
environment:
|
||||||
commands:
|
TAG_VERSION: ${DRONE_TAG#v}
|
||||||
- export PATH=$HOME/.xmake/bin:$PATH
|
commands: |
|
||||||
- TAG_VERSION=${DRONE_TAG#v}
|
export PATH=$HOME/.xmake/bin:$PATH
|
||||||
- xmake f -p mingw -a x86_64 -m release -y
|
xmake f -m release --plat=mingw --arch=x86_64
|
||||||
- xmake b -y
|
xmake build
|
||||||
- mv build/mingw/x86_64/release/Fig.exe "Fig-${TAG_VERSION}-windows-x86_64.exe"
|
mkdir -p release
|
||||||
|
mv build/ Fig-${TAG_VERSION}-windows-x86_64.exe
|
||||||
|
|
||||||
- name: release
|
- name: release
|
||||||
image: alpine:latest
|
image: alpine:latest
|
||||||
shell: /bin/sh
|
environment:
|
||||||
commands:
|
GITEA_TOKEN:
|
||||||
- apk add --no-cache curl jq
|
from_secret: GITEA_TOKEN
|
||||||
- TAG_VERSION=${DRONE_TAG#v}
|
TAG_VERSION: ${DRONE_TAG#v}
|
||||||
# 获取 Gitea release ID,如果没有就创建
|
commands: |
|
||||||
- RELEASE_JSON=$(curl -s -H "Authorization: token ${GITEA_TOKEN}" \
|
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)
|
"https://git.fig-lang.cn/api/v1/repos/PuqiAR/Fig/releases/tags/${TAG_VERSION}" || true)
|
||||||
- if [ "$(echo "$RELEASE_JSON" | jq -r .id)" = "null" ]; then
|
|
||||||
|
if [ "$(echo "$RELEASE_JSON" | jq -r .id)" = "null" ]; then
|
||||||
curl -s -X POST -H "Content-Type: application/json" \
|
curl -s -X POST -H "Content-Type: application/json" \
|
||||||
-H "Authorization: token ${GITEA_TOKEN}" \
|
-H "Authorization: token ${GITEA_TOKEN}" \
|
||||||
-d "{\"tag_name\":\"${DRONE_TAG}\",\"name\":\"${TAG_VERSION}\",\"draft\":false,\"prerelease\":false}" \
|
-d "{\"tag_name\":\"${DRONE_TAG}\",\"name\":\"${TAG_VERSION}\",\"draft\":false,\"prerelease\":false}" \
|
||||||
https://git.fig-lang.cn/api/v1/repos/PuqiAR/Fig/releases;
|
https://git.fig-lang.cn/api/v1/repos/PuqiAR/Fig/releases
|
||||||
fi
|
fi
|
||||||
- RELEASE_ID=$(curl -s -H "Authorization: token ${GITEA_TOKEN}" \
|
|
||||||
|
# 获取 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)
|
"https://git.fig-lang.cn/api/v1/repos/PuqiAR/Fig/releases/tags/${TAG_VERSION}" | jq -r .id)
|
||||||
# 上传 Linux & Windows 构建产物
|
|
||||||
- curl -X POST -H "Content-Type: multipart/form-data" \
|
# 上传资产
|
||||||
-F "file=@Fig-${TAG_VERSION}-linux-x86_64" \
|
curl -X POST -H "Content-Type: multipart/form-data" \
|
||||||
|
-F "file=@release/Fig-${TAG_VERSION}-linux-x86_64" \
|
||||||
-H "Authorization: token ${GITEA_TOKEN}" \
|
-H "Authorization: token ${GITEA_TOKEN}" \
|
||||||
"https://git.fig-lang.cn/api/v1/repos/PuqiAR/Fig/releases/${RELEASE_ID}/assets"
|
"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=@Fig-${TAG_VERSION}-windows-x86_64.exe" \
|
curl -X POST -H "Content-Type: multipart/form-data" \
|
||||||
|
-F "file=@release/Fig-${TAG_VERSION}-windows-x86_64.exe" \
|
||||||
-H "Authorization: token ${GITEA_TOKEN}" \
|
-H "Authorization: token ${GITEA_TOKEN}" \
|
||||||
"https://git.fig-lang.cn/api/v1/repos/PuqiAR/Fig/releases/${RELEASE_ID}/assets"
|
"https://git.fig-lang.cn/api/v1/repos/PuqiAR/Fig/releases/${RELEASE_ID}/assets"
|
||||||
|
|
||||||
|
trigger:
|
||||||
|
event:
|
||||||
|
- tag
|
||||||
|
|||||||
Reference in New Issue
Block a user