Bugfixes and minor additions #23
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
name: YLP Release | |
on: | |
push: | |
paths: | |
- "**.py" | |
workflow_dispatch: | |
jobs: | |
build: | |
runs-on: windows-latest | |
name: Build YLP | |
outputs: | |
full_sha: ${{ steps.var.outputs.full_sha }} | |
new_tag: ${{ steps.get_version.outputs.new_tag }} | |
ffi_tag: ${{ steps.get_version.outputs.ffi_tag }} | |
steps: | |
- name: Checkout Repo | |
uses: actions/checkout@v4 | |
- name: Set up Python 3.12 | |
uses: actions/setup-python@v5 | |
with: | |
python-version: "3.12.1" | |
- name: Get Version Number | |
id: get_version | |
uses: actions/github-script@v7 | |
with: | |
script: | | |
const owner = context.repo.owner; | |
const repo = context.repo.repo; | |
const tags = await github.rest.repos.listTags({ | |
owner: owner, | |
repo: repo, | |
}); | |
let newTag; | |
let oldTag; | |
let ffiTag; | |
if (tags.data.length === 0) { | |
newTag = '1.0.0.0'; | |
} else { | |
const latestTag = tags.data[0].name; | |
const versionParts = latestTag.split('.').map(Number); | |
if (versionParts[1] === 9 && versionParts[2] === 9 && versionParts[3] === 9) { | |
versionParts[0] += 1; | |
versionParts[1] = 0; | |
versionParts[2] = 0; | |
versionParts[3] = 0; | |
} else if (versionParts[2] === 9) { | |
versionParts[1] += 1; | |
versionParts[2] = 0; | |
versionParts[3] = 0; | |
} else if (versionParts[3] === 9) { | |
versionParts[2] += 1; | |
versionParts[3] = 0; | |
} else { | |
versionParts[3] += 1; | |
} | |
newTag = `${versionParts.join('.')}`; | |
oldTag = latestTag; | |
} | |
ffiTag = newTag.replaceAll(".",","); | |
core.setOutput("new_tag", newTag); | |
core.setOutput("ffi_tag", ffiTag); | |
core.setOutput("old_tag", oldTag); | |
- name: Create Version File | |
id: create_version_file | |
run: | | |
New-Item ./version.txt | |
Set-Content -encoding ASCII ./version.txt @" | |
# UTF-8 | |
# | |
# For more details about fixed file info 'ffi' see: | |
# http://msdn.microsoft.com/en-us/library/ms646997.aspx | |
VSVersionInfo( | |
ffi=FixedFileInfo( | |
# filevers and prodvers should be always a tuple with four items: (1, 2, 3, 4) | |
# Set not needed items to zero 0. | |
filevers=(${{ steps.get_version.outputs.ffi_tag }}), | |
prodvers=(${{ steps.get_version.outputs.ffi_tag }}), | |
# Contains a bitmask that specifies the valid bits 'flags' | |
mask=0x3f, | |
# Contains a bitmask that specifies the Boolean attributes of the file. | |
flags=0x0, | |
# The operating system for which this file was designed. | |
# 0x4 - NT and there is no need to change it. | |
OS=0x4, | |
# The general type of file. | |
# 0x1 - the file is an application. | |
fileType=0x1, | |
# The function of the file. | |
# 0x0 - the function is not defined for this fileType | |
subtype=0x0, | |
# Creation date and time stamp. | |
date=(0, 0) | |
), | |
kids=[ | |
StringFileInfo( | |
[ | |
StringTable( | |
u'040904B0', | |
[StringStruct(u'CompanyName', u'github.com/xesdoog'), | |
StringStruct(u'FileDescription', u'YimLaunchpad'), | |
StringStruct(u'FileVersion', u'${{ steps.get_version.outputs.new_tag }}'), | |
StringStruct(u'InternalName', u'YLP'), | |
StringStruct(u'LegalCopyright', u'Copyright (c) SAMURAI - 2025'), | |
StringStruct(u'OriginalFilename', u'YimLaunchpad.exe'), | |
StringStruct(u'ProductName', u'YLP'), | |
StringStruct(u'ProductVersion', u'${{ steps.get_version.outputs.new_tag }}')]) | |
]), | |
VarFileInfo([VarStruct(u'Translation', [1033, 1200])]) | |
] | |
) | |
"@ | |
shell: pwsh | |
- name: Install dependencies | |
run: | | |
python -m pip install --upgrade pip | |
pip install flake8 pyinstaller | |
pip install -r requirements.txt | |
- name: Install UPX | |
run: | | |
Invoke-WebRequest -Uri "https://github.com/upx/upx/releases/download/v4.2.4/upx-4.2.4-win64.zip" -OutFile "./upx.zip" | |
Expand-Archive -Path "./upx.zip" -DestinationPath "./upx" | |
- name: Review Code With Flake8 | |
run: | | |
# stop the build if there are Python syntax errors or undefined names | |
flake8 . --count --select=E9,F63,F7,F82 --show-source --statistics | |
# exit-zero treats all errors as warnings. The GitHub editor is 127 chars wide | |
flake8 . --count --exit-zero --max-complexity=10 --max-line-length=127 --statistics | |
- name: Build Executable | |
run: | | |
pyinstaller "YimLaunchpad.py" --noconfirm --onefile --windowed --name "YimLaunchpad" --clean --version-file "./version.txt" --icon "./src/assets/img/ylp_icon.ico" --splash "./src/assets/img/ylp_splash.png" --add-data "./src;src/" --add-binary "./src/assets/dll/glfw3.dll;." --add-binary "./src/assets/dll/msvcr110.dll;." --upx-dir "./upx" --upx-exclude "vcruntime140.dll" --hidden-import=winsdk --hidden-import=pymem | |
- name: Generate Build Info | |
id: var | |
run: | | |
echo "full_sha=$(git rev-parse HEAD)" >> $env:GITHUB_OUTPUT | |
echo "short_sha=$(git rev-parse --short HEAD)" >> $env:GITHUB_OUTPUT | |
- name: Upload Artifact | |
uses: actions/upload-artifact@v4 | |
with: | |
name: binary | |
path: | | |
dist\YimLaunchpad.exe | |
create_release: | |
runs-on: ubuntu-latest | |
name: Create Release | |
needs: build | |
steps: | |
- name: Checkout Repo | |
uses: actions/checkout@v4 | |
- name: Write Changelog | |
id: write_changelog | |
run: | | |
commitMessage=$(git log -1 --pretty=format:"%s") | |
commitBody=$(git log -1 --pretty=format:"%b") | |
echo "Commit Message: $commitMessage" | |
echo "Commit Body: $commitBody" | |
{ | |
echo "changelog_body<<EOF" | |
echo "$commitMessage" | |
echo "" | |
echo "$commitBody" | |
echo "EOF" | |
} >> "$GITHUB_ENV" | |
shell: bash | |
- name: Download Artifact | |
uses: actions/download-artifact@v4 | |
with: | |
name: binary | |
- name: Echo build_sha256 | |
id: build_sha | |
run: | | |
sha256sum YimLaunchpad.exe > sha256.checksum | |
echo "build_sha=$(cat sha256.checksum)" >> $GITHUB_OUTPUT | |
cat sha256.checksum | |
- name: Upload Release | |
uses: softprops/action-gh-release@v2 | |
with: | |
name: YimLaunchpad ${{ needs.build.outputs.new_tag }} | |
tag_name: ${{ needs.build.outputs.new_tag }} | |
body: | | |
>[!NOTE] | |
>**This automatic release was built by Github Actions** | |
>| [Link to build](${{ github.server_url }}/${{ github.repository }}/actions/runs/${{ github.run_id }}) | | |
>| ------------- | | |
### Build SHA256: | |
${{ steps.build_sha.outputs.build_sha }} | |
### v${{ needs.build.outputs.new_tag }} Changelog | |
${{ env.changelog_body }} | |
files: | | |
YimLaunchpad.exe |