Skip to content

Commit 298b9e1

Browse files
committed
Refactor Windows build to use batch scripts
1 parent 5934166 commit 298b9e1

File tree

3 files changed

+62
-39
lines changed

3 files changed

+62
-39
lines changed

.github/workflows/build-installers.yml

Lines changed: 3 additions & 39 deletions
Original file line numberDiff line numberDiff line change
@@ -98,33 +98,9 @@ jobs:
9898
ruby-version: '3.2.2'
9999
bundler-cache: false # We manage gems manually via openstudio_meta
100100

101-
- name: Download and Install OpenStudio
102-
shell: powershell
103-
run: |
104-
$Version = "${{ env.OPENSTUDIO_VERSION }}"
105-
$Ext = "${{ env.OPENSTUDIO_VERSION_EXT }}"
106-
$Sha = "${{ env.OPENSTUDIO_VERSION_SHA }}"
107-
$InstallerName = "OpenStudio-$Version$Ext+$Sha-Windows.exe"
108-
$Url = "https://github.com/NREL/OpenStudio/releases/download/v$Version$Ext/$InstallerName"
109-
110-
Write-Host "Downloading $Url..."
111-
Invoke-WebRequest -Uri $Url -OutFile $InstallerName
112-
113-
Write-Host "Installing OpenStudio..."
114-
Start-Process -FilePath ".\$InstallerName" -ArgumentList "/S /D=C:\projects\openstudio" -Wait
115-
116-
# Verify
117-
$env:Path = "C:\projects\openstudio\bin;$env:Path"
118-
openstudio openstudio_version
119-
120-
- name: Setup MSYS2 and Dependencies
101+
- name: Setup Windows Environment
121102
shell: cmd
122-
run: |
123-
ridk install 2 3
124-
125-
REM Mimic setup.cmd gcc installation if needed, but standard ruby setup usually suffices.
126-
REM Checking gcc version
127-
gcc --version
103+
run: ci\github-actions\setup_win.bat
128104

129105
- name: Build Gem Package
130106
shell: cmd
@@ -134,19 +110,7 @@ jobs:
134110
GEM_PATH: C:\projects\openstudio-server\gems;C:\projects\openstudio-server\gems\bundler\gems
135111
RUBYLIB: C:\projects\openstudio\Ruby
136112
OPENSTUDIO_TEST_EXE: C:\projects\openstudio\bin\openstudio.exe
137-
run: |
138-
REM Create export directory
139-
mkdir C:\export
140-
141-
REM Install Bundler
142-
gem install bundler -v %BUNDLE_VERSION% --no-document
143-
144-
REM Run Build
145-
ruby bin\openstudio_meta install_gems --export="C:\export" --debug
146-
147-
REM Move export to workspace for upload
148-
mkdir build\NREL
149-
move C:\export build\NREL\export
113+
run: ci\github-actions\export_build_win.bat
150114

151115
- name: Upload Windows Artifact
152116
uses: actions/upload-artifact@v4
Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,20 @@
1+
@echo off
2+
setlocal
3+
4+
REM Create export directory
5+
if not exist "C:\export" mkdir C:\export
6+
7+
REM Install Bundler
8+
call gem install bundler -v %BUNDLE_VERSION% --no-document
9+
if %ERRORLEVEL% neq 0 exit /b %ERRORLEVEL%
10+
11+
REM Run Build
12+
call ruby bin\openstudio_meta install_gems --export="C:\export" --debug
13+
if %ERRORLEVEL% neq 0 exit /b %ERRORLEVEL%
14+
15+
REM Move export to workspace for upload
16+
if not exist "build\NREL" mkdir build\NREL
17+
move C:\export build\NREL\export
18+
if %ERRORLEVEL% neq 0 exit /b %ERRORLEVEL%
19+
20+
endlocal

ci/github-actions/setup_win.bat

Lines changed: 39 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,39 @@
1+
@echo off
2+
setlocal
3+
4+
REM --- Install OpenStudio ---
5+
set "InstallerName=OpenStudio-%OPENSTUDIO_VERSION%%OPENSTUDIO_VERSION_EXT%+%OPENSTUDIO_VERSION_SHA%-Windows.exe"
6+
set "Url=https://github.com/NREL/OpenStudio/releases/download/v%OPENSTUDIO_VERSION%%OPENSTUDIO_VERSION_EXT%/%InstallerName%"
7+
8+
echo Downloading %Url%...
9+
powershell -Command "Invoke-WebRequest -Uri '%Url%' -OutFile '%InstallerName%'"
10+
if %ERRORLEVEL% neq 0 (
11+
echo Error downloading OpenStudio
12+
exit /b %ERRORLEVEL%
13+
)
14+
15+
echo Installing OpenStudio...
16+
start /wait "" ".\%InstallerName%" /S /D=C:\projects\openstudio
17+
if %ERRORLEVEL% neq 0 (
18+
echo Error installing OpenStudio
19+
exit /b %ERRORLEVEL%
20+
)
21+
22+
REM Verify OpenStudio
23+
set "PATH=C:\projects\openstudio\bin;%PATH%"
24+
call openstudio openstudio_version
25+
if %ERRORLEVEL% neq 0 (
26+
echo Error verifying OpenStudio
27+
exit /b %ERRORLEVEL%
28+
)
29+
30+
REM --- Setup MSYS2 and Dependencies ---
31+
call ridk install 2 3
32+
if %ERRORLEVEL% neq 0 (
33+
echo Error running ridk install
34+
exit /b %ERRORLEVEL%
35+
)
36+
37+
call gcc --version
38+
39+
endlocal

0 commit comments

Comments
 (0)