Skip to content
This repository has been archived by the owner on Feb 14, 2023. It is now read-only.

Commit

Permalink
Merge pull request #42 from RyoLee/dev
Browse files Browse the repository at this point in the history
Dev
  • Loading branch information
Lee authored May 10, 2022
2 parents c2655b4 + b24c2b0 commit 324a707
Show file tree
Hide file tree
Showing 6 changed files with 73 additions and 23 deletions.
43 changes: 26 additions & 17 deletions .github/workflows/deploy.yml
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,6 @@ jobs:
cd ../../../
Remove-Item public -Recurse -ErrorAction Ignore
mkdir public
Copy-Item version.txt ./public/ -force
mv ./Gevjon-Core/bin/Release/Gevjon.7z ./public/
- name: Upload artifact
Expand All @@ -42,20 +41,6 @@ jobs:
retention-days: 1
path: |
public/Gevjon.7z
public/version.txt
- name: Deploy
uses: peaceiris/actions-gh-pages@v3
with:
github_token: ${{ secrets.GITHUB_TOKEN }}
publish_dir: ./public
keep_files: true

- name: Purge CDN cache
if: github.ref == 'refs/heads/master'
run: |
curl https://purge.jsdelivr.net/gh/RyoLee/Gevjon@gh-pages/version.txt
curl https://purge.jsdelivr.net/gh/RyoLee/Gevjon@gh-pages/Gevjon.7z
release:
needs: build
Expand All @@ -67,9 +52,20 @@ jobs:
with:
name: Gevjon
path: public
- name: Set Version
- name: Pack
run: |
VER=$(head -n 1 public/version.txt)
mkdir -p ./pack
mv ./public/Gevjon.7z ./pack/
cd ./pack
7z x Gevjon.7z
rm Gevjon.7z -f
wget -q -O - https://ygocdb.com/api/v0/cards.zip | gunzip - > ./cards.json
wget -q -O ./cards.ver https://ygocdb.com/api/v0/cards.zip.md5
7z a Gevjon.7z *
cd ..
mv ./pack/version.txt ./public/
mv ./pack/Gevjon.7z ./public/
VER=$(head -n 1 ./public/version.txt)
echo "TAG_NAME=$VER" >> $GITHUB_ENV
CONTENT="Checksum(SHA256): "$(sha256sum public//Gevjon.7z | awk '{print $1}')
echo "DEFAULT_CONTENT=$CONTENT" >> $GITHUB_ENV
Expand All @@ -80,3 +76,16 @@ jobs:
generate_release_notes: true
tag_name: ${{ env.TAG_NAME }}
files: public/Gevjon.7z

- name: Deploy github pages
uses: peaceiris/actions-gh-pages@v3
with:
github_token: ${{ secrets.GITHUB_TOKEN }}
publish_dir: ./public
keep_files: true

- name: Purge CDN cache
if: github.ref == 'refs/heads/master'
run: |
curl https://purge.jsdelivr.net/gh/RyoLee/Gevjon@gh-pages/version.txt
curl https://purge.jsdelivr.net/gh/RyoLee/Gevjon@gh-pages/Gevjon.7z
2 changes: 2 additions & 0 deletions Gevjon-Core/App.config
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,8 @@
<add key="currentFontSize" value="16" />
<add key="verURL" value="https://cdn.jsdelivr.net/gh/RyoLee/Gevjon@gh-pages/version.txt" />
<add key="dlURL" value="https://cdn.jsdelivr.net/gh/RyoLee/Gevjon@gh-pages/Gevjon.7z" />
<add key="dataVerURL" value="https://ygocdb.com/api/v0/cards.zip.md5" />
<add key="dataDlURL" value="https://ygocdb.com/api/v0/cards.zip" />
</appSettings>
<startup>
<supportedRuntime version="v4.0" sku=".NETFramework,Version=v4.7.2" />
Expand Down
3 changes: 3 additions & 0 deletions Gevjon-Core/Gevjon.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -117,6 +117,8 @@
<Reference Include="System.Configuration" />
<Reference Include="System.Data" />
<Reference Include="System.Drawing" />
<Reference Include="System.IO.Compression" />
<Reference Include="System.IO.Compression.FileSystem" />
<Reference Include="System.Web.Extensions" />
<Reference Include="System.Xml" />
<Reference Include="Microsoft.CSharp" />
Expand Down Expand Up @@ -196,6 +198,7 @@
</PropertyGroup>
<PropertyGroup>
<PostBuildEvent>xcopy "$(SolutionDir)Gevjon-Core\cards.json" "$(TargetDir)" /Y
xcopy "$(SolutionDir)Gevjon-Core\cards.ver" "$(TargetDir)" /Y
xcopy "$(SolutionDir)README.md" "$(TargetDir)" /Y
xcopy "$(SolutionDir)version.txt" "$(TargetDir)" /Y</PostBuildEvent>
</PropertyGroup>
Expand Down
1 change: 1 addition & 0 deletions Gevjon-Core/cards.ver
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
"9ac9f993be8eed795caedc2fa55c7d30"
45 changes: 40 additions & 5 deletions Gevjon-Core/mainwindow.xaml.cs
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,7 @@
using System.Web.Script.Serialization;
using System.Threading.Tasks;
using System.IO;
using System.IO.Compression;

namespace Gevjon
{
Expand Down Expand Up @@ -158,8 +159,7 @@ public class YGOdb
static string dbFile = "cards.json";

Dictionary<string, Card> datas;
public YGOdb()
{
public void reload() {
datas = new Dictionary<string, Card>();
using (StreamReader file = File.OpenText(dbFile))
{
Expand Down Expand Up @@ -197,6 +197,10 @@ public YGOdb()
}
}
}
public YGOdb()
{
reload();
}
public List<Card> Find(string key,bool exact)
{
List<Card> cards = new List<Card>();
Expand Down Expand Up @@ -498,19 +502,50 @@ private async Task CheckUpdate()
string HITS_URL = "https://hits.dwyl.com/RyoLee/Gevjon.svg";
string VER_URL = GetSetting("verURL", "https://cdn.jsdelivr.net/gh/RyoLee/Gevjon@gh-pages/version.txt");
string REL_URL = GetSetting("dlURL", "https://cdn.jsdelivr.net/gh/RyoLee/Gevjon@gh-pages/Gevjon.7z");
string DATA_VER_URL = GetSetting("dataVerURL", "https://ygocdb.com/api/v0/cards.zip.md5");
string DATA_REL_URL = GetSetting("dataDlURL", "https://ygocdb.com/api/v0/cards.zip");
string remote_ver_str = await TryGetAsync(VER_URL);
string locale_ver_str;
using (StreamReader reader = new StreamReader("version.txt")) {
using (StreamReader reader = new StreamReader("version.txt"))
{
locale_ver_str = reader.ReadLine() ?? "";
}
var remote_ver = new Version(remote_ver_str);
var locale_ver = new Version(locale_ver_str);
if (remote_ver.CompareTo(locale_ver)==1) {
if (MessageBox.Show("本地:\t" + locale_ver_str + "\n远端:\t" + remote_ver_str + "\n是否更新?", "发现新版本", MessageBoxButton.YesNo, MessageBoxImage.Information) == MessageBoxResult.Yes) {
if (remote_ver.CompareTo(locale_ver) == 1)
{
if (MessageBox.Show("本地:\t" + locale_ver_str + "\n远端:\t" + remote_ver_str + "\n是否更新?", "发现新版本", MessageBoxButton.YesNo, MessageBoxImage.Information) == MessageBoxResult.Yes)
{
await TryGetAsync(HITS_URL);
System.Diagnostics.Process.Start(REL_URL);
}
}
string remote_data_ver_str = await TryGetAsync(DATA_VER_URL);
string locale_data_ver_str;
using (StreamReader reader = new StreamReader("cards.ver"))
{
locale_data_ver_str = reader.ReadLine() ?? "";
}
if (!locale_data_ver_str.Equals(remote_data_ver_str))
{
if (MessageBox.Show("本地卡片数据与服务器不一致\n是否更新?", "发现新数据", MessageBoxButton.YesNo, MessageBoxImage.Information) == MessageBoxResult.Yes)
{
await TryGetAsync(HITS_URL);
using (var client = new System.Net.WebClient())
{
client.DownloadFile(DATA_REL_URL, "cards.zip");
using (var zipArchive = ZipFile.OpenRead("cards.zip"))
{
foreach (ZipArchiveEntry entry in zipArchive.Entries)
{
entry.ExtractToFile(entry.Name, true);
}
}
client.DownloadFile(DATA_VER_URL, "cards.ver");
db.reload();
}
}
}
}
finally {
System.Threading.Monitor.Exit(UpdateCheckBox);
Expand Down
2 changes: 1 addition & 1 deletion version.txt
Original file line number Diff line number Diff line change
@@ -1 +1 @@
1.3.0
1.3.1

0 comments on commit 324a707

Please sign in to comment.