Publish AI Installer and Portable Version #3
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: Publish AI Installer and Portable Version | |
on: | |
push: | |
tags: | |
- 'v*' | |
workflow_dispatch: | |
inputs: | |
version: | |
description: 'שם הגרסה (למשל, 1.0.0)' | |
required: false | |
jobs: | |
build: | |
runs-on: windows-latest | |
steps: | |
- name: Checkout repository | |
uses: actions/checkout@v4 | |
with: | |
fetch-depth: 0 # נדרש כדי לאפשר יצירת תגיות ושחרורים | |
- name: Setup Python | |
uses: actions/setup-python@v5 | |
with: | |
python-version: '3.10' | |
- name: Install dependencies | |
run: | | |
pip install pyinstaller music_tag jibrish_to_hebrew flet spacy==3.7.5 scikit-learn==1.5.1 chardet | |
- name: Get the version | |
id: get_version | |
shell: bash | |
run: | | |
if [ "${{ github.event_name }}" == "workflow_dispatch" ] && [ -n "${{ github.event.inputs.version }}" ]; then | |
VERSION=${{ github.event.inputs.version }} | |
else | |
VERSION=${GITHUB_REF#refs/tags/v} | |
fi | |
echo "VERSION=$VERSION" >> $GITHUB_OUTPUT | |
echo "RELEASE_TITLE=מסדר הסינגלים $VERSION" >> $GITHUB_OUTPUT | |
- name: Create Tag (if manually triggered) | |
if: ${{ github.event_name == 'workflow_dispatch' && github.event.inputs.version != '' }} | |
run: | | |
if git rev-parse "v${{ steps.get_version.outputs.VERSION }}" >/dev/null 2>&1; then | |
echo "Tag v${{ steps.get_version.outputs.VERSION }} כבר קיים. דילוג על יצירת תג." | |
else | |
git config user.name "github-actions" | |
git config user.email "[email protected]" | |
git tag v${{ steps.get_version.outputs.VERSION }} | |
git push origin v${{ steps.get_version.outputs.VERSION }} | |
fi | |
env: | |
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} | |
- name: Build EXE | |
run: | | |
flet pack -i src/core/assets/icon.ico src/core/main.py --product-name "Singles Sorter" --product-version "${{ steps.get_version.outputs.VERSION }}" --file-description "Singles Sorter" --copyright "[email protected]" | |
- name: Install Inno Setup | |
run: | | |
choco install innosetup -y | |
- name: Create Inno Setup Script | |
run: | | |
$script = @" | |
#define MyAppName "מסדר הסינגלים" | |
#define MyAppVersion "${{ steps.get_version.outputs.VERSION }}" | |
#define MyAppPublisher "nhlocal" | |
#define MyAppURL "https://nhlocal.github.io/Singles-Sorter" | |
#define MyAppExeName "main.exe" | |
[Setup] | |
AppId={{C1801B38-3050-4D83-8085-6466145B0A06} | |
AppName={#MyAppName} | |
AppVersion={#MyAppVersion} | |
AppPublisher={#MyAppPublisher} | |
AppPublisherURL={#MyAppURL} | |
AppSupportURL={#MyAppURL} | |
AppUpdatesURL={#MyAppURL} | |
DefaultDirName={autopf}\Singles Sorter | |
DisableProgramGroupPage=yes | |
LicenseFile="license.md" | |
PrivilegesRequired=lowest | |
OutputBaseFilename=Singles-Sorter-Installer-AI-{#MyAppVersion} | |
SetupIconFile=src\core\assets\icon.ico | |
SolidCompression=yes | |
Compression=lzma2/ultra64 | |
LZMAUseSeparateProcess=yes | |
LZMADictionarySize=1048576 | |
LZMANumFastBytes=273 | |
WizardStyle=modern | |
[Languages] | |
Name: "hebrew"; MessagesFile: "compiler:Languages\Hebrew.isl" | |
[Tasks] | |
Name: "desktopicon"; Description: "{cm:CreateDesktopIcon}"; GroupDescription: "{cm:AdditionalIcons}"; Flags: unchecked | |
[Files] | |
Source: "dist\main.exe"; DestDir: "{app}"; Flags: ignoreversion | |
Source: "src\core\app\*"; DestDir: "{app}\app"; Flags: ignoreversion recursesubdirs createallsubdirs | |
Source: "src\core\models\*"; DestDir: "{app}\models"; Flags: ignoreversion recursesubdirs createallsubdirs | |
Source: "src\core\assets\icon.png"; DestDir: "{app}\assets"; Flags: ignoreversion recursesubdirs createallsubdirs | |
[Icons] | |
Name: "{autoprograms}\{#MyAppName}"; Filename: "{app}\{#MyAppExeName}" | |
Name: "{autodesktop}\{#MyAppName}"; Filename: "{app}\{#MyAppExeName}"; Tasks: desktopicon | |
[Run] | |
Filename: "{app}\{#MyAppExeName}"; Description: "{cm:LaunchProgram,{#StringChange(MyAppName, '&', '&&')}}"; Flags: nowait postinstall skipifsilent | |
"@ | |
Set-Content -Path inno_setup_script.iss -Value $script | |
- name: Build Installer | |
run: | | |
& 'C:\Program Files (x86)\Inno Setup 6\ISCC.exe' inno_setup_script.iss | |
- name: Create Portable Version | |
run: | | |
New-Item -ItemType Directory -Force -Path portable | |
Copy-Item dist\main.exe portable\ | |
Copy-Item -Recurse src\core\app portable\ | |
Copy-Item -Recurse src\core\models portable\ | |
Copy-Item -Recurse src\core\assets portable\ | |
Compress-Archive -Path portable\* -DestinationPath Singles-Sorter-Portable-AI-${{ steps.get_version.outputs.VERSION }}.zip -CompressionLevel Optimal | |
- name: Check if Release Exists | |
id: check_release | |
uses: actions/github-script@v6 | |
with: | |
script: | | |
const tag = 'v${{ steps.get_version.outputs.VERSION }}'; | |
const releases = await github.rest.repos.listReleases({ | |
owner: context.repo.owner, | |
repo: context.repo.repo, | |
per_page: 100 | |
}); | |
const release = releases.data.find(r => r.tag_name === tag); | |
if (release) { | |
core.setOutput('exists', 'true'); | |
core.setOutput('release_id', release.id); | |
} else { | |
core.setOutput('exists', 'false'); | |
} | |
env: | |
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} | |
- name: Create Release (if not exists) | |
if: steps.check_release.outputs.exists == 'false' | |
uses: softprops/[email protected] | |
env: | |
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} | |
with: | |
tag_name: "v${{ steps.get_version.outputs.VERSION }}" | |
name: ${{ steps.get_version.outputs.RELEASE_TITLE }} | |
draft: true | |
prerelease: true | |
files: | | |
Output/Singles-Sorter-Installer-AI-${{ steps.get_version.outputs.VERSION }}.exe | |
Singles-Sorter-Portable-AI-${{ steps.get_version.outputs.VERSION }}.zip | |
- name: Upload Assets to Existing Release | |
if: steps.check_release.outputs.exists == 'true' | |
uses: softprops/[email protected] | |
env: | |
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} | |
with: | |
tag_name: "v${{ steps.get_version.outputs.VERSION }}" | |
files: | | |
Output/Singles-Sorter-Installer-AI-${{ steps.get_version.outputs.VERSION }}.exe | |
Singles-Sorter-Portable-AI-${{ steps.get_version.outputs.VERSION }}.zip |