Skip to content

Commit 3db95d9

Browse files
authored
Add: files and workflow to make installer on release. (#616)
1 parent 9dc068d commit 3db95d9

File tree

3 files changed

+189
-0
lines changed

3 files changed

+189
-0
lines changed

.github/workflows/CI.yml

Lines changed: 77 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -166,11 +166,88 @@ jobs:
166166
name: ${{ env.FPM_RELEASE }}
167167
path: ${{ env.FPM_RELEASE }}
168168

169+
170+
make-installer:
171+
if: ${{ github.event_name == 'release' && contains(github.ref, 'v') || github.event_name == 'push' }}
172+
runs-on: windows-latest
173+
needs:
174+
- build
175+
176+
steps:
177+
- uses: actions/checkout@v2
178+
179+
- name: Download Artifacts
180+
uses: actions/download-artifact@v2
181+
with:
182+
path: ${{ github.workspace }} # This will download all files
183+
184+
- name: Get version (normal)
185+
if: github.event_name != 'release'
186+
shell: bash
187+
run: |
188+
VERSION=$(git rev-parse --short HEAD)
189+
echo "VERSION=$VERSION" >> $GITHUB_ENV
190+
191+
- name: Get version (release)
192+
if: github.event_name == 'release'
193+
shell: bash
194+
run: |
195+
VERSION=$(echo ${{ github.ref }} | cut -dv -f2)
196+
echo "VERSION=$VERSION" >> $GITHUB_ENV
197+
env:
198+
REGEX: '[0-9]\{1,4\}\.[0-9]\{1,4\}\.[0-9]\{1,4\}'
199+
200+
- name: Setup MinGW (MSYS2)
201+
uses: msys2/setup-msys2@v2
202+
with:
203+
msystem: MINGW64
204+
update: false
205+
install: >-
206+
wget
207+
unzip
208+
209+
- name: Fetch Windows executable
210+
shell: msys2 {0}
211+
run: |
212+
cp fpm-*/fpm*.exe ./ci/fpm.exe
213+
214+
- name: Fetch Git for Windows
215+
shell: msys2 {0}
216+
run: |
217+
cd ./ci
218+
wget ${{ env.git_download }} -O MinGit.zip
219+
unzip MinGit.zip -d MinGit
220+
env:
221+
git_download: "https://github.com/git-for-windows/git/releases/download/v2.33.1.windows.1/MinGit-2.33.1-64-bit.zip"
222+
223+
- name: Fetch EnVar Plugin for NSIS
224+
shell: msys2 {0}
225+
run: |
226+
cd ./ci
227+
wget ${{ env.envar_download }} -O EnVar-Plugin.zip
228+
mkdir EnVar_plugin
229+
unzip EnVar-Plugin.zip -d EnVar_plugin
230+
env:
231+
envar_download: "https://github.com/GsNSIS/EnVar/releases/download/v0.3.1/EnVar-Plugin.zip"
232+
233+
- name: Generate installer
234+
run: |
235+
cd ./ci
236+
makensis fpm-installer.nsi
237+
move fpm-installer.exe fpm-installer-${{ env.VERSION }}.exe
238+
239+
- name: Upload artifact
240+
uses: actions/upload-artifact@v2
241+
with:
242+
name: fpm-installer
243+
path: ci/fpm-installer-${{ env.VERSION }}.exe
244+
169245
upload-artifacts:
170246
if: ${{ github.event_name == 'release' && contains(github.ref, 'v') || github.event_name == 'push' }}
171247
runs-on: ubuntu-latest
172248
needs:
173249
- build
250+
- make-installer
174251

175252
steps:
176253
- id: deploy-on-push

ci/fpm-installer.nsi

Lines changed: 112 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,112 @@
1+
; NSIS Installer script for the Fortran Package Manager
2+
3+
; ---------------- Properties ----------------
4+
; Name used in installer GUI
5+
Name "Fortran Package Manager"
6+
7+
; Name for folder location and reg key
8+
!define INSTALL_NAME "fortran-lang"
9+
10+
; Installer icon
11+
!define MUI_ICON "installer-icon.ico"
12+
13+
; Compress installer
14+
SetCompress auto
15+
16+
; Always produce unicode installer
17+
Unicode true
18+
19+
; ---------------- Setup ----------------
20+
; Use EnVar plugin (https://nsis.sourceforge.io/EnVar_plug-in)
21+
!addplugindir ".\EnVar_plugin\Plugins\x86-unicode"
22+
23+
; Use the 'Modern' Installer UI macros
24+
!include "MUI2.nsh"
25+
26+
; Default installation folder (local)
27+
InstallDir "$LOCALAPPDATA\${INSTALL_NAME}"
28+
29+
; Get installation folder from registry if available
30+
InstallDirRegKey HKCU "Software\${INSTALL_NAME}" ""
31+
32+
; Request application privileges
33+
RequestExecutionLevel user
34+
35+
36+
; ---------------- Installer Pages ----------------
37+
!insertmacro MUI_PAGE_COMPONENTS
38+
!insertmacro MUI_PAGE_DIRECTORY
39+
!insertmacro MUI_PAGE_INSTFILES
40+
41+
42+
; ---------------- Uninstaller Pages ----------------
43+
!insertmacro MUI_UNPAGE_CONFIRM
44+
!insertmacro MUI_UNPAGE_INSTFILES
45+
46+
47+
; MUI Language
48+
!insertmacro MUI_LANGUAGE "English"
49+
50+
51+
; ---------------- Component: Core Installation ----------------
52+
Section "-Core" SecCore
53+
54+
SetOutPath "$INSTDIR"
55+
56+
; Store installation folder
57+
WriteRegStr HKCU "Software\${INSTALL_NAME}" "" $INSTDIR
58+
59+
; Create uninstaller
60+
WriteUninstaller "$INSTDIR\Uninstall.exe"
61+
62+
; Add to path
63+
EnVar::SetHKCU
64+
EnVar::AddValue "PATH" "$INSTDIR\fpm"
65+
EnVar::AddValue "PATH" "$INSTDIR\MinGit\mingw64\bin"
66+
67+
SectionEnd
68+
69+
70+
; ---------------- Component: fpm ----------------
71+
Section "FPM" SecFPM
72+
73+
SetOutPath "$INSTDIR\fpm"
74+
75+
File "fpm.exe"
76+
77+
SectionEnd
78+
79+
80+
; ---------------- Component: Git ----------------
81+
Section "Git for Windows" SecGit
82+
83+
SetOutPath "$INSTDIR"
84+
85+
File /r "MinGit"
86+
87+
SectionEnd
88+
89+
90+
; ---------------- Uninstaller ----------------
91+
Section "Uninstall"
92+
93+
RMDir /r "$INSTDIR"
94+
95+
DeleteRegKey /ifempty HKCU "Software\${INSTALL_NAME}"
96+
97+
EnVar::SetHKCU
98+
EnVar::DeleteValue "PATH" "$INSTDIR\fpm"
99+
EnVar::DeleteValue "PATH" "$INSTDIR\MinGit\mingw64\bin"
100+
101+
SectionEnd
102+
103+
104+
; ---------------- Component description Strings (EN) ----------------
105+
LangString DESC_SecFPM ${LANG_ENGLISH} "The Fortran Package Manager"
106+
LangString DESC_SecGit ${LANG_ENGLISH} "Git version control (required for FPM)"
107+
108+
109+
!insertmacro MUI_FUNCTION_DESCRIPTION_BEGIN
110+
!insertmacro MUI_DESCRIPTION_TEXT ${SecFPM} $(DESC_SecFPM)
111+
!insertmacro MUI_DESCRIPTION_TEXT ${SecGit} $(DESC_SecGit)
112+
!insertmacro MUI_FUNCTION_DESCRIPTION_END

ci/installer-icon.ico

16.6 KB
Binary file not shown.

0 commit comments

Comments
 (0)