Skip to content

Commit 5db9d55

Browse files
wojtekmachjosevalim
authored andcommitted
Add offline Windows installer to releases (#12640)
1 parent 3cb3d41 commit 5db9d55

File tree

6 files changed

+275
-3
lines changed

6 files changed

+275
-3
lines changed

.github/workflows/release.yml

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,7 @@ permissions:
1515

1616
jobs:
1717
create_draft_release:
18-
runs-on: ubuntu-20.04
18+
runs-on: ubuntu-22.04
1919
env:
2020
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
2121
steps:
@@ -40,7 +40,7 @@ jobs:
4040
- otp: 26
4141
otp_version: '26.0'
4242
build_docs: build_docs
43-
runs-on: ubuntu-20.04
43+
runs-on: ubuntu-22.04
4444
steps:
4545
- uses: actions/checkout@v3
4646
with:
@@ -56,7 +56,9 @@ jobs:
5656
run: |
5757
gh release upload --clobber "${{ github.ref_name }}" \
5858
elixir-otp-${{ matrix.otp }}.zip \
59-
elixir-otp-${{ matrix.otp }}.zip.sha{1,256}sum
59+
elixir-otp-${{ matrix.otp }}.zip.sha{1,256}sum \
60+
elixir-otp-${{ matrix.otp }}.exe \
61+
elixir-otp-${{ matrix.otp }}.exe.sha{1,256}sum
6062
- name: Upload Docs to GitHub
6163
if: ${{ matrix.build_docs }}
6264
env:

.github/workflows/release_pre_built/action.yml

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -22,6 +22,20 @@ runs:
2222
shasum -a 1 elixir-otp-${{ inputs.otp }}.zip > elixir-otp-${{ inputs.otp }}.zip.sha1sum
2323
shasum -a 256 elixir-otp-${{ inputs.otp }}.zip > elixir-otp-${{ inputs.otp }}.zip.sha256sum
2424
echo "$PWD/bin" >> $GITHUB_PATH
25+
- name: Install NSIS
26+
shell: bash
27+
run: |
28+
sudo apt update
29+
sudo apt install -y nsis
30+
- name: Build Elixir Windows Installer
31+
shell: bash
32+
run: |
33+
export OTP_VERSION=${{ inputs.otp_version }}
34+
export ELIXIR_ZIP=$PWD/elixir-otp-${{ inputs.otp }}.zip
35+
(cd lib/elixir/scripts/windows_installer && ./build.sh)
36+
mv lib/elixir/scripts/windows_installer/tmp/elixir-otp-${{ inputs.otp }}.exe .
37+
shasum -a 1 elixir-otp-${{ inputs.otp }}.exe > elixir-otp-${{ inputs.otp }}.exe.sha1sum
38+
shasum -a 256 elixir-otp-${{ inputs.otp }}.exe > elixir-otp-${{ inputs.otp }}.exe.sha256sum
2539
- name: Get latest stable ExDoc version
2640
if: ${{ inputs.build_docs }}
2741
shell: bash
Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
tmp/
Binary file not shown.
Lines changed: 46 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,46 @@
1+
#!/bin/bash
2+
# Usage:
3+
#
4+
# With Elixir archive:
5+
#
6+
# ELIXIR_ZIP=Precompiled.zip OTP_VERSION=25.3.2.2 ./build.sh
7+
#
8+
# With Elixir version:
9+
#
10+
# ELIXIR_VERSION=1.14.5 OTP_VERSION=25.3.2.2 ./build.sh
11+
set -euo pipefail
12+
13+
OTP_VERSION="${OTP_VERSION:-26.0}"
14+
otp_release=`echo "${OTP_VERSION}" | cut -d. -f1`
15+
16+
mkdir -p tmp
17+
18+
ELIXIR_VERSION="${ELIXIR_VERSION:-}"
19+
if [ -n "${ELIXIR_VERSION}" ]; then
20+
ELIXIR_ZIP="tmp/elixir-${ELIXIR_VERSION}-otp-${otp_release}.zip"
21+
if [ ! -f "${ELIXIR_ZIP}" ]; then
22+
url="https://github.com/elixir-lang/elixir/releases/download/v${ELIXIR_VERSION}/elixir-otp-${otp_release}.zip"
23+
echo "downloading ${url}"
24+
curl --fail -L -o "${ELIXIR_ZIP}" "${url}"
25+
fi
26+
basename=elixir-${ELIXIR_VERSION}-otp-${otp_release}
27+
else
28+
basename=elixir-otp-${otp_release}
29+
fi
30+
31+
if [ ! -d "tmp/${basename}" ]; then
32+
unzip -d "tmp/${basename}" "${ELIXIR_ZIP}"
33+
fi
34+
35+
# brew install makensis
36+
# apt install -y nsis
37+
# choco install -y nsis
38+
export PATH="/c/Program Files (x86)/NSIS:${PATH}"
39+
makensis \
40+
-X"OutFile tmp\\${basename}.exe" \
41+
-DOTP_VERSION=${OTP_VERSION} \
42+
-DOTP_RELEASE="${otp_release}" \
43+
-DELIXIR_DIR=tmp\\${basename} \
44+
installer.nsi
45+
46+
echo "Installer path: tmp/${basename}.exe"
Lines changed: 209 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,209 @@
1+
!include "MUI2.nsh"
2+
!include "StrFunc.nsh"
3+
${Using:StrFunc} StrStr
4+
${Using:StrFunc} UnStrStr
5+
${Using:StrFunc} UnStrRep
6+
7+
Name "Elixir"
8+
ManifestDPIAware true
9+
Unicode True
10+
InstallDir "$PROGRAMFILES64\Elixir"
11+
!define MUI_ICON "assets\drop.ico"
12+
13+
; Install Page: Install Erlang/OTP
14+
15+
Page custom CheckOTPPageShow CheckOTPPageLeave
16+
17+
var Dialog
18+
var DownloadOTPLink
19+
var InstalledERTSVersion
20+
var InstalledOTPRelease
21+
var OTPPath
22+
Function CheckOTPPageShow
23+
!insertmacro MUI_HEADER_TEXT "Checking Erlang/OTP" ""
24+
25+
nsDialogs::Create 1018
26+
Pop $Dialog
27+
28+
${If} $Dialog == error
29+
Abort
30+
${EndIf}
31+
32+
EnumRegKey $0 HKLM "SOFTWARE\WOW6432NODE\Ericsson\Erlang" 0
33+
ReadRegStr $1 HKLM "SOFTWARE\WOW6432NODE\Ericsson\Erlang\$0" ""
34+
StrCpy $InstalledERTSVersion $0
35+
StrCpy $OTPPath $1
36+
37+
${If} $1 == ""
38+
${NSD_CreateLabel} 0 0 100% 20u "Couldn't find existing Erlang/OTP installation. Click the link below to download and install it before proceeding."
39+
${NSD_CreateLink} 0 25u 100% 20u "Download Erlang/OTP ${OTP_RELEASE}"
40+
Pop $DownloadOTPLink
41+
${NSD_OnClick} $DownloadOTPLink OpenOTPDownloads
42+
${Else}
43+
nsExec::ExecToStack `$OTPPath\bin\erl.exe -noinput -eval "\
44+
io:put_chars(erlang:system_info(otp_release)),\
45+
halt()."`
46+
Pop $0
47+
Pop $1
48+
49+
${If} $0 == 0
50+
StrCpy $InstalledOTPRelease $1
51+
${If} $InstalledOTPRelease == ${OTP_RELEASE}
52+
${NSD_CreateLabel} 0 0 100% 20u "Found existing Erlang/OTP $InstalledOTPRelease installation at $OTPPath. Please proceed."
53+
${ElseIf} $2 < ${OTP_RELEASE}
54+
${NSD_CreateLabel} 0 0 100% 30u "Found existing Erlang/OTP $InstalledOTPRelease installation at $OTPPath but this Elixir installer was precompiled for Erlang/OTP ${OTP_RELEASE}. \
55+
We recommend checking if there is an Elixir version precompiled for Erlang/OTP $InstalledOTPRelease. Otherwise, proceed."
56+
${Else}
57+
SetErrorlevel 5
58+
MessageBox MB_ICONSTOP "Found existing Erlang/OTP $InstalledOTPRelease installation at $OTPPath but this Elixir version was precompiled for Erlang/OTP ${OTP_RELEASE}. \
59+
Please upgrade your Erlang/OTP version or choose an Elixir installer matching your Erlang/OTP version"
60+
Quit
61+
${EndIf}
62+
${Else}
63+
SetErrorlevel 5
64+
MessageBox MB_ICONSTOP "Found existing Erlang/OTP installation at $OTPPath but checking it exited with $0: $1"
65+
Quit
66+
${EndIf}
67+
${EndIf}
68+
69+
nsDialogs::Show
70+
FunctionEnd
71+
72+
Function OpenOTPDownloads
73+
ExecShell "open" "https://www.erlang.org/downloads/${OTP_RELEASE}"
74+
FunctionEnd
75+
76+
Function CheckOTPPageLeave
77+
FunctionEnd
78+
79+
; Install Page: Files
80+
81+
!insertmacro MUI_PAGE_DIRECTORY
82+
!insertmacro MUI_PAGE_INSTFILES
83+
84+
; Install Page: Finish
85+
86+
Page custom FinishPageShow FinishPageLeave
87+
88+
var AddOTPToPathCheckbox
89+
var AddElixirToPathCheckbox
90+
Function FinishPageShow
91+
!insertmacro MUI_HEADER_TEXT "Finish Setup" ""
92+
93+
nsDialogs::Create 1018
94+
Pop $Dialog
95+
96+
${If} $Dialog == error
97+
Abort
98+
${EndIf}
99+
100+
${NSD_CreateCheckbox} 0 0 195u 10u "&Add $INSTDIR\bin to %PATH%"
101+
Pop $AddElixirToPathCheckbox
102+
SendMessage $AddElixirToPathCheckbox ${BM_SETCHECK} ${BST_CHECKED} 0
103+
104+
EnumRegKey $0 HKLM "SOFTWARE\WOW6432NODE\Ericsson\Erlang" 0
105+
ReadRegStr $0 HKLM "SOFTWARE\WOW6432NODE\Ericsson\Erlang\$0" ""
106+
StrCpy $OTPPath $0
107+
${If} $0 != ""
108+
${NSD_CreateCheckbox} 0 20u 195u 10u "&Add $0\bin to %PATH%"
109+
Pop $AddOTPToPathCheckbox
110+
SendMessage $AddOTPToPathCheckbox ${BM_SETCHECK} ${BST_CHECKED} 0
111+
${EndIf}
112+
113+
nsDialogs::Show
114+
FunctionEnd
115+
116+
Function FinishPageLeave
117+
${NSD_GetState} $AddOTPToPathCheckbox $0
118+
${If} $0 <> ${BST_UNCHECKED}
119+
ReadRegStr $0 HKCU "Environment" "Path"
120+
${StrStr} $1 "$0" "$OTPPath\bin"
121+
${If} $1 == ""
122+
WriteRegExpandStr HKCU "Environment" "Path" "$OTPPath\bin;$0"
123+
${Else}
124+
MessageBox MB_OK "$OTPPath\bin already in %PATH%"
125+
${EndIf}
126+
${EndIf}
127+
128+
${NSD_GetState} $AddElixirToPathCheckbox $0
129+
${If} $0 <> ${BST_UNCHECKED}
130+
ReadRegStr $0 HKCU "Environment" "Path"
131+
${StrStr} $1 "$0" "$INSTDIR\bin"
132+
${If} $1 == ""
133+
WriteRegExpandStr HKCU "Environment" "Path" "$INSTDIR\bin;$0"
134+
${Else}
135+
MessageBox MB_OK "$INSTDIR\bin already in %PATH%"
136+
${EndIf}
137+
${EndIf}
138+
FunctionEnd
139+
140+
Section "Install Elixir" SectionElixir
141+
SetOutPath "$INSTDIR"
142+
File /r "${ELIXIR_DIR}\"
143+
144+
WriteUninstaller "Uninstall.exe"
145+
SectionEnd
146+
147+
; Uninstall Page: Files
148+
149+
!insertmacro MUI_UNPAGE_DIRECTORY
150+
!insertmacro MUI_UNPAGE_INSTFILES
151+
152+
Section "Uninstall"
153+
RMDir /r "$INSTDIR"
154+
SectionEnd
155+
156+
; Uninstall Page: Finish
157+
158+
var RemoveOTPFromPathCheckbox
159+
var RemoveElixirFromPathCheckbox
160+
Function un.FinishPageShow
161+
!insertmacro MUI_HEADER_TEXT "Finish Setup" ""
162+
163+
nsDialogs::Create 1018
164+
Pop $Dialog
165+
166+
${If} $Dialog == error
167+
Abort
168+
${EndIf}
169+
170+
ReadRegStr $0 HKCU "Environment" "Path"
171+
${UnStrStr} $1 "$0" "$INSTDIR\bin"
172+
${If} $1 != ""
173+
${NSD_CreateCheckbox} 0 0 195u 10u "&Remove $INSTDIR\bin from %PATH%"
174+
Pop $RemoveElixirFromPathCheckbox
175+
SendMessage $RemoveElixirFromPathCheckbox ${BM_SETCHECK} ${BST_CHECKED} 0
176+
${EndIf}
177+
178+
EnumRegKey $1 HKLM "SOFTWARE\WOW6432NODE\Ericsson\Erlang" 0
179+
ReadRegStr $1 HKLM "SOFTWARE\WOW6432NODE\Ericsson\Erlang\$1" ""
180+
StrCpy $OTPPath $1
181+
${UnStrStr} $1 "$0" "$OTPPath\bin"
182+
${If} $1 != ""
183+
${NSD_CreateCheckbox} 0 20u 195u 10u "&Remove $OTPPath\bin from %PATH%"
184+
Pop $RemoveOTPFromPathCheckbox
185+
SendMessage $RemoveOTPFromPathCheckbox ${BM_SETCHECK} ${BST_CHECKED} 0
186+
${EndIf}
187+
188+
nsDialogs::Show
189+
FunctionEnd
190+
191+
Function un.FinishPageLeave
192+
ReadRegStr $0 HKCU "Environment" "Path"
193+
194+
${NSD_GetState} $RemoveOTPFromPathCheckbox $1
195+
${If} $1 <> ${BST_UNCHECKED}
196+
${UnStrRep} $0 "$0" "$OTPPath\bin;" ""
197+
${EndIf}
198+
199+
${NSD_GetState} $RemoveElixirFromPathCheckbox $1
200+
${If} $1 <> ${BST_UNCHECKED}
201+
${UnStrRep} $0 "$0" "$INSTDIR\bin;" ""
202+
${EndIf}
203+
204+
WriteRegExpandStr HKCU "Environment" "Path" "$0"
205+
FunctionEnd
206+
207+
UninstPage custom un.FinishPageShow un.FinishPageLeave
208+
209+
!insertmacro MUI_LANGUAGE "English"

0 commit comments

Comments
 (0)