Give gitea action a try
This commit is contained in:
104
.gitea/workflows/release.yml
Normal file
104
.gitea/workflows/release.yml
Normal file
@@ -0,0 +1,104 @@
|
|||||||
|
name: Release Build
|
||||||
|
on:
|
||||||
|
push:
|
||||||
|
tags: ['v*']
|
||||||
|
workflow_dispatch:
|
||||||
|
inputs:
|
||||||
|
version:
|
||||||
|
description: '版本号 (如: 1.0.0)'
|
||||||
|
required: true
|
||||||
|
|
||||||
|
env:
|
||||||
|
VERSION: ${{ github.event.inputs.version || github.ref_name }}
|
||||||
|
|
||||||
|
jobs:
|
||||||
|
build:
|
||||||
|
strategy:
|
||||||
|
matrix:
|
||||||
|
include:
|
||||||
|
- platform: linux
|
||||||
|
arch: x86_64
|
||||||
|
runner: ubuntu-latest
|
||||||
|
- platform: linux
|
||||||
|
arch: aarch64
|
||||||
|
runner: ubuntu-22.04-arm
|
||||||
|
- platform: windows
|
||||||
|
arch: x86_64
|
||||||
|
runner: windows-latest
|
||||||
|
- platform: macos
|
||||||
|
arch: x86_64
|
||||||
|
runner: macos-12
|
||||||
|
- platform: macos
|
||||||
|
arch: arm64
|
||||||
|
runner: macos-14
|
||||||
|
|
||||||
|
runs-on: ${{ matrix.runner }}
|
||||||
|
|
||||||
|
steps:
|
||||||
|
- uses: actions/checkout@v3
|
||||||
|
with:
|
||||||
|
fetch-depth: 0
|
||||||
|
|
||||||
|
- name: Install xmake
|
||||||
|
run: |
|
||||||
|
curl -fsSL https://xmake.io/shget.text | bash
|
||||||
|
echo "$HOME/.local/bin" >> $GITHUB_PATH
|
||||||
|
|
||||||
|
- name: Configure
|
||||||
|
run: |
|
||||||
|
if [ "${{ matrix.platform }}" = "windows" ]; then
|
||||||
|
xmake f -p mingw -a ${{ matrix.arch }} -m release
|
||||||
|
else
|
||||||
|
xmake f -p ${{ matrix.platform }} -a ${{ matrix.arch }} -m release
|
||||||
|
fi
|
||||||
|
|
||||||
|
- name: Build
|
||||||
|
run: xmake -j4
|
||||||
|
|
||||||
|
- name: Create Package
|
||||||
|
run: |
|
||||||
|
mkdir -p Fig-${{ env.VERSION }}-${{ matrix.platform }}-${{ matrix.arch }}
|
||||||
|
# 复制可执行文件
|
||||||
|
if [ "${{ matrix.platform }}" = "windows" ]; then
|
||||||
|
cp build/mingw/${{ matrix.arch }}/release/Fig.exe Fig-${{ env.VERSION }}-${{ matrix.platform }}-${{ matrix.arch }}/
|
||||||
|
else
|
||||||
|
cp build/${{ matrix.platform }}/${{ matrix.arch }}/release/Fig Fig-${{ env.VERSION }}-${{ matrix.platform }}-${{ matrix.arch }}/
|
||||||
|
fi
|
||||||
|
# 复制 Library 目录
|
||||||
|
cp -r src/Module/Library Fig-${{ env.VERSION }}-${{ matrix.platform }}-${{ matrix.arch }}/
|
||||||
|
|
||||||
|
# 创建压缩包
|
||||||
|
if [ "${{ matrix.platform }}" = "windows" ]; then
|
||||||
|
zip -r Fig-${{ env.VERSION }}-${{ matrix.platform }}-${{ matrix.arch }}.zip Fig-${{ env.VERSION }}-${{ matrix.platform }}-${{ matrix.arch }}
|
||||||
|
else
|
||||||
|
tar -czf Fig-${{ env.VERSION }}-${{ matrix.platform }}-${{ matrix.arch }}.tar.gz Fig-${{ env.VERSION }}-${{ matrix.platform }}-${{ matrix.arch }}
|
||||||
|
fi
|
||||||
|
|
||||||
|
# 生成 checksum
|
||||||
|
sha256sum Fig-${{ env.VERSION }}-*.tar.gz Fig-${{ env.VERSION }}-*.zip 2>/dev/null | grep -v "No such file" > checksums.txt || true
|
||||||
|
|
||||||
|
- name: Upload Artifacts
|
||||||
|
uses: actions/upload-artifact@v3
|
||||||
|
with:
|
||||||
|
name: binaries-${{ matrix.platform }}-${{ matrix.arch }}
|
||||||
|
path: |
|
||||||
|
Fig-${{ env.VERSION }}-${{ matrix.platform }}-${{ matrix.arch }}.*
|
||||||
|
checksums.txt
|
||||||
|
|
||||||
|
release:
|
||||||
|
needs: build
|
||||||
|
runs-on: ubuntu-latest
|
||||||
|
if: startsWith(github.ref, 'refs/tags/')
|
||||||
|
|
||||||
|
steps:
|
||||||
|
- name: Download all artifacts
|
||||||
|
uses: actions/download-artifact@v3
|
||||||
|
|
||||||
|
- name: Create Release
|
||||||
|
uses: softprops/action-gh-release@v1
|
||||||
|
with:
|
||||||
|
files: |
|
||||||
|
**/*.tar.gz
|
||||||
|
**/*.zip
|
||||||
|
**/checksums.txt
|
||||||
|
generate_release_notes: true
|
||||||
@@ -1,83 +0,0 @@
|
|||||||
# .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
|
|
||||||
14
xmake.lua
14
xmake.lua
@@ -9,14 +9,20 @@ target("Fig")
|
|||||||
|
|
||||||
if is_plat("windows") then
|
if is_plat("windows") then
|
||||||
set_plat("mingw")
|
set_plat("mingw")
|
||||||
|
add_cxxflags("-static")
|
||||||
|
add_ldflags("-Wl,--stack,268435456")
|
||||||
|
|
||||||
|
elseif is_plat("linux") then
|
||||||
|
add_ldflags("-static-libstdc++", "-static-libgcc")
|
||||||
end
|
end
|
||||||
|
|
||||||
if is_plat("mingw") then
|
if is_plat("windows") then
|
||||||
add_cxxflags("-static")
|
set_filename("Fig.exe")
|
||||||
add_cxxflags("-stdlib=libc++")
|
else
|
||||||
add_ldflags("-Wl,--stack,268435456")
|
set_filename("Fig")
|
||||||
end
|
end
|
||||||
|
|
||||||
|
|
||||||
add_files("src/main.cpp")
|
add_files("src/main.cpp")
|
||||||
add_files("src/Core/warning.cpp")
|
add_files("src/Core/warning.cpp")
|
||||||
add_files("src/Evaluator/evaluator.cpp")
|
add_files("src/Evaluator/evaluator.cpp")
|
||||||
|
|||||||
Reference in New Issue
Block a user