Skip to content

Commit

Permalink
fix_ps1
Browse files Browse the repository at this point in the history
  • Loading branch information
epompeii committed Nov 30, 2024
1 parent 54d462b commit bbad165
Show file tree
Hide file tree
Showing 3 changed files with 42 additions and 24 deletions.
14 changes: 13 additions & 1 deletion .github/workflows/bencher.yml
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -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
Expand All @@ -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
Expand All @@ -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.27; 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.27"; 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
Expand Down
25 changes: 14 additions & 11 deletions services/cli/templates/install-cli.ps1.j2
Original file line number Diff line number Diff line change
Expand Up @@ -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

Expand All @@ -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 = $(if ($env:BENCHER_VERSION) { $env:BENCHER_VERSION } else { '{{ app_version }}' }),
[Parameter(HelpMessage = "The URL of the directory where artifacts can be fetched from")]
[string]$ArtifactDownloadUrl = "https://bencher.dev/download/$(if ($env:BENCHER_VERSION) { $env:BENCHER_VERSION } else { '{{ 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) {
Expand All @@ -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 "" }}
Expand Down Expand Up @@ -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
Expand Down
27 changes: 15 additions & 12 deletions services/cli/templates/output/install-cli.ps1
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -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 = $(if ($env:BENCHER_VERSION) { $env:BENCHER_VERSION } else { '0.4.28' }),
[Parameter(HelpMessage = "The URL of the directory where artifacts can be fetched from")]
[string]$ArtifactDownloadUrl = "https://bencher.dev/download/$(if ($env:BENCHER_VERSION) { $env:BENCHER_VERSION } else { '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) {
Expand All @@ -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"
Expand Down Expand Up @@ -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
Expand Down

0 comments on commit bbad165

Please sign in to comment.