Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
35 changes: 35 additions & 0 deletions .github/scripts/copy-example-files.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,35 @@
#!/usr/bin/env bash
set -euo pipefail

CABAL_FILE="${CABAL_FILE:?Environment variable CABAL_FILE is required}"
DEST_DIR_RELEASE="${RELEASE_DIR:?Environment variable RELEASE_DIR is required}"
DEST_DIR_ZIP="${ZIP_DIR:?Environment variable ZIP_DIR is required}"

[[ -f "$CABAL_FILE" ]] || { echo "Error: cabal file '$CABAL_FILE' does not exist"; exit 1; }
mkdir -p "$DEST_DIR_RELEASE"
mkdir -p "$DEST_DIR_ZIP"

get_cabal_field() {
local cabal_file="$1"
local field="$2"
awk -v field="$field" '
BEGIN { in_field=0 }
$0 ~ "^"field":" { in_field=1; next }
in_field && /^[^[:space:]]/ { in_field=0 }
in_field { gsub(/^[[:space:]]+/, ""); print }
' "$cabal_file"
}

while IFS= read -r file; do
[[ -z "$file" ]] && continue
mkdir -p "$(dirname "$DEST_DIR_RELEASE/$file")"
cp -r "$file" "$DEST_DIR_RELEASE/$file"
mkdir -p "$(dirname "$DEST_DIR_ZIP/$file")"
cp -r "$file" "$DEST_DIR_ZIP/$file"
done < <(get_cabal_field "$CABAL_FILE" "data-files")

while IFS= read -r file; do
[[ -z "$file" ]] && continue
mkdir -p "$(dirname "$DEST_DIR_ZIP/$file")"
cp -r "$file" "$DEST_DIR_ZIP/$file"
done < <(get_cabal_field "$CABAL_FILE" "extra-source-files")
17 changes: 17 additions & 0 deletions .github/scripts/copy-exe-to-release.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
#!/usr/bin/env bash
set -euo pipefail

DIST_NEWSTYLE="${DIST_NEWSTYLE:?Environment variable DIST_NEWSTYLE is required}"
RELEASE_DIR="${RELEASE_DIR:?Environment variable RELEASE_DIR is required}"

mkdir -p "$RELEASE_DIR"

EXE_PATH=$(find "$DIST_NEWSTYLE/build" -type f -name "*.exe" | head -n 1)

if [ -z "$EXE_PATH" ]; then
echo "Error: No exe found in '$DIST_NEWSTYLE/build'. Make sure the build step succeeded."
exit 1
fi

cp "$EXE_PATH" "$RELEASE_DIR/jbeam-edit.exe"
echo "Copied exe to $RELEASE_DIR/jbeam-edit.exe"
27 changes: 27 additions & 0 deletions .github/scripts/prepare-release.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
#!/usr/bin/env bash

set -euo pipefail

RELEASE_DIR="${RELEASE_DIR:?Environment variable RELEASE_DIR is required}"
ZIP_DIR="${ZIP_DIR:?Environment variable ZIP_DIR is required}"
ZIP_FILE="${ZIP_FILE:-dist/jbeam-edit-${GITHUB_REF_NAME}.zip}"

mkdir -p "$ZIP_DIR"
mkdir -p "$(dirname "$ZIP_FILE")"

SETUP_EXE="installer/Output/setup.exe"
if [ ! -f "$SETUP_EXE" ]; then
echo "Error: setup.exe not found in release folder '$RELEASE_DIR'. Make sure Inno Setup ran successfully."
exit 1
fi

cp "$SETUP_EXE" "$ZIP_DIR/"

for f in README.md JBFL_DOCS.md LICENSE; do
SRC="$RELEASE_DIR/$f"
if [ -f "$SRC" ]; then
cp "$SRC" "$ZIP_DIR/"
else
echo "Warning: $f not found in release folder, skipping."
fi
done
55 changes: 17 additions & 38 deletions .github/workflows/build-and-release.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -74,61 +74,40 @@ jobs:
name: Release for Windows
strategy:
matrix: ${{ fromJSON(needs.get-newest-supported-ghc.outputs.matrix) }}
env:
RELEASE_DIR: dist/release
ZIP_DIR: dist/zip_temp
DIST_NEWSTYLE: dist-newstyle
CABAL_FILE: jbeam-edit.cabal
steps:
- uses: actions/checkout@v5
- name: Download build artifact
uses: actions/download-artifact@v5.0.0
with:
name: jbeam-edit-${{ matrix.ghc }}
path: dist-newstyle
- name: Prepare release folder
run: |
$ErrorActionPreference = 'Stop'
$releaseDir = "$env:GITHUB_WORKSPACE\dist\release"
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" -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."
}
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
path: ${{ env.DIST_NEWSTYLE }}
- name: Extract files from cabal
shell: bash
run: bash .github/scripts/copy-example-files.sh
- name: Copy exe to release folder
shell: bash
run: bash .github/scripts/copy-exe-to-release.sh
- name: Build Inno Setup Installer
uses: Minionguyjpro/Inno-Setup-Action@v1.2.6
with:
path: installer/setup.iss
options: /O+
- 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
- name: Prepare release
shell: bash
run: bash .github/scripts/prepare-release.sh
- name: Package the release
shell: powershell
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:
Expand Down
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@ cabal.project.local
cabal.project.local~
cabal.project.*.local
dist-newstyle/
dist/
TAGS
.stack-work/
.ghc.environment.*
Expand Down
3 changes: 3 additions & 0 deletions jbeam-edit.cabal
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,9 @@ data-files:
extra-source-files:
README.md
JBFL_DOCS.md
examples/README.md
examples/jbeam/fender.jbeam
examples/jbeam/suspension.jbeam

source-repository head
type: git
Expand Down
8 changes: 7 additions & 1 deletion package.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,13 @@ author: webdevred
maintainer: example@example.com
copyright: 2025 webdevred
data-files: examples/jbfl/*.jbfl
extra-source-files: [README.md, JBFL_DOCS.md]

extra-source-files:
- README.md
- JBFL_DOCS.md
- examples/README.md
- examples/jbeam/*.jbeam

description: Please see the README on GitHub at <https://github.com/webdevred/jbeam-edit#readme>
tested-with: [GHC == 9.4.7, GHC == 9.6.6]

Expand Down
Loading