From 113fa4d77422029089f95cba80104d14f2193a98 Mon Sep 17 00:00:00 2001 From: webdevred <148627186+webdevred@users.noreply.github.com> Date: Thu, 14 Aug 2025 18:32:26 +0200 Subject: [PATCH 01/18] Initial build and release for windows - Create `.github/workflows/build-and-release.yaml` to: * Build jbeam-edit on Windows using the latest supported GHC * Cache Cabal store and build artifacts * Package executables, examples, and docs into a zip * Build an Inno Setup installer * Create a GitHub release with attached zip and installer - Update `.github/workflows/build-and-test.yaml` minor job name formatting - Add `installer/setup.iss` Inno Setup script for Windows installer --- .github/workflows/build-and-release.yaml | 89 ++++++++++++++++++++++++ .github/workflows/build-and-test.yaml | 2 +- installer/setup.iss | 23 ++++++ 3 files changed, 113 insertions(+), 1 deletion(-) create mode 100644 .github/workflows/build-and-release.yaml create mode 100644 installer/setup.iss diff --git a/.github/workflows/build-and-release.yaml b/.github/workflows/build-and-release.yaml new file mode 100644 index 00000000..f4281af2 --- /dev/null +++ b/.github/workflows/build-and-release.yaml @@ -0,0 +1,89 @@ +name: Build and release + +on: + push: + tags: [v*] + +jobs: + get-newest-supported-ghc: + name: Get the newest supported GHC + outputs: + matrix: ${{ steps.get-latest-version.outputs.matrix }} + runs-on: ubuntu-latest + steps: + - name: Extract the tested GHC versions + id: get-latest-version + uses: webdevred/get-tested@4671a0284723f30fa7f97989ff1f9513167180fe + with: + cabal-file: jbeam-edit.cabal + windows-version: latest + version: get-tested-for-jbeam-edit + newest: true + build-release: + runs-on: windows-latest + needs: get-newest-supported-ghc + name: Build and release for ${{ matrix.ghc }} + strategy: + matrix: ${{ fromJSON(needs.get-newest-supported-ghc.outputs.matrix) }} + steps: + - uses: actions/checkout@v4 + - name: Set up GHC latest and Cabal + id: setup-ghc + uses: haskell-actions/setup@v2.8.1 + with: + ghc-version: ${{ matrix.ghc }} + cabal-version: latest + cabal-update: true + - name: Cache GHC, Cabal store, and build artifacts + uses: actions/cache@v4.2.4 + with: + path: | + dist-newstyle + ${{ steps.setup-ghc.outputs.cabal-store }} + key: >- + ${{ runner.os }}-cabal-${{ + matrix.ghc + }}-${{ + hashFiles('**/package.yaml') + }} + restore-keys: | + ${{ runner.os }}-cabal-${{ matrix.ghc }}- + - name: Build executables + run: cabal build exe:jbeam-edit + - name: Prepare release folder + run: | + $releaseDir = "$env:GITHUB_WORKSPACE\dist\release" + Remove-Item $releaseDir -Recurse -Force -ErrorAction SilentlyContinue + New-Item -ItemType Directory -Path $releaseDir | Out-Null + $exePath = Get-ChildItem -Path "$env:GITHUB_WORKSPACE\dist-newstyle\build" -Recurse -Filter "jbeam-edit.exe" | Select-Object -First 1 + if ($exePath) { + Copy-Item $exePath.FullName $releaseDir + Write-Host "✅ Copied $($exePath.FullName)" + } + else { + Write-Warning "⚠️ jbeam-edit.exe was not found in dist-newstyle, skipping." + } + $dataDir = "$releaseDir\examples\jbfl" + New-Item -ItemType Directory -Path $dataDir -Force | Out-Null + Copy-Item "examples\jbfl\*" $dataDir -Recurse -ErrorAction SilentlyContinue + Copy-Item README.md $releaseDir + Copy-Item JBFL_DOCS.md $releaseDir + Copy-Item LICENSE $releaseDir + - name: Zip release + run: | + $zipFile = "$env:GITHUB_WORKSPACE\dist\jbeam-edit-${env:GITHUB_REF_NAME}.zip" + Add-Type -AssemblyName System.IO.Compression.FileSystem + [System.IO.Compression.ZipFile]::CreateFromDirectory("$env:GITHUB_WORKSPACE\dist\release", $zipFile) + - name: Build Inno Setup Installer + uses: Minionguyjpro/Inno-Setup-Action@v1.2.2 + with: + path: installer/setup.iss + options: /O+ + - name: Create GitHub Release + uses: softprops/action-gh-release@v2.3.2 + with: + tag_name: ${{ github.ref_name }} + generate_release_notes: true + files: |- + dist/jbeam-edit-${{ github.ref_name }}.zip + dist/release/setup.exe diff --git a/.github/workflows/build-and-test.yaml b/.github/workflows/build-and-test.yaml index 7d07575e..e5815edd 100644 --- a/.github/workflows/build-and-test.yaml +++ b/.github/workflows/build-and-test.yaml @@ -69,7 +69,7 @@ jobs: - name: Run tests run: stack test --fast generate-matrix: - name: "Generate matrix from cabal" + name: Generate matrix from cabal outputs: matrix: ${{ steps.set-matrix.outputs.matrix }} runs-on: ubuntu-latest diff --git a/installer/setup.iss b/installer/setup.iss new file mode 100644 index 00000000..189d82a2 --- /dev/null +++ b/installer/setup.iss @@ -0,0 +1,23 @@ +; -- Basic Inno Setup Script for jbeam-edit -- + +[Setup] +AppName=jbeam-edit +AppVersion=1.0 +DefaultDirName={pf}\jbeam-edit +DefaultGroupName=jbeam-edit +OutputBaseFilename=setup +Compression=lzma +SolidCompression=yes + +[Files] +Source: "..\dist\release\jbeam-edit.exe"; DestDir: "{app}"; Flags: ignoreversion +Source: "..\dist\release\examples\*"; DestDir: "{app}\examples"; Flags: recursesubdirs createallsubdirs +Source: "..\dist\release\README.md"; DestDir: "{app}"; Flags: ignoreversion +Source: "..\dist\release\JBFL_DOCS.md"; DestDir: "{app}"; Flags: ignoreversion +Source: "..\dist\release\LICENSE"; DestDir: "{app}"; Flags: ignoreversion + +[Icons] +Name: "{group}\jbeam-edit"; Filename: "{app}\jbeam-edit.exe" + +[Run] +Filename: "{app}\jbeam-edit.exe"; Description: "Launch jbeam-edit"; Flags: nowait postinstall skipifsilent From 197e265a91de6529752ce79af80c1ca3920cb501 Mon Sep 17 00:00:00 2001 From: webdevred <148627186+webdevred@users.noreply.github.com> Date: Sat, 16 Aug 2025 02:09:10 +0200 Subject: [PATCH 02/18] Edited the cabal.project.dev for better dev experience --- cabal.project.dev | 10 +++++++++- 1 file changed, 9 insertions(+), 1 deletion(-) diff --git a/cabal.project.dev b/cabal.project.dev index 602c4c76..4f62caba 100644 --- a/cabal.project.dev +++ b/cabal.project.dev @@ -1,7 +1,15 @@ packages: . +write-ghc-environment-files: always package * - ghc-options: -haddock + optimization: 0 + debug-info: True + tests: True + documentation: True + library-for-ghci: True package jbeam-edit + haddock-executables: True + haddock-internal: True + haddock-tests: True flags: +dump-ast +transformation From aa156fb569e82f8fc25e747844a38716fe51afa2 Mon Sep 17 00:00:00 2001 From: webdevred <148627186+webdevred@users.noreply.github.com> Date: Sat, 16 Aug 2025 03:51:32 +0200 Subject: [PATCH 03/18] Added cabal.project.release --- .github/workflows/build-and-release.yaml | 2 +- cabal.project.release | 12 ++++++++++++ 2 files changed, 13 insertions(+), 1 deletion(-) create mode 100644 cabal.project.release diff --git a/.github/workflows/build-and-release.yaml b/.github/workflows/build-and-release.yaml index f4281af2..09201d9c 100644 --- a/.github/workflows/build-and-release.yaml +++ b/.github/workflows/build-and-release.yaml @@ -49,7 +49,7 @@ jobs: restore-keys: | ${{ runner.os }}-cabal-${{ matrix.ghc }}- - name: Build executables - run: cabal build exe:jbeam-edit + run: cabal build exe:jbeam-edit --project-file cabal.project.release - name: Prepare release folder run: | $releaseDir = "$env:GITHUB_WORKSPACE\dist\release" diff --git a/cabal.project.release b/cabal.project.release new file mode 100644 index 00000000..6daa846a --- /dev/null +++ b/cabal.project.release @@ -0,0 +1,12 @@ +import: cabal.project +tests: False + +package * + ghc-options: + -threaded + -rtsopts + -with-rtsopts=-N + +package jbeam-edit + flags: -dump-ast -transformation + From 9fbdaf59cd10633f00608aa15d885ed6008ef9cf Mon Sep 17 00:00:00 2001 From: webdevred <148627186+webdevred@users.noreply.github.com> Date: Sat, 16 Aug 2025 22:53:17 +0200 Subject: [PATCH 04/18] Refactor cabal project files for modular configuration --- cabal.project | 5 +++++ cabal.project.ci | 6 +----- cabal.project.dev | 3 +-- cabal.project.release | 1 - 4 files changed, 7 insertions(+), 8 deletions(-) create mode 100644 cabal.project diff --git a/cabal.project b/cabal.project new file mode 100644 index 00000000..40bca28b --- /dev/null +++ b/cabal.project @@ -0,0 +1,5 @@ +packages: . +tests: True + +package jbeam-edit + flags: +dump-ast +transformation diff --git a/cabal.project.ci b/cabal.project.ci index 9e67d9e4..91a18d52 100644 --- a/cabal.project.ci +++ b/cabal.project.ci @@ -1,9 +1,5 @@ -packages: . -tests: True +import: cabal.project test-show-details: direct program-options ghc-options: -Werror - -package jbeam-edit - flags: +dump-ast +transformation diff --git a/cabal.project.dev b/cabal.project.dev index 4f62caba..11d905c9 100644 --- a/cabal.project.dev +++ b/cabal.project.dev @@ -1,4 +1,4 @@ -packages: . +import: cabal.project write-ghc-environment-files: always package * @@ -12,4 +12,3 @@ package jbeam-edit haddock-executables: True haddock-internal: True haddock-tests: True - flags: +dump-ast +transformation diff --git a/cabal.project.release b/cabal.project.release index 6daa846a..b7fddf13 100644 --- a/cabal.project.release +++ b/cabal.project.release @@ -9,4 +9,3 @@ package * package jbeam-edit flags: -dump-ast -transformation - From d2c3971208697e8b78748decc96d0c4817930808 Mon Sep 17 00:00:00 2001 From: webdevred <148627186+webdevred@users.noreply.github.com> Date: Sat, 16 Aug 2025 23:32:02 +0200 Subject: [PATCH 05/18] Minor formatting --- .github/workflows/build-and-test.yaml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/build-and-test.yaml b/.github/workflows/build-and-test.yaml index e5815edd..5077b778 100644 --- a/.github/workflows/build-and-test.yaml +++ b/.github/workflows/build-and-test.yaml @@ -79,7 +79,7 @@ jobs: uses: kleidukos/get-tested@v0.1.7.1 with: cabal-file: jbeam-edit.cabal - ubuntu-version: "latest" + ubuntu-version: latest version: 0.1.7.1 build-with-cabal: name: Build and test with Cabal (GHC ${{ matrix.ghc }}) From 83a908db8b5144d6d3460bbda06b0ce45b47ae70 Mon Sep 17 00:00:00 2001 From: webdevred <148627186+webdevred@users.noreply.github.com> Date: Sat, 16 Aug 2025 23:37:01 +0200 Subject: [PATCH 06/18] Run release build on PRs and pushes for validation --- .github/workflows/build-and-release.yaml | 29 +++++++++++++++++++----- 1 file changed, 23 insertions(+), 6 deletions(-) diff --git a/.github/workflows/build-and-release.yaml b/.github/workflows/build-and-release.yaml index 09201d9c..e7dbc320 100644 --- a/.github/workflows/build-and-release.yaml +++ b/.github/workflows/build-and-release.yaml @@ -1,8 +1,10 @@ -name: Build and release +name: Build for release on: push: + branches: [master] tags: [v*] + pull_request: jobs: get-newest-supported-ghc: @@ -22,7 +24,7 @@ jobs: build-release: runs-on: windows-latest needs: get-newest-supported-ghc - name: Build and release for ${{ matrix.ghc }} + name: Build for release for ${{ matrix.ghc }} strategy: matrix: ${{ fromJSON(needs.get-newest-supported-ghc.outputs.matrix) }} steps: @@ -50,6 +52,25 @@ jobs: ${{ runner.os }}-cabal-${{ matrix.ghc }}- - name: Build executables run: cabal build exe:jbeam-edit --project-file cabal.project.release + - name: Upload build artifact + uses: actions/upload-artifact@v4 + with: + name: jbeam-edit-${{ matrix.ghc }} + path: dist-newstyle + release: + runs-on: windows-latest + needs: build + if: startsWith(github.ref, 'refs/tags/') + name: Release for Windows + strategy: + matrix: ${{ fromJSON(needs.get-newest-supported-ghc.outputs.matrix) }} + steps: + - uses: actions/checkout@v4 + - name: Download build artifact + uses: actions/download-artifact@v4 + with: + name: jbeam-edit-${{ matrix.ghc }} + path: dist-newstyle - name: Prepare release folder run: | $releaseDir = "$env:GITHUB_WORKSPACE\dist\release" @@ -58,10 +79,6 @@ jobs: $exePath = Get-ChildItem -Path "$env:GITHUB_WORKSPACE\dist-newstyle\build" -Recurse -Filter "jbeam-edit.exe" | Select-Object -First 1 if ($exePath) { Copy-Item $exePath.FullName $releaseDir - Write-Host "✅ Copied $($exePath.FullName)" - } - else { - Write-Warning "⚠️ jbeam-edit.exe was not found in dist-newstyle, skipping." } $dataDir = "$releaseDir\examples\jbfl" New-Item -ItemType Directory -Path $dataDir -Force | Out-Null From 65bfd5561b4efac2c39485fcc620f452092910df Mon Sep 17 00:00:00 2001 From: webdevred <148627186+webdevred@users.noreply.github.com> Date: Sat, 16 Aug 2025 23:39:55 +0200 Subject: [PATCH 07/18] Run tests for the release building --- .github/workflows/build-and-release.yaml | 13 +++++++++++-- 1 file changed, 11 insertions(+), 2 deletions(-) diff --git a/.github/workflows/build-and-release.yaml b/.github/workflows/build-and-release.yaml index e7dbc320..2df2de8b 100644 --- a/.github/workflows/build-and-release.yaml +++ b/.github/workflows/build-and-release.yaml @@ -21,7 +21,7 @@ jobs: windows-version: latest version: get-tested-for-jbeam-edit newest: true - build-release: + build-for-release: runs-on: windows-latest needs: get-newest-supported-ghc name: Build for release for ${{ matrix.ghc }} @@ -36,8 +36,15 @@ jobs: ghc-version: ${{ matrix.ghc }} cabal-version: latest cabal-update: true + - name: Enable optimization for building on tags + if: startsWith(github.ref, 'refs/tags/') + run: cabal configure --project-file cabal.project.release -O2 + - name: Enable tests for non-tags + if: "!startsWith(github.ref, 'refs/tags/')" + run: cabal configure --project-file cabal.project.release --enable-tests - name: Cache GHC, Cabal store, and build artifacts uses: actions/cache@v4.2.4 + if: "!startsWith(github.ref, 'refs/tags/')" with: path: | dist-newstyle @@ -52,6 +59,8 @@ jobs: ${{ runner.os }}-cabal-${{ matrix.ghc }}- - name: Build executables run: cabal build exe:jbeam-edit --project-file cabal.project.release + - name: Run tests (GHC ${{ matrix.ghc }}) + run: cabal test --project-file cabal.project.release - name: Upload build artifact uses: actions/upload-artifact@v4 with: @@ -59,7 +68,7 @@ jobs: path: dist-newstyle release: runs-on: windows-latest - needs: build + needs: [build-for-release, get-newest-supported-ghc] if: startsWith(github.ref, 'refs/tags/') name: Release for Windows strategy: From 4e0db97a3ff3b74253bd60cb2dbd902b305079e2 Mon Sep 17 00:00:00 2001 From: webdevred <148627186+webdevred@users.noreply.github.com> Date: Sun, 17 Aug 2025 20:17:46 +0200 Subject: [PATCH 08/18] Added .ghc.environment.* to .gitignore --- .gitignore | 1 + 1 file changed, 1 insertion(+) diff --git a/.gitignore b/.gitignore index cc6744ed..2ec7c0c1 100644 --- a/.gitignore +++ b/.gitignore @@ -3,6 +3,7 @@ cabal.project.local~ dist-newstyle/ TAGS .stack-work/ +.ghc.environment.* **/*~ **/#*# **/.#* \ No newline at end of file From 1ca83fe01ad623669444b7f784fa6e9fd5f4307a Mon Sep 17 00:00:00 2001 From: webdevred <148627186+webdevred@users.noreply.github.com> Date: Wed, 20 Aug 2025 18:42:58 +0200 Subject: [PATCH 09/18] Hopefully better way to install config files on Windows --- jbeam-edit.cabal | 3 +++ package.yaml | 8 +++++--- src/Formatting/Config.hs | 27 ++++++++++++++++++++++----- 3 files changed, 30 insertions(+), 8 deletions(-) diff --git a/jbeam-edit.cabal b/jbeam-edit.cabal index 77208276..64a04150 100644 --- a/jbeam-edit.cabal +++ b/jbeam-edit.cabal @@ -82,6 +82,9 @@ library exposed-modules: Transformation hs-source-dirs: src-extra/transformation + if os(windows) + cpp-options: -DWINDOWS_EXAMPLE_PATHS + executable jbeam-edit main-is: Main.hs hs-source-dirs: app diff --git a/package.yaml b/package.yaml index 68a70bb7..4a220761 100644 --- a/package.yaml +++ b/package.yaml @@ -39,9 +39,11 @@ library: source-dirs: src generated-other-modules: Paths_jbeam_edit when: - condition: flag(transformation) - source-dirs: [src-extra/transformation] - exposed-modules: [Transformation] + - condition: flag(transformation) + source-dirs: [src-extra/transformation] + exposed-modules: [Transformation] + - condition: os(mingw32) + cpp-options: -DWINDOWS_EXAMPLE_PATHS flags: dump-ast: diff --git a/src/Formatting/Config.hs b/src/Formatting/Config.hs index 793c5faa..88b25f75 100644 --- a/src/Formatting/Config.hs +++ b/src/Formatting/Config.hs @@ -1,3 +1,5 @@ +{-# LANGUAGE CPP #-} + module Formatting.Config (readFormattingConfig, copyToConfigDir, ConfigType (..)) where import Control.Monad (when) @@ -7,17 +9,22 @@ import Formatting.Rules import GHC.IO.Exception (IOErrorType (NoSuchThing)) import IOUtils import Parsing.DSL (parseDSL) -import Paths_jbeam_edit import System.Directory import System.FilePath (takeDirectory, ()) +#if WINDOWS_EXAMPLE_PATHS +import System.Environment (getExecutablePath) +#else +import Paths_jbeam_edit +#endif + import Data.Text.IO qualified as TIO (putStrLn) data ConfigType = MinimalConfig | ComplexConfig deriving (Show) -getJbflSourcePath :: ConfigType -> FilePath -getJbflSourcePath MinimalConfig = "examples" "jbfl" "minimal.jbfl" -getJbflSourcePath ComplexConfig = "examples" "jbfl" "complex.jbfl" +getRelativeJbflSourcePath :: ConfigType -> FilePath +getRelativeJbflSourcePath MinimalConfig = "examples" "jbfl" "minimal.jbfl" +getRelativeJbflSourcePath ComplexConfig = "examples" "jbfl" "complex.jbfl" getConfigDir :: IO FilePath getConfigDir = getXdgDirectory XdgConfig "jbeam_edit" @@ -32,10 +39,20 @@ getConfigPath userConfigDir = do else pure $ userConfigDir "rules.jbfl" +#if WINDOWS_EXAMPLE_PATHS +getJbflSourcePath :: ConfigType -> IO FilePath +getJbflSourcePath configType = do + executableDir <- takeDirectory <$> getExecutablePath + pure (executableDir getRelativeJbflSourcePath configType) +#else +getJbflSourcePath :: ConfigType -> IO FilePath +getJbflSourcePath configType = getDataFileName (getRelativeJbflSourcePath configType) +#endif + copyConfigFile :: FilePath -> ConfigType -> IO () copyConfigFile dest configType = do createDirectoryIfMissing True (takeDirectory dest) - source <- getDataFileName (getJbflSourcePath configType) + source <- getJbflSourcePath configType putStrLn ("installing " ++ show configType ++ " config file to " ++ dest) copyFile source dest From 317504acfadbf3a71e50790aac7ca4bdce14b3ec Mon Sep 17 00:00:00 2001 From: webdevred <148627186+webdevred@users.noreply.github.com> Date: Wed, 20 Aug 2025 19:06:17 +0200 Subject: [PATCH 10/18] Improve InnoSetup workflow job --- .github/workflows/build-and-release.yaml | 61 +++++++++++++++++------- installer/setup.iss | 13 ++--- 2 files changed, 48 insertions(+), 26 deletions(-) diff --git a/.github/workflows/build-and-release.yaml b/.github/workflows/build-and-release.yaml index 2df2de8b..f2e14041 100644 --- a/.github/workflows/build-and-release.yaml +++ b/.github/workflows/build-and-release.yaml @@ -60,6 +60,7 @@ jobs: - name: Build executables run: cabal build exe:jbeam-edit --project-file cabal.project.release - name: Run tests (GHC ${{ matrix.ghc }}) + if: "!startsWith(github.ref, 'refs/tags/')" run: cabal test --project-file cabal.project.release - name: Upload build artifact uses: actions/upload-artifact@v4 @@ -82,34 +83,60 @@ jobs: path: dist-newstyle - name: Prepare release folder run: | + $ErrorActionPreference = 'Stop' $releaseDir = "$env:GITHUB_WORKSPACE\dist\release" - Remove-Item $releaseDir -Recurse -Force -ErrorAction SilentlyContinue + if (Test-Path $releaseDir) { Remove-Item $releaseDir -Recurse -Force -ErrorAction SilentlyContinue } New-Item -ItemType Directory -Path $releaseDir | Out-Null - $exePath = Get-ChildItem -Path "$env:GITHUB_WORKSPACE\dist-newstyle\build" -Recurse -Filter "jbeam-edit.exe" | Select-Object -First 1 - if ($exePath) { - Copy-Item $exePath.FullName $releaseDir + + $exePath = Get-ChildItem -Path "$env:GITHUB_WORKSPACE\dist-newstyle\build" -Recurse -Filter "jbeam-edit.exe" -ErrorAction SilentlyContinue | Select-Object -First 1 + if (-not $exePath) { + Write-Error "jbeam-edit.exe not found in dist-newstyle build tree. Make sure build-for-release succeeded." } - $dataDir = "$releaseDir\examples\jbfl" - New-Item -ItemType Directory -Path $dataDir -Force | Out-Null - Copy-Item "examples\jbfl\*" $dataDir -Recurse -ErrorAction SilentlyContinue - Copy-Item README.md $releaseDir - Copy-Item JBFL_DOCS.md $releaseDir - Copy-Item LICENSE $releaseDir - - name: Zip release - run: | - $zipFile = "$env:GITHUB_WORKSPACE\dist\jbeam-edit-${env:GITHUB_REF_NAME}.zip" - Add-Type -AssemblyName System.IO.Compression.FileSystem - [System.IO.Compression.ZipFile]::CreateFromDirectory("$env:GITHUB_WORKSPACE\dist\release", $zipFile) + Copy-Item $exePath.FullName $releaseDir + + $jbflDest = Join-Path $releaseDir "examples\jbfl" + New-Item -ItemType Directory -Path $jbflDest -Force | Out-Null + Copy-Item -Path "examples\jbfl\*" -Destination $jbflDest -Recurse -Force + + Copy-Item README.md $releaseDir -Force + Copy-Item JBFL_DOCS.md $releaseDir -Force + Copy-Item LICENSE $releaseDir -Force - name: Build Inno Setup Installer uses: Minionguyjpro/Inno-Setup-Action@v1.2.2 with: path: installer/setup.iss options: /O+ - - name: Create GitHub Release + - name: Locate and move setup.exe into release folder + run: | + $ErrorActionPreference = 'Stop' + $found = Get-ChildItem -Path "$env:GITHUB_WORKSPACE" -Recurse -Filter "setup.exe" -ErrorAction SilentlyContinue | + Where-Object { $_.FullName -notmatch "\\\.git\\" } | + Select-Object -First 1 + if (-not $found) { + Write-Error "setup.exe not found after Inno Setup run. Check installer/output location." + } + $releaseSetupPath = Join-Path "$env:GITHUB_WORKSPACE\dist\release" "setup.exe" + Copy-Item $found.FullName $releaseSetupPath -Force + Write-Host "Copied setup.exe to $releaseSetupPath" + - name: Create zip containing setup.exe and docs + run: | + $ErrorActionPreference = 'Stop' + $zipFile = "$env:GITHUB_WORKSPACE\dist\jbeam-edit-${env:GITHUB_REF_NAME}.zip" + $zipDir = "$env:GITHUB_WORKSPACE\dist\zip_temp" + if (Test-Path $zipDir) { Remove-Item $zipDir -Recurse -Force -ErrorAction SilentlyContinue } + New-Item -ItemType Directory -Path $zipDir | Out-Null + + Copy-Item "$env:GITHUB_WORKSPACE\dist\release\setup.exe" $zipDir -Force + Copy-Item "$env:GITHUB_WORKSPACE\dist\release\README.md" $zipDir -Force + Copy-Item "$env:GITHUB_WORKSPACE\dist\release\JBFL_DOCS.md" $zipDir -Force + Copy-Item "$env:GITHUB_WORKSPACE\dist\release\LICENSE" $zipDir -Force + Add-Type -AssemblyName System.IO.Compression.FileSystem + [System.IO.Compression.ZipFile]::CreateFromDirectory($zipDir, $zipFile) + Write-Host "Created zip: $zipFile" + - name: Create GitHub Release and upload zip uses: softprops/action-gh-release@v2.3.2 with: tag_name: ${{ github.ref_name }} generate_release_notes: true files: |- dist/jbeam-edit-${{ github.ref_name }}.zip - dist/release/setup.exe diff --git a/installer/setup.iss b/installer/setup.iss index 189d82a2..5a762880 100644 --- a/installer/setup.iss +++ b/installer/setup.iss @@ -11,13 +11,8 @@ SolidCompression=yes [Files] Source: "..\dist\release\jbeam-edit.exe"; DestDir: "{app}"; Flags: ignoreversion -Source: "..\dist\release\examples\*"; DestDir: "{app}\examples"; Flags: recursesubdirs createallsubdirs -Source: "..\dist\release\README.md"; DestDir: "{app}"; Flags: ignoreversion -Source: "..\dist\release\JBFL_DOCS.md"; DestDir: "{app}"; Flags: ignoreversion -Source: "..\dist\release\LICENSE"; DestDir: "{app}"; Flags: ignoreversion +Source: "..\dist\release\examples\jbfl\*"; DestDir: "{app}\examples\jbfl"; Flags: recursesubdirs createallsubdirs ignoreversion -[Icons] -Name: "{group}\jbeam-edit"; Filename: "{app}\jbeam-edit.exe" - -[Run] -Filename: "{app}\jbeam-edit.exe"; Description: "Launch jbeam-edit"; Flags: nowait postinstall skipifsilent +[Registry] + Root: HKCU; Subkey: "Environment"; ValueType: string; ValueName: "Path"; \ + ValueData: "{olddata};{app}"; Flags: preservestringtype uninsdeletevalue From cbde70953ed6512ea661fd9a1f8646d3ef9cb22e Mon Sep 17 00:00:00 2001 From: webdevred <148627186+webdevred@users.noreply.github.com> Date: Wed, 20 Aug 2025 23:59:44 +0200 Subject: [PATCH 11/18] Updated README.md --- README.md | 36 +++++++++++++++++++++++++++++------- 1 file changed, 29 insertions(+), 7 deletions(-) diff --git a/README.md b/README.md index 10634e83..bf81b287 100644 --- a/README.md +++ b/README.md @@ -64,15 +64,37 @@ Override per project by placing `.jbeam_edit.jbfl` in your project root. ## Usage -Build and run: +### 1. Download the latest release +Go to the [Releases page](https://github.com/webdevred/jbeam_edit/releases) and download the most recent **`.zip`** file. -```bash -git clone https://github.com/webdevred/jbeam-tool.git -cd jbeam-tool -stack build -stack exec jbeam-tool -- [options] +### 2. Unzip the file +Extract the contents of the downloaded `.zip` archive to a folder of your choice. + +### 3. Run the setup as Administrator + +Inside the extracted folder, right-click on **setup.exe** and choose **Run as administrator**. + +## 4. Allow Windows protection if needed +If Windows shows a warning such as: + +> *Windows protected your PC* + +Click **More info** → **Run anyway**. + +## 5. Open Command Prompt or PowerShell + +Press **Win + R**, type `cmd` (or `powershell`), and press **Enter**. + +## 6. Run jbeam-edit on a file + +Navigate to your project in CMD: + +```powershell +jbeam-edit your-file.jbeam ``` +Replace `your-file.jbeam` with the path to the JBeam file you want to format. + Typical workflow: - Parses and formats the file. @@ -81,7 +103,7 @@ Typical workflow: In-place editing (no backup): -```bash +```powershell jbeam-edit -i example.jbeam ``` From a363b66b618f14f2c2522b2fe42605252dc33685 Mon Sep 17 00:00:00 2001 From: webdevred <148627186+webdevred@users.noreply.github.com> Date: Thu, 21 Aug 2025 00:06:00 +0200 Subject: [PATCH 12/18] Fix version numbers --- installer/setup.iss | 2 +- jbeam-edit.cabal | 2 +- package.yaml | 2 +- 3 files changed, 3 insertions(+), 3 deletions(-) diff --git a/installer/setup.iss b/installer/setup.iss index 5a762880..20a948c6 100644 --- a/installer/setup.iss +++ b/installer/setup.iss @@ -2,7 +2,7 @@ [Setup] AppName=jbeam-edit -AppVersion=1.0 +AppVersion=0.0.1.0 DefaultDirName={pf}\jbeam-edit DefaultGroupName=jbeam-edit OutputBaseFilename=setup diff --git a/jbeam-edit.cabal b/jbeam-edit.cabal index 64a04150..aecbd89e 100644 --- a/jbeam-edit.cabal +++ b/jbeam-edit.cabal @@ -5,7 +5,7 @@ cabal-version: 2.2 -- see: https://github.com/sol/hpack name: jbeam-edit -version: 0.1.0.0 +version: 0.0.1.0 license: BSD-3-Clause license-file: LICENSE copyright: 2025 webdevred diff --git a/package.yaml b/package.yaml index 4a220761..ff2e85d7 100644 --- a/package.yaml +++ b/package.yaml @@ -1,5 +1,5 @@ name: jbeam-edit -version: 0.1.0.0 +version: 0.0.1.0 github: webdevred/jbeam-edit license: BSD-3-Clause author: webdevred From 67caadcd93f99c488358cd570ab24222fa29abd6 Mon Sep 17 00:00:00 2001 From: webdevred <148627186+webdevred@users.noreply.github.com> Date: Thu, 21 Aug 2025 11:31:02 +0200 Subject: [PATCH 13/18] Added flag for window-example-paths --- cabal.project | 2 +- cabal.project.release | 2 +- jbeam-edit.cabal | 9 ++++++++- package.yaml | 7 ++++++- stack.yaml | 1 + 5 files changed, 17 insertions(+), 4 deletions(-) diff --git a/cabal.project b/cabal.project index 40bca28b..86f2ee37 100644 --- a/cabal.project +++ b/cabal.project @@ -2,4 +2,4 @@ packages: . tests: True package jbeam-edit - flags: +dump-ast +transformation + flags: +dump-ast +transformation -windows-example-paths diff --git a/cabal.project.release b/cabal.project.release index b7fddf13..0bb1a785 100644 --- a/cabal.project.release +++ b/cabal.project.release @@ -8,4 +8,4 @@ package * -with-rtsopts=-N package jbeam-edit - flags: -dump-ast -transformation + flags: -dump-ast -transformation +windows-example-paths diff --git a/jbeam-edit.cabal b/jbeam-edit.cabal index aecbd89e..8038415b 100644 --- a/jbeam-edit.cabal +++ b/jbeam-edit.cabal @@ -40,6 +40,13 @@ flag transformation default: False manual: True +flag windows-example-paths + description: + Use executable-relative example paths (for Windows release builds) + + default: False + manual: True + library exposed-modules: CommandLineOptions @@ -82,7 +89,7 @@ library exposed-modules: Transformation hs-source-dirs: src-extra/transformation - if os(windows) + if (os(windows) && flag(windows-example-paths)) cpp-options: -DWINDOWS_EXAMPLE_PATHS executable jbeam-edit diff --git a/package.yaml b/package.yaml index ff2e85d7..66793744 100644 --- a/package.yaml +++ b/package.yaml @@ -42,7 +42,7 @@ library: - condition: flag(transformation) source-dirs: [src-extra/transformation] exposed-modules: [Transformation] - - condition: os(mingw32) + - condition: os(windows) && flag(windows-example-paths) cpp-options: -DWINDOWS_EXAMPLE_PATHS flags: @@ -54,6 +54,11 @@ flags: description: Enable transformation (experimental) manual: true default: false + windows-example-paths: + description: Use executable-relative example paths (for Windows release builds) + default: false + manual: true + executables: jbeam-edit: diff --git a/stack.yaml b/stack.yaml index 6d2e165c..048cc21a 100644 --- a/stack.yaml +++ b/stack.yaml @@ -5,3 +5,4 @@ flags: jbeam-edit: transformation: false dump-ast: false + windows-example-paths: false From 9800f72b900aead5d0f048afa745b61312a2f281 Mon Sep 17 00:00:00 2001 From: webdevred <148627186+webdevred@users.noreply.github.com> Date: Thu, 21 Aug 2025 11:31:30 +0200 Subject: [PATCH 14/18] Static builds --- cabal.project.release | 1 + 1 file changed, 1 insertion(+) diff --git a/cabal.project.release b/cabal.project.release index 0bb1a785..8fd8b1e1 100644 --- a/cabal.project.release +++ b/cabal.project.release @@ -1,5 +1,6 @@ import: cabal.project tests: False +executable-static: True package * ghc-options: From 0ac05eb233cf65fbedce2bad7b909afccfa851dd Mon Sep 17 00:00:00 2001 From: webdevred <148627186+webdevred@users.noreply.github.com> Date: Thu, 21 Aug 2025 11:31:44 +0200 Subject: [PATCH 15/18] Added From source section to README.md --- README.md | 20 +++++++++++++++++--- 1 file changed, 17 insertions(+), 3 deletions(-) diff --git a/README.md b/README.md index bf81b287..0eac88cd 100644 --- a/README.md +++ b/README.md @@ -28,7 +28,7 @@ A fast, robust command-line parser, formatter, and editor for JBeam files, the J Uniform indentation, spacing, and layout for improved readability. - **Automatic Node Management:** - Renames nodes sequentially (e.g., `["bf1", ...]` → `["bf0", "bf1", "bf2"]`) and updates all references automatically. + Renames nodes sequentially (e.g., `["bf1", ...]` → `["bf0", "bf1", "bf2"]`) and updates all references automatically. Feature currently unstable, enabled by build flag `transformation`. - **Configurable Formatting with JBFL:** Customize formatting rules using JBFL, a mini-language to specify padding, decimals, indentation, and more with wildcard targeting. @@ -107,6 +107,18 @@ In-place editing (no backup): jbeam-edit -i example.jbeam ``` +### From source (Linux or development) + +Clone and build with Cabal: + +```bash +git clone https://github.com/webdevred/jbeam_edit.git +cd jbeam_edit +cabal update +cabal install +jbeam-edit your-file.jbeam +``` + ## Examples For sample `.jbeam` files and JBFL rule files, see the [Examples Directory README](examples/README.org). @@ -138,8 +150,10 @@ For an in-depth walkthrough of the implementation and design decisions, see [EXP ## Prerequisites -- GHC (The Glasgow Haskell Compiler) -- Stack build tool +- **Windows users (BeamNG players):** none, just download the installer from [Releases](https://github.com/webdevred/jbeam_edit/releases/latest). +- **Developers / Linux users:** + - [GHC](https://www.haskell.org/ghc/) (Glasgow Haskell Compiler) + - [Cabal](https://www.haskell.org/cabal/) build tool (comes with GHCup) ## Contributing & License From 45ab3b875d5f2599ed8ae778790d77c9b2fd296a Mon Sep 17 00:00:00 2001 From: webdevred <148627186+webdevred@users.noreply.github.com> Date: Thu, 21 Aug 2025 11:32:47 +0200 Subject: [PATCH 16/18] Draft release --- .github/workflows/build-and-release.yaml | 1 + 1 file changed, 1 insertion(+) diff --git a/.github/workflows/build-and-release.yaml b/.github/workflows/build-and-release.yaml index f2e14041..a939b1f6 100644 --- a/.github/workflows/build-and-release.yaml +++ b/.github/workflows/build-and-release.yaml @@ -137,6 +137,7 @@ jobs: uses: softprops/action-gh-release@v2.3.2 with: tag_name: ${{ github.ref_name }} + draft: true generate_release_notes: true files: |- dist/jbeam-edit-${{ github.ref_name }}.zip From 922db665ebc64239c3aa9f5ddec19f698eaf7cba Mon Sep 17 00:00:00 2001 From: webdevred <148627186+webdevred@users.noreply.github.com> Date: Thu, 21 Aug 2025 12:23:29 +0200 Subject: [PATCH 17/18] Added Path refresh step guide --- README.md | 30 ++++++++++++++++++------------ 1 file changed, 18 insertions(+), 12 deletions(-) diff --git a/README.md b/README.md index 0eac88cd..780de110 100644 --- a/README.md +++ b/README.md @@ -81,28 +81,34 @@ If Windows shows a warning such as: Click **More info** → **Run anyway**. -## 5. Open Command Prompt or PowerShell +### 5. Path refresh +The installer adds `jbeam-edit` to your **PATH**, but: +- You must **open a new Command Prompt or PowerShell window** after installation. +- In some cases, you may need to **log out or restart Windows** for the PATH change to take effect. +- If it still doesn’t work, you can run it directly using the full path, e.g.: -Press **Win + R**, type `cmd` (or `powershell`), and press **Enter**. +```powershell +"C:\Program Files (x86)\jbeam_edit\jbeam-edit.exe" your-file.jbeam +``` -## 6. Run jbeam-edit on a file +### 6. Open Command Prompt or PowerShell +Press **`Win + R`**, type `cmd` or `powershell`, and hit **Enter**. -Navigate to your project in CMD: +### 7. Run jbeam-edit on a file +Navigate to your project folder in CMD/PowerShell and run: ```powershell jbeam-edit your-file.jbeam ``` -Replace `your-file.jbeam` with the path to the JBeam file you want to format. - -Typical workflow: - -- Parses and formats the file. -- Sorts and renames nodes, updating references. -- Writes output back with a `.bak` backup by default. +Replace `your-file.jbeam` with the path to your JBeam file. -In-place editing (no backup): +#### Typical workflow: +- Parses and formats the file. +- Sorts and renames nodes, updating references. +- Writes the output back with a `.bak` backup (default). +#### In-place editing (no backup): ```powershell jbeam-edit -i example.jbeam ``` From 752c262936728f3c30854059cd94684d83c766ee Mon Sep 17 00:00:00 2001 From: webdevred <148627186+webdevred@users.noreply.github.com> Date: Thu, 21 Aug 2025 12:26:39 +0200 Subject: [PATCH 18/18] Update checkout action --- .github/workflows/build-and-release.yaml | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/.github/workflows/build-and-release.yaml b/.github/workflows/build-and-release.yaml index a939b1f6..9423dd95 100644 --- a/.github/workflows/build-and-release.yaml +++ b/.github/workflows/build-and-release.yaml @@ -28,7 +28,7 @@ jobs: strategy: matrix: ${{ fromJSON(needs.get-newest-supported-ghc.outputs.matrix) }} steps: - - uses: actions/checkout@v4 + - uses: actions/checkout@v5.0.0 - name: Set up GHC latest and Cabal id: setup-ghc uses: haskell-actions/setup@v2.8.1 @@ -77,7 +77,7 @@ jobs: steps: - uses: actions/checkout@v4 - name: Download build artifact - uses: actions/download-artifact@v4 + uses: actions/download-artifact@v5.0.0 with: name: jbeam-edit-${{ matrix.ghc }} path: dist-newstyle