Skip to content

Commit

Permalink
ci: generate testing\weasel\appcast.xml and add deploy job-steps
Browse files Browse the repository at this point in the history
  • Loading branch information
fxliang committed Jul 23, 2024
1 parent 4196d35 commit 32e7e05
Show file tree
Hide file tree
Showing 2 changed files with 70 additions and 1 deletion.
13 changes: 12 additions & 1 deletion .github/workflows/release-ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -104,4 +104,15 @@ jobs:
./output/archives/weasel*.exe
./output/archives/debug_symbols.7z
body_path: ${{ github.workspace }}/RELEASE_CHANGELOG.md


- name: Generate testing/weasel/appcast.xml
run: |
.\build.bat testing_cast
- name: Deploy testing/weasel/appcast.xml to rime.github.io
uses: peaceiris/actions-gh-pages@v4
with:
deploy_key: ${{ secrets.ACTIONS_DEPLOY_KEY }}
external_repository: rime/rime.github.io
publish_dir: ./testing/weasel/
keep_files: true
58 changes: 58 additions & 0 deletions build.bat
Original file line number Diff line number Diff line change
Expand Up @@ -69,6 +69,7 @@ set rime_build_variant=release
set build_weasel=0
set build_installer=0
set build_arm64=0
set build_test_cast=0

rem parse the command line options
:parse_cmdline_options
Expand All @@ -92,6 +93,7 @@ rem parse the command line options
if "%1" == "weasel" set build_weasel=1
if "%1" == "installer" set build_installer=1
if "%1" == "arm64" set build_arm64=1
if "%1" == "testing_cast" set build_test_cast=1
if "%1" == "all" (
set build_boost=1
set build_data=1
Expand All @@ -105,6 +107,11 @@ rem parse the command line options
goto parse_cmdline_options
:end_parsing_cmdline_options

if %build_test_cast% == 1 (
call :build_test_cast_xml
exit /b
)

if %build_weasel% == 0 (
if %build_boost% == 0 (
if %build_data% == 0 (
Expand Down Expand Up @@ -355,6 +362,57 @@ rem %3 : target_path of rime.dll, base %WEASEL_ROOT% or abs path
if errorlevel 1 goto error

exit /b

:build_test_cast_xml
echo generating testing/weasel/appcast.xml
if not exist testing\weasel (mkdir testing\weasel)
copy update\testing-appcast.xml testing\weasel\appcast.xml > nul
if exist update_cast.ps1 del update_cast.ps1 > nul
echo $content = Get-Content -Path ^
.\testing\weasel\appcast.xml -Raw -Encoding UTF8 > update_cast.ps1
rem set url for nightly build or public release, by %RELEASE_BUILD%
echo $short_pat = "\d+\.\d+\.\d+" >> update_cast.ps1
echo $long_pat = "\d+\.\d+\.\d+\.\d+" >> update_cast.ps1
if not defined RELEASE_BUILD (
echo $newcontent = $content -replace "(?<=download/)$short_pat(?=/weasel-)", ^
"latest" >> update_cast.ps1
echo $newcontent = $newcontent -replace "(?<=weasel-)$long_pat(?=-installer.exe)", ^
"$env:PRODUCT_VERSION" >> update_cast.ps1
echo $newcontent = $newcontent -replace "(?<=<title>\S+\s+)$short_pat(?=</title>)", ^
"$env:PRODUCT_VERSION" >> update_cast.ps1
echo $newcontent = $newcontent -replace "(?<=sparkle:version=.)$short_pat", ^
"$env:PRODUCT_VERSION" >> update_cast.ps1
echo $newcontent = $newcontent -replace ^
"(?<=<sparkle:releaseNotesLink>)(http.*html)(?=</sparkle:releaseNotesLink>)", ^
"https://github.com/rime/weasel/releases/tag/latest" >> update_cast.ps1
) else (
echo $newcontent = $content -replace "(?<=download/)$short_pat(?=/weasel-)", ^
"$env:WEASEL_VERSION" >> update_cast.ps1
echo $newcontent = $newcontent -replace "(?<=weasel-)$long_pat(?=-installer.exe)", ^
"$env:PRODUCT_VERSION" >> update_cast.ps1
echo $newcontent = $newcontent -replace "(?<=<title>\S+\s+)$short_pat(?=</title>)", ^
"$env:WEASEL_VERSION" >> update_cast.ps1
echo $newcontent = $newcontent -replace "(?<=sparkle:version=.)$short_pat", ^
"$env:WEASEL_VERSION" >> update_cast.ps1
)
rem save current set
echo $originalCulture = [System.Threading.Thread]::CurrentThread.CurrentCulture >> update_cast.ps1
echo $originalUICulture = [System.Threading.Thread]::CurrentThread.CurrentUICulture >> update_cast.ps1
echo [System.Threading.Thread]::CurrentThread.CurrentCulture = 'en-US' >> update_cast.ps1
echo [System.Threading.Thread]::CurrentThread.CurrentUICulture = 'en-US' >> update_cast.ps1
echo $dateString = Get-Date -Format "ddd, dd MMM yyyy HH:mm:ss K" >> update_cast.ps1
rem recover current set
echo [System.Threading.Thread]::CurrentThread.CurrentCulture = $originalCulture >> update_cast.ps1
echo [System.Threading.Thread]::CurrentThread.CurrentUICulture = $originalUICulture >> update_cast.ps1
echo $newcontent = $newcontent -replace "(?<=<pubDate>).*(?=</pubDate>)", "$dateString" >> update_cast.ps1
echo $newcontent ^| Set-Content -Path testing\weasel\appcast.xml -Encoding UTF8 >> update_cast.ps1
powershell.exe -ExecutionPolicy Bypass .\update_cast.ps1
if errorlevel 1 exit /b 1
del update_cast.ps1
if errorlevel 1 exit /b 1
echo generated testing/weasel/appcast.xml
exit /b

rem ---------------------------------------------------------------------------

:error
Expand Down

0 comments on commit 32e7e05

Please sign in to comment.