action! 我不认输4

This commit is contained in:
2026-01-03 15:46:27 +08:00
parent 0da8453014
commit ad0e84b0bc

View File

@@ -12,29 +12,22 @@ jobs:
build: build:
runs-on: ubuntu runs-on: ubuntu
container: container:
image: debian:bookworm-slim # 自带bash和apt比Alpine简单 image: ubuntu:22.04 # 自带gcc, g++, make, curl, git
steps: steps:
# 1. 更新并安装最小工具 # 1. 只安装xmake系统已有其他工具
- name: 安装工具
run: |
apt-get update
apt-get install -y --no-install-recommends curl ca-certificates git make gcc g++
apt-get clean
# 2. 安装xmake官方方式
- name: 安装xmake - name: 安装xmake
run: | run: |
bash <(curl -fsSL https://xmake.io/shget.text) bash <(curl -fsSL https://xmake.io/shget.text)
echo "/root/.local/bin" >> $GITHUB_PATH echo "$HOME/.local/bin" >> $GITHUB_PATH
# 3. 检出代码 # 2. 检出代码
- name: 检出代码 - name: 检出代码
run: | run: |
git clone https://git.fig-lang.cn/${{ github.repository }} . git clone https://git.fig-lang.cn/${{ github.repository }} .
git checkout ${{ github.ref }} git checkout ${{ github.ref }}
# 4. 设置版本 # 3. 设置版本
- name: 设置版本 - name: 设置版本
run: | run: |
if [ "${{ github.event_name }}" = "workflow_dispatch" ]; then if [ "${{ github.event_name }}" = "workflow_dispatch" ]; then
@@ -43,19 +36,18 @@ jobs:
VERSION="${GITHUB_REF#refs/tags/}" VERSION="${GITHUB_REF#refs/tags/}"
fi fi
echo "VERSION=$VERSION" >> $GITHUB_ENV echo "VERSION=$VERSION" >> $GITHUB_ENV
echo "构建版本: $VERSION"
# 5. 构建 # 4. 构建
- name: 构建 - name: 构建
run: | run: |
export PATH="/root/.local/bin:$PATH" export PATH="$HOME/.local/bin:$PATH"
xmake f -p linux -a x86_64 -m release -y xmake f -p linux -a x86_64 -m release -y
xmake build -j$(nproc) xmake build -j$(nproc)
# 6. 打包 # 5. 打包
- name: 打包 - name: 打包
run: | run: |
export PATH="/root/.local/bin:$PATH" export PATH="$HOME/.local/bin:$PATH"
DIR="Fig-${{ env.VERSION }}-linux-x86_64" DIR="Fig-${{ env.VERSION }}-linux-x86_64"
mkdir -p "$DIR" mkdir -p "$DIR"
cp build/linux/x86_64/release/Fig "$DIR/" cp build/linux/x86_64/release/Fig "$DIR/"
@@ -63,30 +55,25 @@ jobs:
tar -czf "$DIR.tar.gz" "$DIR" tar -czf "$DIR.tar.gz" "$DIR"
sha256sum "$DIR.tar.gz" > "$DIR.sha256" sha256sum "$DIR.tar.gz" > "$DIR.sha256"
# 7. 发布 # 6. 发布
- name: 发布 - name: 发布
env: env:
TOKEN: ${{ secrets.CI_TOKEN }} TOKEN: ${{ secrets.CI_TOKEN }}
run: | run: |
export PATH="/root/.local/bin:$PATH" export PATH="$HOME/.local/bin:$PATH"
VERSION="${{ env.VERSION }}" VERSION="${{ env.VERSION }}"
API="https://git.fig-lang.cn/api/v1/repos/${{ github.repository }}" API="https://git.fig-lang.cn/api/v1/repos/${{ github.repository }}"
# 创建发布
curl -sS -X POST -H "Authorization: token $TOKEN" \ curl -sS -X POST -H "Authorization: token $TOKEN" \
-H "Content-Type: application/json" \
-d "{\"tag_name\":\"$VERSION\"}" \ -d "{\"tag_name\":\"$VERSION\"}" \
"$API/releases" 2>/dev/null || true "$API/releases" 2>/dev/null || true
# 上传文件
curl -sS -X POST -H "Authorization: token $TOKEN" \ curl -sS -X POST -H "Authorization: token $TOKEN" \
-H "Content-Type: application/octet-stream" \
--data-binary @Fig-$VERSION-linux-x86_64.tar.gz \ --data-binary @Fig-$VERSION-linux-x86_64.tar.gz \
"$API/releases/$VERSION/assets?name=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 $TOKEN" \ curl -sS -X POST -H "Authorization: token $TOKEN" \
-H "Content-Type: text/plain" \
--data-binary @Fig-$VERSION-linux-x86_64.sha256 \ --data-binary @Fig-$VERSION-linux-x86_64.sha256 \
"$API/releases/$VERSION/assets?name=Fig-$VERSION-linux-x86_64.sha256" "$API/releases/$VERSION/assets?name=Fig-$VERSION-linux-x86_64.sha256"
echo "✅ 完成!版本: $VERSION" echo "✅ 完成!"