Get rid of nested archive #4
@@ -1,5 +1,5 @@
|
|||||||
jobs:
|
jobs:
|
||||||
- job:
|
- job: Test_Node
|
||||||
pool:
|
pool:
|
||||||
name: Azure Pipelines
|
name: Azure Pipelines
|
||||||
vmImage: $(VmImage)
|
vmImage: $(VmImage)
|
||||||
@@ -21,11 +21,11 @@ jobs:
|
|||||||
inputs:
|
inputs:
|
||||||
source: 'current'
|
source: 'current'
|
||||||
artifact: 'node-$(Version)-$(Platform)-$(Architecture)'
|
artifact: 'node-$(Version)-$(Platform)-$(Architecture)'
|
||||||
path: $(Build.BinariesDirectory)
|
path: $(Build.ArtifactStagingDirectory)
|
||||||
|
|
||||||
- task: ExtractFiles@1
|
- task: ExtractFiles@1
|
||||||
inputs:
|
inputs:
|
||||||
archiveFilePatterns: '$(Build.BinariesDirectory)/node-$(Version)-$(Platform)-$(Architecture).zip'
|
archiveFilePatterns: '$(Build.ArtifactStagingDirectory)/node-$(Version)-$(Platform)-$(Architecture).zip'
|
||||||
destinationFolder: $(Build.BinariesDirectory)
|
destinationFolder: $(Build.BinariesDirectory)
|
||||||
cleanDestinationFolder: false
|
cleanDestinationFolder: false
|
||||||
|
|
||||||
|
|||||||
@@ -23,9 +23,11 @@ param(
|
|||||||
[Parameter (Mandatory=$true)][Version] $Version,
|
[Parameter (Mandatory=$true)][Version] $Version,
|
||||||
[Parameter (Mandatory=$true)][string] $Platform,
|
[Parameter (Mandatory=$true)][string] $Platform,
|
||||||
[string] $Architecture = "x64"
|
[string] $Architecture = "x64"
|
||||||
|
|
||||||
)
|
)
|
||||||
|
|
||||||
|
Import-Module (Join-Path $PSScriptRoot "../helpers" | Join-Path -ChildPath "nix-helpers.psm1") -DisableNameChecking
|
||||||
|
Import-Module (Join-Path $PSScriptRoot "../helpers" | Join-Path -ChildPath "win-helpers.psm1") -DisableNameChecking
|
||||||
|
|
||||||
function Get-NodeBuilder {
|
function Get-NodeBuilder {
|
||||||
<#
|
<#
|
||||||
.SYNOPSIS
|
.SYNOPSIS
|
||||||
|
|||||||
@@ -40,6 +40,10 @@ class NixNodeBuilder : NodeBuilder {
|
|||||||
return "${base}/v$($this.Version)/node-v$($this.Version)-$($this.Platform)-$($this.Architecture).tar.gz"
|
return "${base}/v$($this.Version)/node-v$($this.Version)-$($this.Platform)-$($this.Architecture).tar.gz"
|
||||||
}
|
}
|
||||||
|
|
||||||
|
[void] ExtractBinaries($archivePath) {
|
||||||
|
Extract-TarArchive -ArchivePath $archivePath -OutputDirectory $this.ArtifactLocation
|
||||||
|
}
|
||||||
|
|
||||||
[void] CreateInstallationScript() {
|
[void] CreateInstallationScript() {
|
||||||
<#
|
<#
|
||||||
.SYNOPSIS
|
.SYNOPSIS
|
||||||
|
|||||||
@@ -15,6 +15,9 @@ class NodeBuilder {
|
|||||||
.PARAMETER Architecture
|
.PARAMETER Architecture
|
||||||
The architecture with which Node.js should be built.
|
The architecture with which Node.js should be built.
|
||||||
|
|
||||||
|
.PARAMETER TempFolderLocation
|
||||||
|
The location of temporary files that will be used during Node.js package generation. Using system BUILD_STAGINGDIRECTORY variable value.
|
||||||
|
|
||||||
.PARAMETER ArtifactLocation
|
.PARAMETER ArtifactLocation
|
||||||
The location of generated Node.js artifact. Using system environment BUILD_BINARIESDIRECTORY variable value.
|
The location of generated Node.js artifact. Using system environment BUILD_BINARIESDIRECTORY variable value.
|
||||||
|
|
||||||
@@ -26,6 +29,7 @@ class NodeBuilder {
|
|||||||
[version] $Version
|
[version] $Version
|
||||||
[string] $Platform
|
[string] $Platform
|
||||||
[string] $Architecture
|
[string] $Architecture
|
||||||
|
[string] $TempFolderLocation
|
||||||
[string] $ArtifactLocation
|
[string] $ArtifactLocation
|
||||||
[string] $InstallationTemplatesLocation
|
[string] $InstallationTemplatesLocation
|
||||||
|
|
||||||
@@ -35,6 +39,7 @@ class NodeBuilder {
|
|||||||
$this.Architecture = $architecture
|
$this.Architecture = $architecture
|
||||||
|
|
||||||
$this.ArtifactLocation = $env:BUILD_BINARIESDIRECTORY
|
$this.ArtifactLocation = $env:BUILD_BINARIESDIRECTORY
|
||||||
|
$this.TempFolderLocation = $env:BUILD_STAGINGDIRECTORY
|
||||||
|
|
||||||
$this.InstallationTemplatesLocation = Join-Path -Path $PSScriptRoot -ChildPath "../installers"
|
$this.InstallationTemplatesLocation = Join-Path -Path $PSScriptRoot -ChildPath "../installers"
|
||||||
}
|
}
|
||||||
@@ -56,7 +61,7 @@ class NodeBuilder {
|
|||||||
|
|
||||||
$binariesUri = $this.GetBinariesUri()
|
$binariesUri = $this.GetBinariesUri()
|
||||||
$targetFilename = [IO.Path]::GetFileName($binariesUri)
|
$targetFilename = [IO.Path]::GetFileName($binariesUri)
|
||||||
$targetFilepath = Join-Path -Path $this.ArtifactLocation -ChildPath $targetFilename
|
$targetFilepath = Join-Path -Path $this.TempFolderLocation -ChildPath $targetFilename
|
||||||
|
|
||||||
Write-Debug "Download binaries from $binariesUri to $targetFilepath"
|
Write-Debug "Download binaries from $binariesUri to $targetFilepath"
|
||||||
try {
|
try {
|
||||||
@@ -78,11 +83,9 @@ class NodeBuilder {
|
|||||||
|
|
||||||
Write-Host "Download Node.js $($this.Version) [$($this.Architecture)] executable..."
|
Write-Host "Download Node.js $($this.Version) [$($this.Architecture)] executable..."
|
||||||
$binariesArchivePath = $this.Download()
|
$binariesArchivePath = $this.Download()
|
||||||
$binariesArchiveDirectory = [IO.Path]::GetDirectoryName($binariesArchivePath)
|
|
||||||
$toolArchivePath = Join-Path $binariesArchiveDirectory $this.OutputArtifactName
|
|
||||||
|
|
||||||
Write-Host "Rename '$binariesArchivePath' to '$toolArchivePath'"
|
Write-Host "Unpack binaries to target directory"
|
||||||
Rename-Item -Path $binariesArchivePath -NewName $toolArchivePath
|
$this.ExtractBinaries($binariesArchivePath)
|
||||||
|
|
||||||
Write-Host "Create installation script..."
|
Write-Host "Create installation script..."
|
||||||
$this.CreateInstallationScript()
|
$this.CreateInstallationScript()
|
||||||
|
|||||||
@@ -40,6 +40,13 @@ class WinNodeBuilder : NodeBuilder {
|
|||||||
return "${base}/v$($this.Version)/node-v$($this.Version)-win-$($this.Architecture).7z"
|
return "${base}/v$($this.Version)/node-v$($this.Version)-win-$($this.Architecture).7z"
|
||||||
}
|
}
|
||||||
|
|
||||||
|
[void] ExtractBinaries($archivePath) {
|
||||||
|
$extractTargetDirectory = Join-Path $this.TempFolderLocation "tempExtract"
|
||||||
|
Extract-7ZipArchive -ArchivePath $archivePath -OutputDirectory $extractTargetDirectory
|
||||||
|
$nodeOutputPath = Get-Item $extractTargetDirectory\* | Select-Object -First 1 -ExpandProperty Fullname
|
||||||
|
Move-Item -Path $nodeOutputPath\* -Destination $this.ArtifactLocation
|
||||||
|
}
|
||||||
|
|
||||||
[void] CreateInstallationScript() {
|
[void] CreateInstallationScript() {
|
||||||
<#
|
<#
|
||||||
.SYNOPSIS
|
.SYNOPSIS
|
||||||
|
|||||||
16
helpers/nix-helpers.psm1
Normal file
16
helpers/nix-helpers.psm1
Normal file
@@ -0,0 +1,16 @@
|
|||||||
|
<#
|
||||||
|
.SYNOPSIS
|
||||||
|
Unpack *.tar file
|
||||||
|
#>
|
||||||
|
function Extract-TarArchive {
|
||||||
|
param(
|
||||||
|
[Parameter(Mandatory=$true)]
|
||||||
|
[String]$ArchivePath,
|
||||||
|
[Parameter(Mandatory=$true)]
|
||||||
|
[String]$OutputDirectory
|
||||||
|
)
|
||||||
|
|
||||||
|
Write-Debug "Extract $ArchivePath to $OutputDirectory"
|
||||||
|
tar -C $OutputDirectory -xzf $ArchivePath --strip 1
|
||||||
|
|
||||||
|
}
|
||||||
15
helpers/win-helpers.psm1
Normal file
15
helpers/win-helpers.psm1
Normal file
@@ -0,0 +1,15 @@
|
|||||||
|
<#
|
||||||
|
.SYNOPSIS
|
||||||
|
Unpack *.7z file
|
||||||
|
#>
|
||||||
|
function Extract-7ZipArchive {
|
||||||
|
param(
|
||||||
|
[Parameter(Mandatory=$true)]
|
||||||
|
[String]$ArchivePath,
|
||||||
|
[Parameter(Mandatory=$true)]
|
||||||
|
[String]$OutputDirectory
|
||||||
|
)
|
||||||
|
|
||||||
|
Write-Debug "Extract $ArchivePath to $OutputDirectory"
|
||||||
|
7z x $ArchivePath -o"$OutputDirectory" -y | Out-Null
|
||||||
|
}
|
||||||
@@ -18,14 +18,8 @@ echo "Create Node.js $NODE_VERSION folder"
|
|||||||
mkdir -p $NODE_TOOLCACHE_VERSION_ARCH_PATH
|
mkdir -p $NODE_TOOLCACHE_VERSION_ARCH_PATH
|
||||||
|
|
||||||
echo "Copy Node.js binaries to hostedtoolcache folder"
|
echo "Copy Node.js binaries to hostedtoolcache folder"
|
||||||
cp ./tool.tar.gz $NODE_TOOLCACHE_VERSION_ARCH_PATH
|
cp -R ./* $NODE_TOOLCACHE_VERSION_ARCH_PATH
|
||||||
|
rm $NODE_TOOLCACHE_VERSION_ARCH_PATH/setup.sh
|
||||||
cd $NODE_TOOLCACHE_VERSION_ARCH_PATH
|
|
||||||
|
|
||||||
echo "Unzip Node.js to $NODE_TOOLCACHE_VERSION_ARCH_PATH"
|
|
||||||
tar -zxf tool.tar.gz -C . --strip 1
|
|
||||||
echo "Node.js unzipped successfully"
|
|
||||||
rm tool.tar.gz
|
|
||||||
|
|
||||||
echo "Create complete file"
|
echo "Create complete file"
|
||||||
touch $NODE_TOOLCACHE_VERSION_PATH/x64.complete
|
touch $NODE_TOOLCACHE_VERSION_PATH/x64.complete
|
||||||
|
|||||||
@@ -1,4 +1,5 @@
|
|||||||
$ErrorActionPreference = "Stop"
|
$ErrorActionPreference = "Stop"
|
||||||
|
|
||||||
[Version]$Version = "{{__VERSION__}}"
|
[Version]$Version = "{{__VERSION__}}"
|
||||||
[string]$Architecture = "{{__ARCHITECTURE__}}"
|
[string]$Architecture = "{{__ARCHITECTURE__}}"
|
||||||
$ArchiveFileName = "tool.7z"
|
$ArchiveFileName = "tool.7z"
|
||||||
@@ -29,16 +30,8 @@ if (-not (Test-Path $NodeToolcacheArchitecturePath)) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
Write-Host "Copy Node.js binaries to hostedtoolcache folder"
|
Write-Host "Copy Node.js binaries to hostedtoolcache folder"
|
||||||
Copy-Item -Path $ArchiveFileName -Destination $NodeToolcacheArchitecturePath
|
Copy-Item -Path * -Destination $NodeToolcacheArchitecturePath
|
||||||
|
Remove-Item $NodeToolcacheArchitecturePath\setup.ps1 -Force | Out-Null
|
||||||
Set-Location $NodeToolcacheArchitecturePath
|
|
||||||
Write-Host "Unzip Node.js to $NodeToolcacheArchitecturePath"
|
|
||||||
7z.exe x $ArchiveFileName -o"$TempDirectory" -y | Out-Null
|
|
||||||
$NodeInnerFolder = Get-Item -Path "$TempDirectory\node-*" | Select-Object -First 1
|
|
||||||
Get-ChildItem $NodeInnerFolder | Move-Item -Destination $NodeToolcacheArchitecturePath
|
|
||||||
Write-Host "Node.js unzipped successfully"
|
|
||||||
|
|
||||||
Remove-Item $ArchiveFileName -Force | Out-Null
|
|
||||||
|
|
||||||
Write-Host "Create complete file"
|
Write-Host "Create complete file"
|
||||||
New-Item -ItemType File -Path $NodeToolcacheVersionPath -Name "$Architecture.complete" | Out-Null
|
New-Item -ItemType File -Path $NodeToolcacheVersionPath -Name "$Architecture.complete" | Out-Null
|
||||||
@@ -20,6 +20,11 @@ Describe "Node.js" {
|
|||||||
"node --version" | Should -ReturnZeroExitCode
|
"node --version" | Should -ReturnZeroExitCode
|
||||||
}
|
}
|
||||||
|
|
||||||
|
It "version is correct" {
|
||||||
|
$versionOutput = Invoke-Expression "node --version"
|
||||||
|
$versionOutput | Should -Match $Version
|
||||||
|
}
|
||||||
|
|
||||||
It "is used from tool-cache" {
|
It "is used from tool-cache" {
|
||||||
$nodePath = (Get-Command "node").Path
|
$nodePath = (Get-Command "node").Path
|
||||||
$nodePath | Should -Not -BeNullOrEmpty
|
$nodePath | Should -Not -BeNullOrEmpty
|
||||||
|
|||||||
Reference in New Issue
Block a user