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 }}
0 commit comments