Skip to content

Commit 15bfd9e

Browse files
authored
Merge branch 'rime:master' into a9m
2 parents e889f4e + 41dc044 commit 15bfd9e

File tree

11 files changed

+344
-224
lines changed

11 files changed

+344
-224
lines changed

.github/workflows/commit-ci.yml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -91,7 +91,7 @@ jobs:
9191
shell: pwsh
9292
run: |
9393
$ErrorActionPreference = 'Stop'
94-
.\get-rime.ps1 -tag 1.13.0 -use dev
94+
.\get-rime.ps1 -use dev
9595
9696
- name: Build data
9797
shell: pwsh
@@ -171,7 +171,7 @@ jobs:
171171
shell: pwsh
172172
run: |
173173
$ErrorActionPreference = 'Stop'
174-
.\get-rime.ps1 -tag 1.13.0 -use dev
174+
.\get-rime.ps1 -use dev
175175
176176
177177
- name: Build data

.github/workflows/release-ci.yml

Lines changed: 1 addition & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -58,7 +58,7 @@ jobs:
5858
shell: pwsh
5959
run: |
6060
$ErrorActionPreference = 'Stop'
61-
.\get-rime.ps1 -tag 1.13.0 -use dev
61+
.\get-rime.ps1 -use dev
6262
6363
- name: Build data
6464
run: |
@@ -112,9 +112,3 @@ jobs:
112112
./output/archives/weasel*.exe
113113
./output/archives/debug_symbols.7z
114114
body_path: ${{ github.workspace }}/RELEASE_CHANGELOG.md
115-
116-
- name: Update testing Appcast
117-
if: ${{ github.repository == 'rime/weasel' }}
118-
run: gh workflow run gh-pages.yml -R rime/home --ref master
119-
env:
120-
GH_TOKEN: ${{ secrets.ACTIONS_DEPLOY_KEY }}
Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,16 @@
1+
name: Update Appcast
2+
on:
3+
release:
4+
types: [published, prereleased]
5+
jobs:
6+
7+
update_appcast:
8+
9+
runs-on: windows-2019
10+
11+
steps:
12+
- name: Update Appcast
13+
if: ${{ github.repository == 'rime/weasel' }}
14+
run: gh workflow run gh-pages.yml -R rime/home --ref master
15+
env:
16+
GH_TOKEN: ${{ secrets.ACTIONS_DEPLOY_KEY }}

WeaselTSF/Compartment.cpp

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -253,8 +253,7 @@ HRESULT WeaselTSF::_HandleCompartment(REFGUID guidCompartment) {
253253
_EnableLanguageBar(isOpen);
254254
_UpdateLanguageBar(_status);
255255
} else {
256-
_status.ascii_mode = !_status.ascii_mode;
257-
_SetKeyboardOpen(true);
256+
_status.ascii_mode = !_IsKeyboardOpen();
258257
if (_pLangBarButton && _pLangBarButton->IsLangBarDisabled())
259258
_EnableLanguageBar(true);
260259
_HandleLangBarMenuSelect(_status.ascii_mode

WeaselTSF/LanguageBar.cpp

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -416,7 +416,11 @@ void WeaselTSF::_UpdateLanguageBar(weasel::Status stat) {
416416
else
417417
flags &= (~TF_CONVERSIONMODE_FULLSHAPE);
418418
_SetCompartmentDWORD(flags, GUID_COMPARTMENT_KEYBOARD_INPUTMODE_CONVERSION);
419-
419+
if (!_isToOpenClose) {
420+
BOOL open = !stat.ascii_mode;
421+
if (_IsKeyboardOpen() != open)
422+
_SetKeyboardOpen(open);
423+
}
420424
_pLangBarButton->UpdateWeaselStatus(stat);
421425
}
422426

clang-format.ps1

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,7 @@ $filesToProcess = @()
2121

2222
$WEASEL_SOURCE_PATH | ForEach-Object {
2323
$filesToProcess += Get-ChildItem -Path $_ -Recurse -Include *.cpp, *.h |
24-
Where-Object { $_.FullName -notmatch "include\\wtl\\" -and -not (ShouldExclude $_.FullName) } |
24+
Where-Object { $_.FullName -notmatch "include[\\/]wtl[\\/]" -and -not (ShouldExclude $_.FullName) } |
2525
ForEach-Object { $_.FullName }
2626
}
2727

get-rime.ps1

Lines changed: 14 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -144,8 +144,20 @@ try {
144144
} catch {
145145
$cmdOk = $false
146146
if($extract) {
147-
Write-Host "❌ Error: 7z is not available. Maybe 7z is not in PATH or not installed"
148-
SafeExit
147+
Write-Host "❌ Error: 7z is not available. Maybe 7z is not in PATH or not installed";
148+
$original_7z_url = "https://github.com/ip7z/7zip/releases/download/24.08/7zr.exe";
149+
if ($url_pat -and $url_replace) {
150+
$original_7z_url = $original_7z_url -replace $url_pat, $url_replace;
151+
}
152+
try {
153+
Write-Host "We will download 7z console tool from: $original_7z_url";
154+
Invoke-WebRequest -Uri $original_7z_url -OutFile ".\7z.exe";
155+
$env:Path += ";$PWD";
156+
$cmdOk = $true
157+
} catch{
158+
Write-Host "Error download 7z commandline tool";
159+
SafeExit
160+
}
149161
}
150162
}
151163
# check 64 bit

github.install.bat

Lines changed: 0 additions & 33 deletions
This file was deleted.

update/bump-version.ps1

100644100755
Lines changed: 93 additions & 54 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,19 @@
1-
param( [string]$tag, [switch]$updatelog)
2-
# -tag [new_tag], new tag shall be in format ^\d+\.\d+\.\d+$ and greater than
3-
# the current one
4-
# -updatelog update CHANGELOG.md if this switch used
5-
1+
#!/usr/bin/env pwsh
2+
param( [string]$tag, [string]$basetag, [switch]$updatelog, [switch]$h)
3+
# -tag [new_tag], new tag shall be in format of ^\d+\.\d+\.\d+$ and greater than
4+
# the current one or $basetag
5+
# -basetag [basetag name], specify the base tag(which shall be in format of ^\d+\.\d+\.\d+$),
6+
# default to be the latest number format tag name
7+
# -updatelog, update CHANGELOG.md if this switch used
8+
# -h, show help info
9+
function faild_exit {
10+
Write-Host
11+
Write-Host "Orz :( bump version failed!"
12+
Write-Host "we will revert the modification by command git checkout . "
13+
Write-Host
14+
& git checkout .
15+
exit 1
16+
}
617
# get old version info from file, esp from build.bat
718
function get_old_version{
819
param ([string]$filePath)
@@ -25,7 +36,6 @@ function get_old_version{
2536
$version['str'] = $version["major"] + "." + $version["minor"] + "." + $version["patch"];
2637
return $version;
2738
}
28-
2939
# parse new version info
3040
function parse_new_version {
3141
param([string]$new_version)
@@ -37,26 +47,10 @@ function parse_new_version {
3747
}
3848
return $version;
3949
}
40-
41-
# update bat file with param filePath, and tags
42-
function update_bat_file{
43-
param( [string]$filePath, $old_version, $new_version)
44-
$old_major, $old_minor, $old_patch = $old_version['major'], $old_version["minor"], $old_version["patch"];
45-
$new_major, $new_minor, $new_patch = $new_version['major'], $new_version["minor"], $new_version["patch"];
46-
$fileContent = Get-Content -Path $filePath;
47-
$fileContent = $fileContent -replace "VERSION_MAJOR=$old_major", "VERSION_MAJOR=$new_major";
48-
$fileContent = $fileContent -replace "VERSION_MINOR=$old_minor", "VERSION_MINOR=$new_minor";
49-
$fileContent = $fileContent -replace "VERSION_PATCH=$old_patch", "VERSION_PATCH=$new_patch";
50-
Set-Content -Path $filePath -Value $fileContent -Encoding UTF8;
51-
}
52-
5350
# update change log, work like clog-cli
5451
function update_changelog {
5552
param( [string]$new_tag, [string]$old_tag)
56-
# get the current the previous release tag and current release tag
57-
$tags = git tag --sort=creatordate | Select-String -Pattern '^\d+\.\d+\.\d+$' | ForEach-Object { $_.ToString() };
58-
$latestTag = $tags[-1];
59-
$commits = git log "$latestTag..HEAD" --pretty=format:"%s ([%an](https://github.com/rime/weasel/commit/%H))";
53+
$commits = git log "$old_tag..HEAD" --pretty=format:"%s ([%an](https://github.com/rime/weasel/commit/%H))";
6054
# group commit logs
6155
$groupedCommits = @{
6256
build = @(); ci = @(); fix = @(); feat = @(); docs = @(); style = @();
@@ -75,8 +69,8 @@ function update_changelog {
7569
commit = "Commits";
7670
};
7771
foreach ($commit in $commits) {
78-
if ($commit -match "^(build|ci|fix|feat|docs|style|refactor|test|chore):") {
79-
$prefix = $matches[1];
72+
if ($commit -match "^((?i)(build|ci|fix|feat|docs|style|refactor|test|chore)(\([^\)]+\))?):") {
73+
$prefix = $matches[2].ToLower();
8074
$groupedCommits[$prefix] += $commit;
8175
} else {
8276
$groupedCommits["commit"] += $commit;
@@ -99,57 +93,102 @@ function update_changelog {
9993
$contentAdd += $changelog;
10094
Write-Host "`n" + $contentAdd + "`n"
10195
$fileContent = $contentAdd + "`n" + $fileContent;
102-
$fileContent | Out-File -FilePath "CHANGELOG.md" -Encoding UTF8;
96+
$fileContent | Out-File -FilePath "CHANGELOG.md" -NoNewline -Encoding UTF8;
10397
}
104-
105-
# update appcast file, with regex patterns
106-
function update_appcast_file {
98+
# replace string with regex pat
99+
function replace_str {
107100
param( [string]$filePath, [string]$pat_orig, [string]$pat_replace)
108-
$fileContent = Get-Content -Path $filePath;
109-
$fileContent = $fileContent -replace $pat_orig, $pat_replace;
110-
Set-Content -Path $filePath -Value $fileContent;
101+
$fileContent = Get-Content -Path $filePath -Raw;
102+
$fileContent = [regex]::Replace($fileContent, $pat_orig, $pat_replace)
103+
$fileContent | Out-File -FilePath $filePath -NoNewline;
104+
}
105+
# update xml file
106+
function update_xml {
107+
param([string]$filePath, [string]$tag)
108+
$CurrentCulture = [System.Globalization.CultureInfo]::InvariantCulture
109+
$localTime = Get-Date
110+
$currentDateTime = $localTime.ToString("ddd, dd MMM yyyy HH:mm:ss zz00")
111+
replace_str -filePath "$filePath" -pat_orig "\d+\.\d+\.\d+" -pat_replace $tag
112+
replace_str -filePath "$filePath" `
113+
-pat_orig "(?<=<sparkle:releaseNotesLink>)[^>]*(?=</sparkle:releaseNotesLink>)" `
114+
-pat_replace "http://rime.github.io/release/weasel/"
115+
replace_str -filePath "$filePath" `
116+
-pat_orig "(?<=<pubDate>).*?(?=</pubDate>)" -pat_replace "$currentDateTime"
117+
Write-Host "$filePath updated"
118+
}
119+
# update bat file
120+
function update_bat {
121+
param([string]$filePath, [string]$tag)
122+
$new_version = parse_new_version -new_version $tag
123+
replace_str -filePath $filePath -pat_orig "(?<=VERSION_MAJOR=)\d+" $new_version['major']
124+
replace_str -filePath $filePath -pat_orig "(?<=VERSION_MINOR=)\d+" $new_version['minor']
125+
replace_str -filePath $filePath -pat_orig "(?<=VERSION_PATCH=)\d+" $new_version['patch']
126+
Write-Host "$filePath updated"
127+
}
128+
# test if cwd is weasel root
129+
function is_weasel_root() {
130+
return (Test-Path -Path "weasel.sln") -and (Test-Path -Path ".git")
111131
}
112132
###############################################################################
113133
# program now started
134+
if ($h -or (-not $tag)) {
135+
$info = @(
136+
"-tag [new_tag]`n`tnew tag shall be in format of ^\d+\.\d+\.\d+$ and greater than the current one or `$basetag",
137+
"-basetag [basetag name]`n`tspecify the base tag(which shall be in format of ^\d+\.\d+\.\d+$), default to be the latest number format tag name",
138+
"-updatelog`n`tupdate CHANGELOG.md if this switch used",
139+
"-h`n`tshow help info"
140+
)
141+
Write-Host ($info -join "`n");
142+
exit 0;
143+
}
144+
if (-not (is_weasel_root)) {
145+
Write-Host "Current directory is: $(Get-Location), it's not the weasel root directory"
146+
Write-Host "please run ``update/bump_version.ps1`` with parameters under the weasel root in Powershell";
147+
Write-Host "or run ``pwsh update/bump_version.ps1`` with parameters under weasel root in shell if yor're running Mac OS or Linux"
148+
exit 1;
149+
}
114150
# tag name not match rule, exit
115151
if (-not ($tag -match '^\d+\.\d+\.\d+$')) {
116152
Write-Host "tag name not match rule '^\d+\.\d+\.\d+$'";
117153
Write-Host "please recheck it";
118-
exit;
154+
exit 1;
119155
}
120156
# get old version
121157
$old_version = get_old_version -filePath "build.bat";
122-
$old_major, $old_minor, $old_patch = $old_version['major'], $old_version["minor"], $old_version["patch"];
123158
# get new version
124159
$new_version = parse_new_version -new_version $tag
160+
if ($basetag -eq "") {
161+
$basetag = $old_version["str"]
162+
}
163+
if ($basetag -notmatch "^\d+\.\d+\.\d+$") {
164+
Write-Host "basetag format is not correct, it shall be in format of '^\d+\.\d+\.\d+$'"
165+
Write-Host "please recheck it";
166+
exit 1;
167+
}
168+
125169
# check new version is greater than the current one
126170
if ($tag -eq $old_version["str"]) {
127171
Write-Host "the new tag: $tag is the same with the old one:" $old_version["str"];
128-
exit;
172+
exit 1;
129173
} elseif ($tag -lt $old_version["str"]) {
130174
Write-Host "$tag is older version than " $old_version['str']", please recheck your target version.";
131-
exit;
175+
exit 1;
132176
}
133-
Write-Host "bump version to $tag ... "
134-
#get date-time string in english date-time format
135-
$CurrentCulture = [System.Globalization.CultureInfo]::InvariantCulture
136-
$currentDateTime = (Get-Date).ToString("ddd, dd MMM yyyy HH:mm:ss K", $CurrentCulture)
137-
138-
#update appcast files
139-
update_appcast_file -filePath "update/appcast.xml" -pat_orig "$old_major\.$old_minor\.$old_patch" -pat_replace $tag
140-
update_appcast_file -filePath "update/appcast.xml" -pat_orig "<pubDate>.*?</pubDate>" -pat_replace "<pubDate>$currentDateTime</pubDate>"
141-
Write-Host "update/appcast.xml updated"
142-
update_appcast_file -filePath "update/testing-appcast.xml" -pat_orig "$old_major\.$old_minor\.$old_patch" -pat_replace $tag
143-
update_appcast_file -filePath "update/testing-appcast.xml" -pat_orig "<pubDate>.*?</pubDate>" -pat_replace "<pubDate>$currentDateTime</pubDate>"
144-
Write-Host "update/testing-appcast.xml updated"
145-
#update bat files
146-
update_bat_file -filePath "build.bat" -old_version $old_version -new_version $new_version
147-
Write-Host "build.bat updated"
148-
update_bat_file -filePath "xbuild.bat" -old_version $old_version -new_version $new_version
149-
Write-Host "xbuild.bat updated"
177+
Write-Host "Bumping version from $($old_version['str']) to $tag ..."
178+
# update xml files
179+
update_xml -filePath "update/appcast.xml" -tag "$tag";
180+
if ($?) { } else { faild_exit }
181+
update_xml -filePath "update/testing-appcast.xml" -tag "$tag";
182+
if ($?) { } else { faild_exit }
183+
# update bat files
184+
update_bat -filePath "build.bat" -tag "$tag";
185+
if ($?) { } else { faild_exit }
186+
update_bat -filePath "xbuild.bat" -tag "$tag";
187+
if ($?) { } else { faild_exit }
150188
#update CHANGELOG.md
151189
if ($updatelog) {
152-
update_changelog -new_tag $tag -old_tag "$old_major.$old_minor.$old_patch"
190+
update_changelog -new_tag $tag -old_tag $basetag;
191+
if ($?) { } else { faild_exit }
153192
& git add CHANGELOG.md
154193
Write-Host "CHANGELOG.md updated"
155194
}

0 commit comments

Comments
 (0)