diff --git a/.gitea/workflows/release.yml b/.gitea/workflows/release.yml index 3d36360..4d79203 100644 --- a/.gitea/workflows/release.yml +++ b/.gitea/workflows/release.yml @@ -11,29 +11,24 @@ jobs: steps: - name: Ensure Node.js for Gitea actions - shell: cmd + shell: powershell run: | - where node - if %ERRORLEVEL% EQU 0 ( + if (Get-Command node -ErrorAction SilentlyContinue) { node --version - exit /b 0 - ) - set "NODE_VERSION=v20.19.0" - set "ZIP_URL=https://nodejs.org/dist/%NODE_VERSION%/node-%NODE_VERSION%-win-x64.zip" - set "ZIP_PATH=%RUNNER_TEMP%\node.zip" - set "EXTRACT_ROOT=%RUNNER_TEMP%\node" - mkdir "%EXTRACT_ROOT%" - curl.exe -fsSL "%ZIP_URL%" -o "%ZIP_PATH%" - tar -xf "%ZIP_PATH%" -C "%EXTRACT_ROOT%" - for /d %%D in ("%EXTRACT_ROOT%\*") do ( - set "NODE_DIR=%%~fD" - goto :node_found - ) - echo Node.js archive extracted incorrectly. - exit /b 1 - :node_found - echo %NODE_DIR%>>"%GITHUB_PATH%" - set "PATH=%NODE_DIR%;%PATH%" + exit 0 + } + $nodeVersion = "v20.19.0" + $zipUrl = "https://nodejs.org/dist/$nodeVersion/node-$nodeVersion-win-x64.zip" + $zipPath = "$env:RUNNER_TEMP\node.zip" + $extractRoot = "$env:RUNNER_TEMP\node" + Invoke-WebRequest -Uri $zipUrl -OutFile $zipPath + Expand-Archive -Path $zipPath -DestinationPath $extractRoot -Force + $nodeDir = Get-ChildItem -Path $extractRoot -Directory | Select-Object -First 1 + if (-not $nodeDir) { + throw "Node.js archive extracted incorrectly." + } + $nodeDir.FullName | Out-File -FilePath $env:GITHUB_PATH -Encoding utf8 -Append + $env:PATH = "$($nodeDir.FullName);$env:PATH" node --version - name: Checkout