From 2c4a741adecd9097e3fbc3a37070142dda2ed9cd Mon Sep 17 00:00:00 2001 From: Everett Pompeii Date: Fri, 29 Nov 2024 18:33:21 -0500 Subject: [PATCH] fix_ps1 --- .github/workflows/bencher.yml | 14 +++++++++- services/cli/templates/install-cli.ps1.j2 | 25 +++++++++-------- services/cli/templates/output/install-cli.ps1 | 27 ++++++++++--------- 3 files changed, 42 insertions(+), 24 deletions(-) diff --git a/.github/workflows/bencher.yml b/.github/workflows/bencher.yml index 0b4a9c655..57484db40 100644 --- a/.github/workflows/bencher.yml +++ b/.github/workflows/bencher.yml @@ -67,6 +67,8 @@ jobs: source: script-cloud - os: ubuntu-latest source: script-gen + - os: ubuntu-latest + source: script-gen-version - os: ubuntu-latest source: cargo-main - os: ubuntu-latest @@ -80,6 +82,8 @@ jobs: source: script-cloud - os: macos-latest source: script-gen + - os: macos-latest + source: script-gen-version - os: macos-latest source: cargo-main - os: macos-latest @@ -93,6 +97,8 @@ jobs: source: script-cloud - os: windows-latest source: script-gen + - os: windows-latest + source: script-gen-version - os: windows-latest source: cargo-main - os: windows-latest @@ -112,13 +118,19 @@ jobs: if: matrix.source == 'script-cloud' && matrix.os == 'windows-latest' run: irm https://bencher.dev/download/install-cli.ps1 | iex - uses: actions/checkout@v4 - if: matrix.source == 'script-gen' + if: matrix.source == 'script-gen' || matrix.source == 'script-gen-version' - name: Unix CLI Install Script if: matrix.source == 'script-gen' && matrix.os != 'windows-latest' run: cat services/cli/templates/output/install-cli.sh | sh + - name: Unix CLI Install Script Version + if: matrix.source == 'script-gen-version' && matrix.os != 'windows-latest' + run: export BENCHER_VERSION=0.4.28; cat services/cli/templates/output/install-cli.sh | sh - name: Windows CLI Install Script if: matrix.source == 'script-gen' && matrix.os == 'windows-latest' run: gc -Raw services/cli/templates/output/install-cli.ps1 | iex + - name: Windows CLI Install Script Version + if: matrix.source == 'script-gen-version' && matrix.os == 'windows-latest' + run: $env:BENCHER_VERSION="0.4.28"; gc -Raw services/cli/templates/output/install-cli.ps1 | iex - name: Cargo CLI Install main if: matrix.source == 'cargo-main' run: cargo install --git https://github.com/bencherdev/bencher --branch main --locked bencher_cli diff --git a/services/cli/templates/install-cli.ps1.j2 b/services/cli/templates/install-cli.ps1.j2 index dc5ab3d09..28da8ebf2 100644 --- a/services/cli/templates/install-cli.ps1.j2 +++ b/services/cli/templates/install-cli.ps1.j2 @@ -20,6 +20,9 @@ If you get an error that says "running scripts is disabled on this system": - Enter: `Y` - Rerun this script +.PARAMETER AppVersion +The version of the application to install + .PARAMETER ArtifactDownloadUrl The URL of the directory where artifacts can be fetched from @@ -31,18 +34,18 @@ Print help #> -$app_name = 'bencher' -$app_version = if ($env:BENCHER_VERSION) { $env:BENCHER_VERSION } else { '{{ app_version }}' } - param ( - [Parameter(HelpMessage = "The URL of the directory where artifacts can be fetched from")] - [string]$ArtifactDownloadUrl = "https://bencher.dev/download/$app_version", - [Parameter(HelpMessage = "Don't add the install directory to PATH")] - [switch]$NoModifyPath, - [Parameter(HelpMessage = "Print Help")] - [switch]$Help + [Parameter(HelpMessage = "The version of the application to install")] + [string]$AppVersion = $env:BENCHER_VERSION -or '{{ app_version }}' + [Parameter(HelpMessage = "The URL of the directory where artifacts can be fetched from")] + [string]$ArtifactDownloadUrl = "https://bencher.dev/download/$($env:BENCHER_VERSION -or '{{ app_version }}')" + [Parameter(HelpMessage = "Don't add the install directory to PATH")] + [switch]$NoModifyPath, + [Parameter(HelpMessage = "Print Help")] + [switch]$Help ) +$app_name = 'bencher' function Install-Binary($install_args) { if ($Help) { @@ -55,7 +58,7 @@ function Install-Binary($install_args) { $platforms = @{ {%- for artifact in artifacts %} "{{ artifact.target_triple }}" = @{ - "artifact_name" = "$app_name-v$app_version-{{ artifact.os_arch }}.exe" + "artifact_name" = "$app_name-v$AppVersion-{{ artifact.os_arch }}.exe" "zip_ext" = "{{ artifact.zip_style }}" "bins" = {% for bin in artifact.binaries -%} "{{ bin }}"{{ ", " if not loop.last else "" }} @@ -137,7 +140,7 @@ https://github.com/bencherdev/bencher/issues # Download and unpack! $url = "$download_url/$artifact_name" - Write-Information "Downloading Bencher CLI ($app_name $app_version)" + Write-Information "Downloading Bencher CLI ($app_name $AppVersion)" Write-Verbose " From: $url" Write-Verbose " To: $dir_path" $wc = New-Object Net.Webclient diff --git a/services/cli/templates/output/install-cli.ps1 b/services/cli/templates/output/install-cli.ps1 index c169048f8..7b92772fd 100755 --- a/services/cli/templates/output/install-cli.ps1 +++ b/services/cli/templates/output/install-cli.ps1 @@ -20,6 +20,9 @@ If you get an error that says "running scripts is disabled on this system": - Enter: `Y` - Rerun this script +.PARAMETER AppVersion +The version of the application to install + .PARAMETER ArtifactDownloadUrl The URL of the directory where artifacts can be fetched from @@ -31,18 +34,18 @@ Print help #> -$app_name = 'bencher' -$app_version = if ($env:BENCHER_VERSION) { $env:BENCHER_VERSION } else { '0.4.28' } - param ( - [Parameter(HelpMessage = "The URL of the directory where artifacts can be fetched from")] - [string]$ArtifactDownloadUrl = "https://bencher.dev/download/$app_version", - [Parameter(HelpMessage = "Don't add the install directory to PATH")] - [switch]$NoModifyPath, - [Parameter(HelpMessage = "Print Help")] - [switch]$Help + [Parameter(HelpMessage = "The version of the application to install")] + [string]$AppVersion = $env:BENCHER_VERSION -or '0.4.28' + [Parameter(HelpMessage = "The URL of the directory where artifacts can be fetched from")] + [string]$ArtifactDownloadUrl = "https://bencher.dev/download/$($env:BENCHER_VERSION -or '0.4.28')" + [Parameter(HelpMessage = "Don't add the install directory to PATH")] + [switch]$NoModifyPath, + [Parameter(HelpMessage = "Print Help")] + [switch]$Help ) +$app_name = 'bencher' function Install-Binary($install_args) { if ($Help) { @@ -54,13 +57,13 @@ function Install-Binary($install_args) { $platforms = @{ "x86_64-pc-windows-msvc" = @{ - "artifact_name" = "$app_name-v$app_version-windows-x86-64.exe" + "artifact_name" = "$app_name-v$AppVersion-windows-x86-64.exe" "zip_ext" = "" "bins" = "bencher" "bin" = "bencher" } "aarch64-pc-windows-msvc" = @{ - "artifact_name" = "$app_name-v$app_version-windows-arm-64.exe" + "artifact_name" = "$app_name-v$AppVersion-windows-arm-64.exe" "zip_ext" = "" "bins" = "bencher" "bin" = "bencher" @@ -139,7 +142,7 @@ https://github.com/bencherdev/bencher/issues # Download and unpack! $url = "$download_url/$artifact_name" - Write-Information "Downloading Bencher CLI ($app_name $app_version)" + Write-Information "Downloading Bencher CLI ($app_name $AppVersion)" Write-Verbose " From: $url" Write-Verbose " To: $dir_path" $wc = New-Object Net.Webclient