Compare commits
3 Commits
dev-build
...
v0.3.6-alp
| Author | SHA1 | Date | |
|---|---|---|---|
| 1ccc63419d | |||
| 3b5e99242f | |||
| 85bdab5db3 |
@@ -61,7 +61,7 @@ jobs:
|
||||
# 安装依赖并构建
|
||||
pip install --upgrade pip
|
||||
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安装器构建完成"
|
||||
|
||||
- name: 打包Linux发布文件
|
||||
@@ -119,12 +119,12 @@ jobs:
|
||||
"$API/releases/$RELEASE_ID/assets?name=Fig-$VERSION-linux-x86_64.sha256"
|
||||
|
||||
# 🔧 新增:上传Linux安装器
|
||||
if [ -f "Installer/ConsoleInstaller/dist/linux/fig-setup" ]; then
|
||||
if [ -f "Installer/ConsoleInstaller/dist/linux/FigSetup-Linux" ]; then
|
||||
echo "正在上传Linux安装器..."
|
||||
curl -sS -X POST -H "Authorization: token $GITEA_TOKEN" \
|
||||
-H "Content-Type: application/octet-stream" \
|
||||
--data-binary @Installer/ConsoleInstaller/dist/linux/fig-setup \
|
||||
"$API/releases/$RELEASE_ID/assets?name=fig-setup"
|
||||
--data-binary @Installer/ConsoleInstaller/dist/linux/FigSetup-Linux \
|
||||
"$API/releases/$RELEASE_ID/assets?name=FigSetup-Linux"
|
||||
fi
|
||||
|
||||
echo "✅ Linux版本发布完成!"
|
||||
@@ -186,13 +186,16 @@ jobs:
|
||||
run: |
|
||||
[Console]::OutputEncoding = [System.Text.Encoding]::UTF8
|
||||
|
||||
# 确保版本号不为空
|
||||
$VERSION = $env:VERSION
|
||||
if ([string]::IsNullOrEmpty($VERSION)) {
|
||||
Write-Host "警告:版本号为空,使用默认值 dev-build"
|
||||
$VERSION = "dev-build"
|
||||
# 🔧 修改:与发布步骤使用相同的版本号计算逻辑
|
||||
if ($env:GITHUB_EVENT_NAME -eq 'workflow_dispatch') {
|
||||
$VERSION = $env:INPUT_VERSION
|
||||
if (-not $VERSION) { $VERSION = "dev-build" }
|
||||
} else {
|
||||
$VERSION = $env:GITHUB_REF_NAME
|
||||
}
|
||||
|
||||
Write-Host "打包版本: $VERSION"
|
||||
|
||||
$PACKAGE_NAME = "Fig-${VERSION}-windows-x86_64"
|
||||
Write-Host "打包名称: $PACKAGE_NAME"
|
||||
|
||||
@@ -242,43 +245,77 @@ jobs:
|
||||
$API = "https://git.fig-lang.cn/api/v1/repos/$REPO"
|
||||
$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
|
||||
$RELEASE_RESPONSE = Invoke-RestMethod -Uri "$API/releases/tags/$VERSION" -Headers @{Authorization = "token $TOKEN" } -ErrorAction SilentlyContinue
|
||||
if ($RELEASE_RESPONSE -and $RELEASE_RESPONSE.id) {
|
||||
$RELEASE_ID = $RELEASE_RESPONSE.id
|
||||
Write-Host "找到已有发布 ID: $RELEASE_ID"
|
||||
if (-not (Test-Path $ZIP_FILE)) {
|
||||
Write-Host "❌ 错误:找不到ZIP文件 $ZIP_FILE"
|
||||
Get-ChildItem *.zip
|
||||
exit 1
|
||||
}
|
||||
|
||||
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 {
|
||||
# 如果不存在,则创建新发布
|
||||
Write-Host '发布不存在,正在创建...'
|
||||
$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
|
||||
}
|
||||
Write-Host "❌ 错误:无法获取或创建发布 ID"
|
||||
exit 1
|
||||
}
|
||||
|
||||
# 2. 使用 Release ID 上传资产
|
||||
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"
|
||||
# 上传资产
|
||||
Write-Host "正在上传 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 '正在上传校验文件...'
|
||||
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"
|
||||
Write-Host "正在上传校验文件..."
|
||||
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安装器
|
||||
$InstallerPath = "Installer\ConsoleInstaller\dist\windows\FigSetup.exe"
|
||||
if (Test-Path $InstallerPath) {
|
||||
Write-Host '正在上传Windows安装器...'
|
||||
Invoke-RestMethod -Method Post -Uri "$API/releases/$RELEASE_ID/assets?name=FigSetup.exe" `
|
||||
-Headers @{
|
||||
Authorization = "token $TOKEN"
|
||||
'Content-Type' = 'application/octet-stream'
|
||||
} -InFile $InstallerPath
|
||||
# 上传Windows安装器
|
||||
if (Test-Path $INSTALLER_PATH) {
|
||||
Write-Host "正在上传Windows安装器..."
|
||||
Invoke-RestMethod -Method Post -Uri "$API/releases/$RELEASE_ID/assets?name=FigSetup.exe" `
|
||||
-Headers @{
|
||||
Authorization = "token $TOKEN"
|
||||
'Content-Type' = 'application/octet-stream'
|
||||
} -InFile $INSTALLER_PATH -ErrorAction SilentlyContinue
|
||||
} else {
|
||||
Write-Host "⚠️ 警告:未找到安装器文件 $INSTALLER_PATH"
|
||||
}
|
||||
|
||||
Write-Host '✅ Windows版本发布完成!'
|
||||
Write-Host "✅ Windows版本发布完成!"
|
||||
@@ -9,7 +9,7 @@ import json
|
||||
import zipfile
|
||||
import platform
|
||||
from os import path as ospath
|
||||
from os import mkdir,chdir
|
||||
from os import mkdir,chdir,remove,rename
|
||||
|
||||
from sys import exit, argv
|
||||
|
||||
@@ -49,12 +49,7 @@ def getReleases():
|
||||
# print(rel)
|
||||
return rel
|
||||
|
||||
def install(url, path:str) -> None:
|
||||
if not ospath.exists(path):
|
||||
mkdir(path)
|
||||
|
||||
filename = path.split('/')[-1]
|
||||
|
||||
def install(url, path:str, filename:str) -> None:
|
||||
response = requests.get(url, stream=True)
|
||||
total_size = int(response.headers.get('content-length', 0))
|
||||
|
||||
@@ -64,12 +59,29 @@ def install(url, path:str) -> None:
|
||||
f.write(data)
|
||||
b.update(len(data))
|
||||
|
||||
print()
|
||||
print(f'{filename} download completed.')
|
||||
print(f'unziping to {path} ...')
|
||||
destZipPath = ospath.dirname(path)
|
||||
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('\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:
|
||||
@@ -84,7 +96,7 @@ def main() -> None:
|
||||
print(f'Install to (default: {dpath}): ', end='')
|
||||
|
||||
path = input()
|
||||
if path.isspace():
|
||||
if not path:
|
||||
path = dpath
|
||||
print()
|
||||
|
||||
@@ -97,7 +109,7 @@ def main() -> None:
|
||||
print('No version has been released!')
|
||||
exit(0)
|
||||
|
||||
print('There are {} versions:' % len(releases))
|
||||
print(f'There are {len(releases)} versions:')
|
||||
i = 1
|
||||
for release in releases:
|
||||
print(f" {i} {release['name']} - {release['body']}")
|
||||
@@ -114,8 +126,7 @@ def main() -> None:
|
||||
print()
|
||||
|
||||
version = insVersion
|
||||
if not usrInput.isspace():
|
||||
|
||||
if usrInput:
|
||||
if '.' in usrInput:
|
||||
for release in releases:
|
||||
if release['tag_name'].find(usrInput) != -1:
|
||||
@@ -135,13 +146,15 @@ def main() -> None:
|
||||
print(f"Installing Fig-{version['tag_name']}")
|
||||
|
||||
url = None
|
||||
assetName = None
|
||||
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']
|
||||
break
|
||||
|
||||
if url:
|
||||
install(url, path)
|
||||
install(url, path, assetName)
|
||||
else:
|
||||
print('Could not find artifact:')
|
||||
print(version['assets'])
|
||||
|
||||
18
src/main.cpp
18
src/main.cpp
@@ -49,10 +49,10 @@ int main(int argc, char **argv)
|
||||
program.add_argument("source")
|
||||
.help("source file to be interpreted")
|
||||
.default_value(std::string(""));
|
||||
program.add_argument("-v", "--version")
|
||||
.help("get the version of Fig Interpreter")
|
||||
.default_value(false)
|
||||
.implicit_value(true);
|
||||
// program.add_argument("-v", "--version")
|
||||
// .help("get the version of Fig Interpreter")
|
||||
// .default_value(false)
|
||||
// .implicit_value(true);
|
||||
// interpreter
|
||||
|
||||
try
|
||||
@@ -64,11 +64,11 @@ int main(int argc, char **argv)
|
||||
std::cerr << e.what() << '\n';
|
||||
return 1;
|
||||
}
|
||||
if (program.get<bool>("--version"))
|
||||
{
|
||||
std::print("Fig Interpreter version {}\n", Fig::Core::VERSION);
|
||||
return 0;
|
||||
}
|
||||
// if (program.get<bool>("--version"))
|
||||
// {
|
||||
// std::print("Fig Interpreter version {}\n", Fig::Core::VERSION);
|
||||
// return 0;
|
||||
// }
|
||||
Fig::FString sourcePath(program.get<std::string>("source"));
|
||||
if (sourcePath.empty())
|
||||
{
|
||||
|
||||
Reference in New Issue
Block a user