Implement script to prepare packages with Node.js

This commit is contained in:
Maxim Lobanov
2020-04-23 12:58:18 +03:00
commit 4e7c1d2a13
26 changed files with 1486 additions and 0 deletions

View File

@@ -0,0 +1,25 @@
set -e
NODE_VERSION={0}
NODE_TOOLCACHE_PATH=$AGENT_TOOLSDIRECTORY/node
NODE_TOOLCACHE_VERSION_PATH=$NODE_TOOLCACHE_PATH/$NODE_VERSION
NODE_TOOLCACHE_VERSION_ARCH_PATH=$NODE_TOOLCACHE_VERSION_PATH/x64
echo "Check if Node.js hostedtoolcache folder exist..."
if [ ! -d $NODE_TOOLCACHE_PATH ]; then
mkdir -p $NODE_TOOLCACHE_PATH
fi
echo "Delete Node.js $NODE_VERSION if installed"
rm -rf $NODE_TOOLCACHE_VERSION_PATH
echo "Create Node.js $NODE_VERSION folder"
mkdir -p $NODE_TOOLCACHE_VERSION_ARCH_PATH
echo "Copy Node.js binaries to hostedtoolcache folder"
cp -R ./* $NODE_TOOLCACHE_VERSION_ARCH_PATH
rm $NODE_TOOLCACHE_VERSION_ARCH_PATH/setup.sh
echo "Create complete file"
touch $NODE_TOOLCACHE_VERSION_PATH/x64.complete

View File

@@ -0,0 +1,37 @@
$ErrorActionPreference = "Stop"
[Version]$Version = "{{__VERSION__}}"
[string]$Architecture = "{{__ARCHITECTURE__}}"
$ArchiveFileName = "tool.7z"
$TempDirectory = Join-Path $env:TEMP "Node"
$ToolcacheRoot = $env:AGENT_TOOLSDIRECTORY
if ([string]::IsNullOrEmpty($ToolcacheRoot)) {
# GitHub images don't have `AGENT_TOOLSDIRECTORY` variable
$ToolcacheRoot = $env:RUNNER_TOOL_CACHE
}
$NodeToolcachePath = Join-Path -Path $ToolcacheRoot -ChildPath "node"
$NodeToolcacheVersionPath = Join-Path -Path $NodeToolcachePath -ChildPath $Version.ToString()
$NodeToolcacheArchitecturePath = Join-Path $NodeToolcacheVersionPath $Architecture
Write-Host "Check if Node.js hostedtoolcache folder exist..."
if (-not (Test-Path $NodeToolcachePath)) {
New-Item -ItemType Directory -Path $NodeToolcachePath | Out-Null
}
Write-Host "Delete Node.js $Version if installed"
if (Test-Path $NodeToolcacheVersionPath) {
Remove-Item $NodeToolcachePath -Recurse -Force | Out-Null
}
Write-Host "Create Node.js $Version folder"
if (-not (Test-Path $NodeToolcacheArchitecturePath)) {
New-Item -ItemType Directory -Path $NodeToolcacheArchitecturePath | Out-Null
}
Write-Host "Copy Node.js binaries to hostedtoolcache folder"
Copy-Item -Path * -Destination $NodeToolcacheArchitecturePath
Remove-Item $NodeToolcacheArchitecturePath\setup.ps1 -Force | Out-Null
Write-Host "Create complete file"
New-Item -ItemType File -Path $NodeToolcacheVersionPath -Name "$Architecture.complete" | Out-Null