Skip to content

Commit a063cce

Browse files
authored
Merge pull request #273 from auth0/ium-2759-use-github-runner
feat: use github runner to build releases
2 parents 85f5ad5 + 19ec2f3 commit a063cce

File tree

5 files changed

+51
-223
lines changed

5 files changed

+51
-223
lines changed
Lines changed: 41 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,41 @@
1+
name: Build AD-LDAP Connector Windows Installer
2+
3+
on:
4+
push:
5+
tags:
6+
- "v*.*.*"
7+
jobs:
8+
Build-Windows-Installer:
9+
runs-on: windows-latest
10+
if: ${{ startsWith(github.ref, 'refs/tags/') && github.event.base_ref == 'refs/heads/master' }}
11+
steps:
12+
- run: echo "🎉 The job was automatically triggered by a ${{ github.event_name }} event."
13+
- run: echo "🐧 This job is now running on a ${{ runner.os }} server hosted by GitHub!"
14+
- run: echo "🔎 The name of your branch is ${{ github.ref }} + ${{ github.event.base_ref }} and your repository is ${{ github.repository }}."
15+
- name: Check out repository code
16+
uses: actions/checkout@v4
17+
- run: echo "💡 The ${{ github.repository }} repository has been cloned to the runner."
18+
- run: echo "🖥️ The workflow is now ready to test your code on the runner."
19+
- name: Node
20+
uses: actions/setup-node@v4
21+
with:
22+
node-version-file: .nvmrc
23+
- name: Installer Dependencies
24+
run: |
25+
choco install wixtoolset
26+
cd installer
27+
./prepare.ps1
28+
Import-Module "$env:ChocolateyInstall/helpers/chocolateyInstaller.psm1"
29+
refreshenv
30+
- name: Application Dependencies
31+
run: |
32+
npm ci
33+
npm i -g rimraf
34+
- name: Build
35+
run: |
36+
cd installer
37+
./build.ps1
38+
- name: Release
39+
uses: softprops/action-gh-release@v2
40+
with:
41+
files: installer/output/adldap.msi

installer/build.ps1

Lines changed: 5 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -3,9 +3,9 @@ $ErrorActionPreference = "Stop"
33

44
$ProjectPath = [System.IO.Path]::GetFullPath("$PSScriptRoot\..\") -replace "\\$"
55
$ProjectPathUnix = $ProjectPath.replace("\", "/")
6-
$InstallerPath = "$ProjectPath\Installer"
6+
$InstallerPath = "$ProjectPath\installer"
77

8-
echo "installer path is $InstallerPath"
8+
echo "Installer path is $InstallerPath"
99

1010
# remember to manually remove this after npm install... it fails because the path is too long.
1111
# rimraf "..\node_modules\jsonwebtoken\node_modules\jws\node_modules\base64url\node_modules\tap"
@@ -58,11 +58,9 @@ $version = $version.Trim()
5858
$nodeBin = (gcm node).Path
5959

6060
#Generate the installer
61-
$wix_dir="c:\Program Files (x86)\WiX Toolset v3.11\bin"
62-
63-
. "$wix_dir\heat.exe" dir $tmp_dir -srd -dr INSTALLDIR -cg MainComponentGroup -out $InstallerPath\directory.wxs -ke -sfrag -gg -var var.SourceDir -sreg -scom
64-
. "$wix_dir\candle.exe" -dNodeBin="$nodeBin" -dSourceDir="$tmp_dir" -dProductVersion="$version" -dRTMProductVersion="0.0.0" -dUpgradeCode="{1072AB9E-1842-4AFA-9CF2-545462CD60E2}" $InstallerPath\*.wxs -o $InstallerPath\output\ -ext WiXUtilExtension
65-
. "$wix_dir\light.exe" -o $InstallerPath\output\adldap.msi $InstallerPath\output\*.wixobj -cultures:en-US -ext WixUIExtension.dll -ext WiXUtilExtension -ext WiXNetFxExtension
61+
. "heat.exe" dir $tmp_dir -srd -dr INSTALLDIR -cg MainComponentGroup -out $InstallerPath\directory.wxs -ke -sfrag -gg -var var.SourceDir -sreg -scom
62+
. "candle.exe" -dNodeBin="$nodeBin" -dSourceDir="$tmp_dir" -dProductVersion="$version" -dRTMProductVersion="0.0.0" -dUpgradeCode="{1072AB9E-1842-4AFA-9CF2-545462CD60E2}" $InstallerPath\*.wxs -o $InstallerPath\output\ -ext WiXUtilExtension
63+
. "light.exe" -o $InstallerPath\output\adldap.msi $InstallerPath\output\*.wixobj -cultures:en-US -ext WixUIExtension.dll -ext WiXUtilExtension -ext WiXNetFxExtension
6664
# . "C:\Program Files (x86)\Microsoft SDKs\Windows\v7.1A\Bin\signtool.exe" sign /n "Auth0" $InstallerPath\output\adldap.msi
6765

6866
#Remove the temp

installer/installer.wxs

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -89,10 +89,6 @@
8989
</Component>
9090
<Component Id="nssm_component" Guid="{07D39AAA-CBB2-4F3F-BC22-EC7AE4963FFF}" Directory="INSTALLDIR">
9191
<File Id="nssm" KeyPath="yes" Source="C:\Program Files (x86)\nssm-2.24\win32\nssm.exe" />
92-
<!-- <RemoveFile Id="RemoveConfigJson"
93-
Name="config.json"
94-
On="uninstall" /> -->
95-
9692
<ServiceControl Id="ControlAdminService"
9793
Name="Auth0 ADLDAP Admin"
9894
Remove="uninstall"

installer/prepare.ps1

Lines changed: 4 additions & 211 deletions
Original file line numberDiff line numberDiff line change
@@ -1,44 +1,4 @@
1-
$exeDependencies = @(
2-
@{
3-
'Name'='git';
4-
'Url'='https://github.com/git-for-windows/git/releases/download/v2.9.2.windows.1/Git-2.9.2-32-bit.exe';
5-
'Args'=@('/silent';'/norestart');
6-
'Test'=@{
7-
'Cmd'='git';
8-
'Args'=@('--version')
9-
}
10-
} )
11-
12-
$msiDependencies = @(
13-
@{
14-
'Name'='Python';
15-
'Url'="https://www.python.org/ftp/python/2.7.12/python-2.7.12.msi";
16-
'Path'='C:\Python27\'
17-
'Test'=@{
18-
'Cmd'='C:\Python27\python.exe';
19-
'Args'=@('-V')
20-
}
21-
} ;
22-
@{
23-
'Name'='nodejs';
24-
'Url'="https://nodejs.org/dist/v12.19.0/node-v12.19.0-x86.msi";
25-
'Path' = 'C:\Program Files (x86)\nodejs'
26-
'Test'=@{
27-
'Cmd'='C:\Program Files (x86)\nodejs\node.exe';
28-
'Args'=@('-v')
29-
}
30-
} )
31-
321
$zipDependencies = @(
33-
@{
34-
'Name'='Wix';
35-
'Url'="https://wix.codeplex.com/downloads/get/1587180";
36-
'Path'= "C:\Program Files (x86)\WiX Toolset v3.8\bin"
37-
'Test'=@{
38-
'Cmd'='C:\Program Files (x86)\WiX Toolset v3.8\bin\heat.exe';
39-
'Args'=@('-?')
40-
}
41-
} ;
422
@{
433
'Name'='nssm';
444
'Url'="http://nssm.cc/release/nssm-2.24.zip";
@@ -48,11 +8,6 @@ $zipDependencies = @(
488
}
499
} )
5010

51-
$npmPackages = @(
52-
@{'Name'='npm'; 'Version'="6.14.8"} ;
53-
@{'Name'='node-gyp'; 'Version'="3.4.0"}
54-
)
55-
5611
function Get-TempPath
5712
{
5813
[io.path]::GetTempPath()
@@ -63,107 +18,6 @@ function Get-TempFileName
6318
[io.path]::GetTempFileName()
6419
}
6520

66-
function Test-Command
67-
{
68-
param(
69-
[Parameter(Mandatory=$true)] $Command
70-
)
71-
72-
try
73-
{
74-
$result = $true;
75-
if ($Command.Cmd -ne $null)
76-
{
77-
if ($Command.Args -eq $null)
78-
{
79-
$Command.Args = @();
80-
}
81-
82-
$process = Start-Process -Wait -PassThru -File $Command.Cmd -ArgumentList $Command.Args -NoNewWindow
83-
$result = $result -and ($process.exitCode -eq 0)
84-
}
85-
86-
if ($Command.Path -ne $null)
87-
{
88-
$result = $result -and (Test-Path $Command.Path)
89-
}
90-
91-
$result
92-
}
93-
catch
94-
{
95-
$false
96-
}
97-
}
98-
99-
function Expand-ZipFile
100-
{
101-
param(
102-
[Parameter(Mandatory=$true)][String] $File,
103-
[Parameter(Mandatory=$true)][String] $Path
104-
)
105-
106-
if (-not (Test-Path $Path) )
107-
{
108-
Write-Verbose "Creting Directory $Path"
109-
New-Item -Path $Path -ItemType directory -force | Out-Null
110-
}
111-
112-
$shell = New-Object -com Shell.Application
113-
$zip = $shell.NameSpace($File)
114-
foreach($item in $zip.items())
115-
{
116-
$shell.Namespace($Path).copyhere($item)
117-
}
118-
}
119-
120-
function InstallFrom-Exe
121-
{
122-
param(
123-
[Parameter(Mandatory=$true)][String] $Url,
124-
[Parameter(Mandatory=$false)]$Args= @(),
125-
[Parameter(Mandatory=$false)][String] $TempFile = (Get-TempFileName) + '.exe'
126-
)
127-
128-
Write-Verbose " ==>Downloading executable $Url ==> $TempFile"
129-
Invoke-WebRequest -Uri $Url -OutFile $TempFile
130-
131-
Write-Verbose "Starting process"
132-
133-
Start-Process -Wait -Verb runas -FilePath $TempFile -ArgumentList $Args
134-
135-
Write-Debug "Removing $TempFile"
136-
Remove-Item $TempFile
137-
}
138-
139-
function InstallFrom-Url
140-
{
141-
param(
142-
[Parameter(Mandatory=$true)][String] $Url,
143-
[Parameter(Mandatory=$false)][String] $Path= $null,
144-
[Parameter(Mandatory=$false)][String] $TempFile = (Get-TempFileName)
145-
)
146-
147-
Write-Verbose " ==>Downloading installer $Url ==> $TempFile"
148-
Invoke-WebRequest -Uri $Url -OutFile $TempFile
149-
150-
Write-Verbose "Starting msiexec process"
151-
$args = @("/i";$TempFile;"/qb")
152-
if ($Path -ne $null)
153-
{
154-
$args = @("/i";$TempFile;"TARGETDIR=`"$Path`""; "INSTALLDIR=`"$Path`"", "/qb")
155-
}
156-
else
157-
{
158-
$args = @("/i";$TempFile;"/qb")
159-
}
160-
161-
Start-Process -Wait -Verb runas -FilePath msiexec -ArgumentList $args
162-
163-
Write-Debug "Removing $TempFile"
164-
Remove-Item $TempFile
165-
}
166-
16721
function UnpackFrom-Url
16822
{
16923
param(
@@ -178,37 +32,7 @@ function UnpackFrom-Url
17832
Invoke-WebRequest -Uri $Url -OutFile $TempFile
17933

18034
Write-Verbose "Unpacking file into $Path"
181-
Expand-ZipFile -File $TempFile -Path $Path
182-
183-
Write-Debug "Removing $TempFile"
184-
#Remove-Item $TempFile
185-
}
186-
187-
function Install-NpmPackage
188-
{
189-
param(
190-
[Parameter(Mandatory=$true)][String] $Name,
191-
[Parameter(Mandatory=$false)][String] $Version=$null,
192-
[Parameter(Mandatory=$false)][switch] $Global
193-
)
194-
195-
if ($Version -ne $null)
196-
{
197-
$Name = $Name + "@" + $Version
198-
}
199-
200-
Write-Verbose "Starting NPM install of package $Name"
201-
202-
if ($global)
203-
{
204-
$args = @("install";$Name; "-g")
205-
}
206-
else
207-
{
208-
$args = @("install";$Name)
209-
}
210-
211-
Start-Process -FilePath "npm" -ArgumentList $args -Wait -NoNewWindow
35+
Expand-Archive -Path $TempFile -DestinationPath $Path -Force
21236
}
21337

21438
function Test-IsAdmin()
@@ -236,42 +60,11 @@ if (-not (Test-IsAdmin))
23660
}
23761
else
23862
{
239-
Write-Host "Installing Dependencies"
240-
241-
$exeDependencies | ForEach-Object {
242-
if (-not (Test-Command $_.Test))
243-
{
244-
Write-Host "==> Installing $($_.Name)" ;
245-
InstallFrom-Exe -Url $_.Url -Args $_.Args
246-
}
247-
}
248-
249-
$msiDependencies | ForEach-Object {
250-
if (-not (Test-Command $_.Test))
251-
{
252-
Write-Host "==> Installing $($_.Name)" ;
253-
InstallFrom-Url -Url $_.Url -Path $_.Path
254-
}
255-
}
256-
25763
$zipDependencies | ForEach-Object {
258-
if (-not (Test-Command $_.Test))
259-
{
260-
Write-Host "==> Installing $($_.Name)" ;
261-
UnpackFrom-Url -Url $_.Url -Path $_.Path
262-
}
263-
}
64+
Write-Host "==> Installing $($_.Name)" ;
65+
UnpackFrom-Url -Url $_.Url -Path $_.Path
66+
}
26467

26568
#reloads path to execute NPM
26669
$env:Path = [System.Environment]::GetEnvironmentVariable("Path","Machine") + ";" + [System.Environment]::GetEnvironmentVariable("Path","User")
267-
268-
Write-Host "Updating NPM packages"
269-
270-
$npmPackages | ForEach-Object {
271-
Write-Host "==> Installing $($_.Name) version $($_.Version)" ;
272-
Install-NpmPackage -Name $_.Name -Version $_.Version -Global
273-
}
274-
275-
Write-Host "Adding Python path to NPM"
276-
Start-Process -FilePath "npm" -ArgumentList @("config";"set";"python";"C:\Python27\python.exe") -Wait -NoNewWindow
27770
}

package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"name": "ad-ldap-connector",
3-
"version": "6.2.0",
3+
"version": "6.3.0",
44
"description": "ADLDAP Federation Connector",
55
"main": "server.js",
66
"scripts": {

0 commit comments

Comments
 (0)