3 Commits

Author SHA1 Message Date
1ccc63419d [VER] v0.3.6-alpha 发布, 完整的Installer已准备!
All checks were successful
Release Build / build-windows-x64 (push) Successful in 58s
Release Build / build-linux-x64 (push) Successful in 1m0s
[w] Change log 在之前的提交
2026-01-04 14:51:32 +08:00
3b5e99242f [Action] 尝试修复win打包计算问题 2026-01-04 14:22:33 +08:00
85bdab5db3 [Action] 重写win发布
Some checks failed
Release Build / build-windows-x64 (push) Failing after 43s
Release Build / build-linux-x64 (push) Successful in 54s
2026-01-04 14:19:38 +08:00
3 changed files with 115 additions and 65 deletions

View File

@@ -61,7 +61,7 @@ jobs:
# 安装依赖并构建 # 安装依赖并构建
pip install --upgrade pip pip install --upgrade pip
pip install -r requirements.txt pip install -r requirements.txt
python3 -m PyInstaller -F -n fig-setup --distpath ./dist/linux main.py python3 -m PyInstaller -F -n FigSetup-Linux --distpath ./dist/linux main.py
echo "Linux安装器构建完成" echo "Linux安装器构建完成"
- name: 打包Linux发布文件 - name: 打包Linux发布文件
@@ -119,12 +119,12 @@ jobs:
"$API/releases/$RELEASE_ID/assets?name=Fig-$VERSION-linux-x86_64.sha256" "$API/releases/$RELEASE_ID/assets?name=Fig-$VERSION-linux-x86_64.sha256"
# 🔧 新增上传Linux安装器 # 🔧 新增上传Linux安装器
if [ -f "Installer/ConsoleInstaller/dist/linux/fig-setup" ]; then if [ -f "Installer/ConsoleInstaller/dist/linux/FigSetup-Linux" ]; then
echo "正在上传Linux安装器..." echo "正在上传Linux安装器..."
curl -sS -X POST -H "Authorization: token $GITEA_TOKEN" \ curl -sS -X POST -H "Authorization: token $GITEA_TOKEN" \
-H "Content-Type: application/octet-stream" \ -H "Content-Type: application/octet-stream" \
--data-binary @Installer/ConsoleInstaller/dist/linux/fig-setup \ --data-binary @Installer/ConsoleInstaller/dist/linux/FigSetup-Linux \
"$API/releases/$RELEASE_ID/assets?name=fig-setup" "$API/releases/$RELEASE_ID/assets?name=FigSetup-Linux"
fi fi
echo "✅ Linux版本发布完成" echo "✅ Linux版本发布完成"
@@ -186,13 +186,16 @@ jobs:
run: | run: |
[Console]::OutputEncoding = [System.Text.Encoding]::UTF8 [Console]::OutputEncoding = [System.Text.Encoding]::UTF8
# 确保版本号不为空 # 🔧 修改:与发布步骤使用相同的版本号计算逻辑
$VERSION = $env:VERSION if ($env:GITHUB_EVENT_NAME -eq 'workflow_dispatch') {
if ([string]::IsNullOrEmpty($VERSION)) { $VERSION = $env:INPUT_VERSION
Write-Host "警告:版本号为空,使用默认值 dev-build" if (-not $VERSION) { $VERSION = "dev-build" }
$VERSION = "dev-build" } else {
$VERSION = $env:GITHUB_REF_NAME
} }
Write-Host "打包版本: $VERSION"
$PACKAGE_NAME = "Fig-${VERSION}-windows-x86_64" $PACKAGE_NAME = "Fig-${VERSION}-windows-x86_64"
Write-Host "打包名称: $PACKAGE_NAME" Write-Host "打包名称: $PACKAGE_NAME"
@@ -242,43 +245,77 @@ jobs:
$API = "https://git.fig-lang.cn/api/v1/repos/$REPO" $API = "https://git.fig-lang.cn/api/v1/repos/$REPO"
$TOKEN = $env:GITEA_TOKEN $TOKEN = $env:GITEA_TOKEN
Write-Host "正在上传Windows版本到发布 $VERSION ..." # 🔧 新增:检查必需的文件是否存在
$ZIP_FILE = "Fig-$VERSION-windows-x86_64.zip"
$HASH_FILE = "Fig-$VERSION-windows-x86_64.sha256"
$INSTALLER_PATH = "Installer\ConsoleInstaller\dist\windows\FigSetup.exe"
# 1. 尝试通过标签获取 Release ID if (-not (Test-Path $ZIP_FILE)) {
$RELEASE_RESPONSE = Invoke-RestMethod -Uri "$API/releases/tags/$VERSION" -Headers @{Authorization = "token $TOKEN" } -ErrorAction SilentlyContinue Write-Host "❌ 错误找不到ZIP文件 $ZIP_FILE"
if ($RELEASE_RESPONSE -and $RELEASE_RESPONSE.id) { Get-ChildItem *.zip
$RELEASE_ID = $RELEASE_RESPONSE.id exit 1
Write-Host "找到已有发布 ID: $RELEASE_ID" }
Write-Host "正在为Windows版本创建/更新发布 $VERSION ..."
# 🔧 关键修改直接创建发布不先检查与Linux逻辑一致
$CREATE_BODY = @{
tag_name = $VERSION
name = "Fig $VERSION"
draft = $false
prerelease = $false
} | ConvertTo-Json -Compress
Write-Host "创建发布请求体: $CREATE_BODY"
# 直接创建发布Gitea会自动处理重复创建
$RESPONSE = Invoke-RestMethod -Method Post -Uri "$API/releases" `
-Headers @{
Authorization = "token $TOKEN"
'Content-Type' = 'application/json'
} -Body $CREATE_BODY -ErrorAction SilentlyContinue
if (-not $RESPONSE -or -not $RESPONSE.id) {
# 如果创建失败尝试通过标签获取已有发布的ID
Write-Host "创建失败,尝试获取已有发布..."
$RESPONSE = Invoke-RestMethod -Uri "$API/releases/tags/$VERSION" `
-Headers @{Authorization = "token $TOKEN" } `
-ErrorAction SilentlyContinue
}
if ($RESPONSE -and $RESPONSE.id) {
$RELEASE_ID = $RESPONSE.id
Write-Host "✅ 使用发布 ID: $RELEASE_ID 进行上传"
} else { } else {
# 如果不存在,则创建发布 Write-Host "❌ 错误:无法获取或创建发布 ID"
Write-Host '发布不存在,正在创建...' exit 1
$CREATE_BODY = @{tag_name = $VERSION; name = "Fig $VERSION"; draft = $false; prerelease = $false } | ConvertTo-Json
$CREATE_RESPONSE = Invoke-RestMethod -Method Post -Uri "$API/releases" -Headers @{Authorization = "token $TOKEN"; 'Content-Type' = 'application/json' } -Body $CREATE_BODY
if ($CREATE_RESPONSE -and $CREATE_RESPONSE.id) {
$RELEASE_ID = $CREATE_RESPONSE.id
Write-Host "创建新发布 ID: $RELEASE_ID"
} else {
Write-Host '错误:无法获取或创建发布'
exit 1
}
} }
# 2. 使用 Release ID 上传资产 # 上传资产
Write-Host '正在上传 ZIP 文件...' Write-Host "正在上传 ZIP 文件..."
Invoke-RestMethod -Method Post -Uri "$API/releases/$RELEASE_ID/assets?name=Fig-$VERSION-windows-x86_64.zip" -Headers @{Authorization = "token $TOKEN"; 'Content-Type' = 'application/octet-stream' } -InFile "Fig-$VERSION-windows-x86_64.zip" Invoke-RestMethod -Method Post -Uri "$API/releases/$RELEASE_ID/assets?name=$ZIP_FILE" `
-Headers @{
Authorization = "token $TOKEN"
'Content-Type' = 'application/octet-stream'
} -InFile $ZIP_FILE -ErrorAction SilentlyContinue
Write-Host '正在上传校验文件...' Write-Host "正在上传校验文件..."
Invoke-RestMethod -Method Post -Uri "$API/releases/$RELEASE_ID/assets?name=Fig-$VERSION-windows-x86_64.sha256" -Headers @{Authorization = "token $TOKEN"; 'Content-Type' = 'text/plain' } -InFile "Fig-$VERSION-windows-x86_64.sha256" Invoke-RestMethod -Method Post -Uri "$API/releases/$RELEASE_ID/assets?name=$HASH_FILE" `
-Headers @{
Authorization = "token $TOKEN"
'Content-Type' = 'text/plain'
} -InFile $HASH_FILE -ErrorAction SilentlyContinue
# 🔧 新增:上传Windows安装器 # 上传Windows安装器
$InstallerPath = "Installer\ConsoleInstaller\dist\windows\FigSetup.exe" if (Test-Path $INSTALLER_PATH) {
if (Test-Path $InstallerPath) { Write-Host "正在上传Windows安装器..."
Write-Host '正在上传Windows安装器...' Invoke-RestMethod -Method Post -Uri "$API/releases/$RELEASE_ID/assets?name=FigSetup.exe" `
Invoke-RestMethod -Method Post -Uri "$API/releases/$RELEASE_ID/assets?name=FigSetup.exe" ` -Headers @{
-Headers @{ Authorization = "token $TOKEN"
Authorization = "token $TOKEN" 'Content-Type' = 'application/octet-stream'
'Content-Type' = 'application/octet-stream' } -InFile $INSTALLER_PATH -ErrorAction SilentlyContinue
} -InFile $InstallerPath } else {
Write-Host "⚠️ 警告:未找到安装器文件 $INSTALLER_PATH"
} }
Write-Host '✅ Windows版本发布完成' Write-Host "✅ Windows版本发布完成"

View File

@@ -9,7 +9,7 @@ import json
import zipfile import zipfile
import platform import platform
from os import path as ospath from os import path as ospath
from os import mkdir,chdir from os import mkdir,chdir,remove,rename
from sys import exit, argv from sys import exit, argv
@@ -49,12 +49,7 @@ def getReleases():
# print(rel) # print(rel)
return rel return rel
def install(url, path:str) -> None: def install(url, path:str, filename:str) -> None:
if not ospath.exists(path):
mkdir(path)
filename = path.split('/')[-1]
response = requests.get(url, stream=True) response = requests.get(url, stream=True)
total_size = int(response.headers.get('content-length', 0)) total_size = int(response.headers.get('content-length', 0))
@@ -64,12 +59,29 @@ def install(url, path:str) -> None:
f.write(data) f.write(data)
b.update(len(data)) b.update(len(data))
print()
print(f'{filename} download completed.') print(f'{filename} download completed.')
print(f'unziping to {path} ...') print(f'unziping to {path} ...')
destZipPath = ospath.dirname(path)
with zipfile.ZipFile(filename) as zip: with zipfile.ZipFile(filename) as zip:
zip.extractall(path) zip.extractall(destZipPath) # 解压到安装目录上一层
rename(ospath.join(destZipPath, ospath.splitext(filename)[0]), path)
print()
print('unziping completed') print('unziping completed')
print('\n==========')
print('cleaning...')
remove(filename)
def osEnumToStr(os: int) -> str:
if os == Windows:
return 'windows'
elif os == Linux:
return 'linux'
elif os == Darwin:
return 'darwin'
return 'other'
def main() -> None: def main() -> None:
@@ -84,7 +96,7 @@ def main() -> None:
print(f'Install to (default: {dpath}): ', end='') print(f'Install to (default: {dpath}): ', end='')
path = input() path = input()
if path.isspace(): if not path:
path = dpath path = dpath
print() print()
@@ -97,7 +109,7 @@ def main() -> None:
print('No version has been released!') print('No version has been released!')
exit(0) exit(0)
print('There are {} versions:' % len(releases)) print(f'There are {len(releases)} versions:')
i = 1 i = 1
for release in releases: for release in releases:
print(f" {i} {release['name']} - {release['body']}") print(f" {i} {release['name']} - {release['body']}")
@@ -114,8 +126,7 @@ def main() -> None:
print() print()
version = insVersion version = insVersion
if not usrInput.isspace(): if usrInput:
if '.' in usrInput: if '.' in usrInput:
for release in releases: for release in releases:
if release['tag_name'].find(usrInput) != -1: if release['tag_name'].find(usrInput) != -1:
@@ -135,13 +146,15 @@ def main() -> None:
print(f"Installing Fig-{version['tag_name']}") print(f"Installing Fig-{version['tag_name']}")
url = None url = None
assetName = None
for asset in version['assets']: for asset in version['assets']:
if asset['name'].find(osName) != -1: assetName = asset['name']
if assetName.find(osEnumToStr(osName)) != -1 and assetName.find('.zip') != -1:
url = asset['browser_download_url'] url = asset['browser_download_url']
break break
if url: if url:
install(url, path) install(url, path, assetName)
else: else:
print('Could not find artifact:') print('Could not find artifact:')
print(version['assets']) print(version['assets'])

View File

@@ -49,10 +49,10 @@ int main(int argc, char **argv)
program.add_argument("source") program.add_argument("source")
.help("source file to be interpreted") .help("source file to be interpreted")
.default_value(std::string("")); .default_value(std::string(""));
program.add_argument("-v", "--version") // program.add_argument("-v", "--version")
.help("get the version of Fig Interpreter") // .help("get the version of Fig Interpreter")
.default_value(false) // .default_value(false)
.implicit_value(true); // .implicit_value(true);
// interpreter // interpreter
try try
@@ -64,11 +64,11 @@ int main(int argc, char **argv)
std::cerr << e.what() << '\n'; std::cerr << e.what() << '\n';
return 1; return 1;
} }
if (program.get<bool>("--version")) // if (program.get<bool>("--version"))
{ // {
std::print("Fig Interpreter version {}\n", Fig::Core::VERSION); // std::print("Fig Interpreter version {}\n", Fig::Core::VERSION);
return 0; // return 0;
} // }
Fig::FString sourcePath(program.get<std::string>("source")); Fig::FString sourcePath(program.get<std::string>("source"));
if (sourcePath.empty()) if (sourcePath.empty())
{ {