diff --git a/.github/workflows/build-installer.yml b/.github/workflows/build-installer.yml index 6c4104e..ee8a53d 100644 --- a/.github/workflows/build-installer.yml +++ b/.github/workflows/build-installer.yml @@ -19,14 +19,9 @@ jobs: uses: actions/download-artifact@v3 with: name: dyn2py.exe - - name: Update version number + - name: Build run: | - $regex = Select-String -Path pyproject.toml -Pattern '^version = "((?:\d\.){2}\d)"$' - $version = $regex.Matches.Groups[1].Value - (Get-Content dyn2py-installer.iss).Replace("x.x.x",$version) | Set-Content dyn2py-installer.iss - - name: Build installer - run: | - & "C:\Program Files (x86)\Inno Setup 6\ISCC.exe" -Qp $(Join-Path $PWD.Path dyn2py-installer.iss) + .\dyn2py-installer.ps1 - uses: actions/upload-artifact@v3 name: Upload artifact with: diff --git a/README.md b/README.md index c167cce..8c28521 100644 --- a/README.md +++ b/README.md @@ -181,17 +181,9 @@ pyinstaller dyn2py.spec ### Create installer for Windows - Install Inno Setup: https://jrsoftware.org/isdl.php -- The already built exe should be in the root folder -- Run this in powershell: +- Build an exe +- Run `dyn2py-installer.ps1` in powershell -```powershell -# Read version number from pyproject.toml and update in innosetup: -$regex = Select-String -Path pyproject.toml -Pattern '^version = "((?:\d\.){2}\d)"$' -$version = $regex.Matches.Groups[1].Value -(Get-Content dyn2py-installer.iss).Replace("x.x.x",$version) | Set-Content dyn2py-installer.iss -# Build: -& "C:\Program Files (x86)\Inno Setup 6\ISCC.exe" -Qp $(Join-Path $PWD.Path dyn2py-installer.iss) -``` ### Live module documentation ``` diff --git a/dyn2py-installer.ps1 b/dyn2py-installer.ps1 new file mode 100644 index 0000000..d22078d --- /dev/null +++ b/dyn2py-installer.ps1 @@ -0,0 +1,24 @@ +$InnoSetupPath = "C:\Program Files (x86)\Inno Setup 6\ISCC.exe" + +# Check if innosetup installed +if (-not (Test-Path -Path $InnoSetupPath -PathType Leaf)) { + throw "Innosetup not found!" +} + +# Copy dyn2py.exe from default folder: +if (Test-Path -Path ".\dist\dyn2py.exe" -PathType Leaf) { + Copy-Item ".\dist\dyn2py.exe" -Destination "." -Force +} + +# Check if dyn2py.exe exists at all +if (-not(Test-Path -Path ".\dist\dyn2py.exe" -PathType Leaf)) { + throw "dyn2py.exe not found!" +} + +# Read version number from pyproject.toml and update in innosetup: +$regex = Select-String -Path pyproject.toml -Pattern '^version = "((?:\d\.){2}\d)"$' +$version = $regex.Matches.Groups[1].Value +(Get-Content dyn2py-installer.iss).Replace("x.x.x", $version) | Set-Content dyn2py-installer.iss + +# Build: +& $InnoSetupPath -Qp $(Join-Path $PWD.Path dyn2py-installer.iss)