Skip to content

Commit 528bd60

Browse files
authored
v2.1 (#44)
* bugfixes fix type hinting fix import * update lock * remove deps and deprecated code * fix CI bug & test multiple python versions in CI (#41) * add classifiers * update version & improve pyproject.toml * use curl-cffi instead of requests & replace to English comment * use curl-cffi instead of requests & replace to English comment bugfix * WIP gcores.py implement get_name get_desc get_brief_desc get_thumbnail get_authors * WIP gcores.py bugfixes * Session reuse * WIP pyinstaller support & gitignore * Fix ci (#42) * bugfix * bugfix * implement other functions bugfix * bugfix * version
1 parent 218cc04 commit 528bd60

File tree

21 files changed

+1154
-684
lines changed

21 files changed

+1154
-684
lines changed

.github/workflows/Pyinstaller.yml

Lines changed: 112 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,112 @@
1+
name: Build and Release
2+
3+
on:
4+
push:
5+
branches:
6+
- dev
7+
- master
8+
paths:
9+
- 'pyproject.toml'
10+
11+
permissions:
12+
contents: write
13+
actions: write
14+
jobs:
15+
build:
16+
runs-on: windows-latest
17+
outputs:
18+
version: ${{ steps.get-version.outputs.version }}
19+
steps:
20+
- uses: actions/checkout@v4
21+
with:
22+
fetch-depth: 2
23+
24+
- name: Get Version from pyproject.toml
25+
id: get-version
26+
run: |
27+
$version = (Get-Content pyproject.toml | Select-String -Pattern '^version = "(.*)"' | ForEach-Object { $_.Matches.Groups[1].Value })
28+
echo "version=$version" >> $env:GITHUB_ENV
29+
echo "version=$version" >> $env:GITHUB_OUTPUT
30+
31+
- name: Get Last Commit Version
32+
run: |
33+
$commit_version = (git show HEAD^:pyproject.toml | Select-String -Pattern '^version = "(.*)"' | ForEach-Object { $_.Matches.Groups[1].Value })
34+
if (!$commit_version) { $commit_version = "none" }
35+
echo "last_commit_version=$commit_version" >> $env:GITHUB_ENV
36+
37+
- name: Check if Versions Match
38+
run: |
39+
if ("${{ env.version }}" -eq "${{ env.last_commit_version }}") {
40+
echo "skip_build=true" >> $env:GITHUB_ENV
41+
} else {
42+
echo "skip_build=false" >> $env:GITHUB_ENV
43+
}
44+
45+
- name: Setup Python
46+
uses: actions/setup-python@v4
47+
with:
48+
python-version: 3.11
49+
if: env.skip_build != 'true'
50+
51+
- name: Install PDM
52+
run: pip install pdm
53+
if: env.skip_build != 'true'
54+
55+
- name: Install Dependencies
56+
run: |
57+
pdm install
58+
pip install pyinstaller
59+
if: env.skip_build != 'true'
60+
61+
- name: Build Binary with PyInstaller
62+
run: |
63+
$env:PYTHONPATH = ".\.venv\Lib\site-packages"; pyinstaller --name GameYamlSpider `
64+
--add-data "gameyamlspiderandgenerator\plugin:gameyamlspiderandgenerator\plugin" `
65+
--add-data "./.venv/lib/site-packages/language_data/data:language_data\data" `
66+
--add-data ./.venv/lib/site-packages/ruamel/yaml/string/__plug_in__.py:ruamel/yaml/string `
67+
--hidden-import gameyamlspiderandgenerator.plugin.gcores `
68+
--hidden-import gameyamlspiderandgenerator.plugin.itchio `
69+
--hidden-import gameyamlspiderandgenerator.plugin.steam `
70+
--hidden-import yamlgenerator_hook_search `
71+
--hidden-import language_data `
72+
--hidden-import ruamel.yaml.string `
73+
--hidden-import yamlgenerator_hook_validate `
74+
pkg.py
75+
env:
76+
PATH: ${{ github.workspace }}/.pdm/bin:${{ env.PATH }}
77+
if: env.skip_build != 'true'
78+
79+
- name: Package with Zipfile
80+
run: python -m zipfile -c dist\GameYamlSpider.zip dist\GameYamlSpider
81+
if: env.skip_build != 'true'
82+
83+
- name: Upload artifact
84+
uses: actions/upload-artifact@v4
85+
with:
86+
name: GameYamlSpider-zip
87+
path: dist/GameYamlSpider.zip
88+
release:
89+
runs-on: ubuntu-latest
90+
needs: build
91+
steps:
92+
- name: Set Is Pre-release
93+
id: prerelease-check
94+
run: |
95+
version="${{ needs.build.outputs.version }}"
96+
echo "version=$version" >> $GITHUB_ENV
97+
if [[ "$version" =~ (a|b|dev|rc)\d? ]]; then
98+
echo "This is a pre-release version. Skipping GitHub release."
99+
exit 1
100+
else
101+
echo "This is a stable release."
102+
fi
103+
- name: Download artifact from build job
104+
uses: actions/download-artifact@v4
105+
with:
106+
name: GameYamlSpider-zip
107+
- name: Upload Release Assets
108+
uses: softprops/action-gh-release@v1
109+
with:
110+
files: GameYamlSpider.zip
111+
tag_name: v${{ env.version }}
112+
target_commitish: ${{ github.ref }}

.github/workflows/Test Default Hooks.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@ on:
88
- master
99
paths:
1010
- '**.py'
11-
- '**.yml'
11+
- 'Test*.yml'
1212
- '**.lock'
1313
- '**.yaml'
1414
permissions:

.github/workflows/Test Main Program.yml

Lines changed: 7 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@ on:
88
- master
99
paths:
1010
- '**.py'
11-
- '**.yml'
11+
- 'Test*.yml'
1212
- '**.lock'
1313
- '**.yaml'
1414
permissions:
@@ -18,19 +18,23 @@ jobs:
1818
test:
1919
runs-on: ubuntu-latest
2020

21+
strategy:
22+
matrix:
23+
python-version: [3.11, 3.12, 3.13]
24+
2125
steps:
2226
- uses: actions/checkout@v4
2327
- name: Setup PDM
2428
uses: pdm-project/setup-pdm@v4
2529
with:
26-
python-version: 3.11
30+
python-version: ${{ matrix.python-version }}
2731
cache: true
2832
- name: Check Cache
2933
id: cache-check
3034
uses: actions/cache@v4
3135
with:
3236
path: ~/.cache/pip
33-
key: ${{ runner.os }}-pip-${{ hashFiles('**/pdm.lock') }}
37+
key: ${{ runner.os }}-pip-${{ matrix.python-version }}-${{ hashFiles('**/pdm.lock') }}
3438
- name: Install dependencies
3539
if: steps.cache-check.outputs.cache-hit != 'true'
3640
run: pdm install

.gitignore

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,4 +3,8 @@
33
__pycache__
44
dist
55
tests/Atopes.zip
6-
tests/Springblades.zip
6+
tests/Springblades.zip
7+
/managed_context/
8+
/gameyamlspiderandgenerator.egg-info/
9+
/test_suite_analysis/
10+
/build/

gameyamlspiderandgenerator/__init__.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@
1414
logger.add(sys.stdout, level="WARNING")
1515

1616

17-
def verify(url: str) -> Callable[..., BasePlugin] | None:
17+
def verify(url: str) -> Callable[..., type[BasePlugin]] | None:
1818
if not pkg.plugin:
1919
raise PluginNotLoadedError
2020
verify_list = [

gameyamlspiderandgenerator/__main__.py

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@
66
from loguru import logger
77
from yaml import safe_load
88

9-
from gameyamlspiderandgenerator import produce_yaml
9+
from . import produce_yaml
1010
from .util.config import config
1111
from .util.fgi import default_config
1212
from .util.fgi_yaml import get_valid_filename
@@ -65,6 +65,7 @@
6565
if args.silent:
6666
logger.remove()
6767
logger.debug(sys.version)
68+
logger.debug(" ".join(sys.argv))
6869
logger.debug("version: " + version("gameyamlspiderandgenerator"))
6970
if isinstance(args.config, str):
7071
with open(args.config) as f:
@@ -87,7 +88,7 @@ def getenv_case_insensitive(key):
8788
"http": getenv_case_insensitive("HTTP_PROXY"),
8889
"https": getenv_case_insensitive("HTTPS_PROXY"),
8990
}
90-
config.update(setting)
91+
config.load(setting)
9192
pkg.init()
9293
yml = produce_yaml(args.url, args.lang)
9394
if args.output is None:

gameyamlspiderandgenerator/hook/_base.py

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@ class HookLoadingSequence(Enum):
99

1010

1111
class BaseHook(abc.ABC):
12-
"""钩子基类"""
12+
"""Base class for hooks"""
1313

1414
CHANGED: list | None = None
1515
REQUIRE_CONFIG: bool = False
@@ -18,8 +18,8 @@ class BaseHook(abc.ABC):
1818
@abc.abstractmethod
1919
def setup(self, data: dict):
2020
"""
21-
运行钩子函数
21+
Run the hook function
2222
2323
Args:
24-
data: 数据
24+
data: The data
2525
"""

0 commit comments

Comments
 (0)