Skip to content

Commit

Permalink
ci: 重构ci模块,在上传失败时不会推送版本
Browse files Browse the repository at this point in the history
  • Loading branch information
Sallee1 committed May 3, 2023
1 parent d3353b8 commit 5a5dfcd
Show file tree
Hide file tree
Showing 5 changed files with 20 additions and 15 deletions.
7 changes: 3 additions & 4 deletions appveyor.yml
Original file line number Diff line number Diff line change
Expand Up @@ -345,8 +345,7 @@

- ps: $buildversion = Get-Content version.ver
- ps: $commitLog = git log -1 --pretty=%B


- ps: ./ci/upload_file.ps1
- ps: ./ci/manual_upload_release.ps1

- ps: $errCode = ./ci/upload_file.ps1
- ps: if($errCode -eq 0){./ci/manual_upload_release.ps1}

2 changes: 1 addition & 1 deletion ci/delete_version.ps1
Original file line number Diff line number Diff line change
Expand Up @@ -2,5 +2,5 @@

$token="cvAutoTrackTmpToken"
$url='http://update.api.weixitianli.com/cvAutoTrack/Version?token='+$token+'?version='+$version
echo $url
Write-Host $url
Invoke-RestMethod -Method Put -Uri $url -ContentType 'application/json'
12 changes: 9 additions & 3 deletions ci/upload_file.ps1
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ $login_password='iOpEv21kPOt5ZrMqViLKvJJXshh6olNR'
$login_api='/api/auth/login'
$login_url='http://download.weixitianli.com'+$login_api + '?Username='+$login_username+'&Password='+$login_password
$token=(Invoke-RestMethod -Uri $login_url -Method Post).data.token
echo $token
Write-Host $token

$upload_api='/api/fs/put'
$upload_url='http://download.weixitianli.com'+$upload_api
Expand All @@ -20,7 +20,13 @@ $upload_headers=@{
'Content-Length' = $upload_file_length
'file-path' = $upload_path
}
Invoke-RestMethod -Uri $upload_url -Method Put -Headers $upload_headers -InFile $upload_file

try{
Invoke-RestMethod -Uri $upload_url -Method Put -Headers $upload_headers -InFile $upload_file
return 0
}
catch{
Write-Host "Upload Error, Program Stop."
return 504
}


14 changes: 7 additions & 7 deletions ci/upload_version.ps1
Original file line number Diff line number Diff line change
@@ -1,17 +1,17 @@
echo 获取版本号
Write-Host 获取版本号
git describe --tags | out-file version.ver
$version = Get-Content version.ver
echo (Get-Content version.ver)
Write-Host (Get-Content version.ver)
7z a -tZip cvAutoTrack-%APPVEYOR_BUILD_VERSION%.zip $env:MyProjectDir\cvAutoTrack\x64\Compile\cvAutoTrack.dll
(Get-FileHash -Path cvAutoTrack-$version.zip -Algorithm MD5).Hash | out-file md5.hash
echo (Get-Content md5.hash)
Write-Host (Get-Content md5.hash)

echo 上传
Write-Host 上传
curl -L "https://github.com/aoaostar/alidrive-uploader/releases/download/v2.2.1/alidrive_uploader_v2.2.1_windows_amd64.zip" -o alidrive.zip
tar -xf alidrive.zip --strip-components 1 | del example.config.yaml
Out-File -FilePath config.yaml -InputObject "ali_drive:`t`n drive_id:`t53348742`n refresh_token:`t7e5bc0b6829c40ac97864d937502447a`n root_path:`t/TianLiUpdateService`ndebug:`tfalse`nretry:`t3`ntransfers:`t3"
.\alidrive.exe .\cvAutoTrack-$version.zip /cvAutoTrack
echo 推送版本
Write-Host 推送版本
$version = Get-Content version.ver
$buildversion = Get-Content build_version.ver
$md5 = Get-Content md5.hash
Expand All @@ -20,6 +20,6 @@ $commitLog = git log -1 --pretty=%B
$token="cvAutoTrackTmpToken"
$url='http://update.api.weixitianli.com/cvAutoTrack/Version?token='+$token
$body='{"version":"' + $version+'","description":"' + $buildVersion + '","downloadUrl":"http://download.weixitianli.com/d/TianLiUpdateService/cvAutoTrack/cvAutoTrack-' + $version + '.zip","hash":"' + $md5 + '","updateLog":"' + $commitLog + '"}'
echo $url
echo $body
Write-Host $url
Write-Host $body
Invoke-RestMethod -Method Post -Uri $url -Body $body -ContentType 'application/json'
Binary file added ci/version.ver
Binary file not shown.

0 comments on commit 5a5dfcd

Please sign in to comment.