Files
Fig-TreeWalker/.gitea/workflows/build.yml

75 lines
2.8 KiB
YAML
Raw Blame History

This file contains ambiguous Unicode characters

This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

name: Release Build
on:
push:
tags: ['*']
workflow_dispatch:
inputs:
version:
description: '版本号 (例如: v1.0.0)'
required: true
default: 'dev-build'
jobs:
build-linux-x64:
runs-on: ubuntu
# 关键:不要写 container让任务直接在宿主机上执行
steps:
# 1. 直接使用本地镜像运行构建
- name: 在自定义镜像中构建
run: |
# 使用本地镜像启动容器,执行所有构建步骤
docker run --rm \
-v $PWD:/workspace \
-w /workspace \
git.fig-lang.cn/puqiar/fig-ci:base-latest \
bash -c "
# 克隆代码(容器内)
git clone 'https://git.fig-lang.cn/${{ github.repository }}' . && \
git checkout '${{ github.ref }}' && \
# 设置版本号
if [ '${{ github.event_name }}' = 'workflow_dispatch' ]; then
VERSION='${{ inputs.version }}'
else
VERSION='${GITHUB_REF#refs/tags/}'
fi && \
echo \"版本: \$VERSION\" && \
# 构建
xmake f -p linux -a x86_64 -m release -y && \
xmake build -j\$(nproc) && \
# 打包
PACKAGE_NAME=\"Fig-\$VERSION-linux-x86_64\" && \
mkdir -p \"\${PACKAGE_NAME}\" && \
cp build/linux/x86_64/release/Fig \"\${PACKAGE_NAME}/\" && \
tar -czf \"\${PACKAGE_NAME}.tar.gz\" \"\${PACKAGE_NAME}\" && \
sha256sum \"\${PACKAGE_NAME}.tar.gz\" > \"\${PACKAGE_NAME}.sha256\" && \
echo \"构建完成\"
"
# 2. 发布(在宿主机上执行,因为打包好的文件在宿主机目录里)
- name: 发布到Gitea
env:
GITEA_TOKEN: ${{ secrets.CI_TOKEN }}
run: |
# 确定版本号(逻辑和上面一样)
if [ '${{ github.event_name }}' = 'workflow_dispatch' ]; then
VERSION='${{ inputs.version }}'
else
VERSION='${GITHUB_REF#refs/tags/}'
fi
API=\"https://git.fig-lang.cn/api/v1/repos/${{ github.repository }}\"
# 上传发布包
curl -sS -X POST -H \"Authorization: token $GITEA_TOKEN\" \
-H \"Content-Type: application/octet-stream\" \
--data-binary @Fig-\$VERSION-linux-x86_64.tar.gz \
\"\$API/releases/\$VERSION/assets?name=Fig-\$VERSION-linux-x86_64.tar.gz\"
# 上传校验文件
curl -sS -X POST -H \"Authorization: token $GITEA_TOKEN\" \
-H \"Content-Type: text/plain\" \
--data-binary @Fig-\$VERSION-linux-x86_64.sha256 \
\"\$API/releases/\$VERSION/assets?name=Fig-\$VERSION-linux-x86_64.sha256\"
echo \"✅ 发布完成!\"