Skip to content

Commit 60b3285

Browse files
committed
Bake staging dashboard URL into CLI releases
1 parent 6109578 commit 60b3285

7 files changed

Lines changed: 37 additions & 19 deletions

File tree

.github/workflows/release-macos-cli.yml

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,7 @@ permissions:
1616

1717
env:
1818
BINDHUB_DEFAULT_API_URL: https://staging-api.bindhub.dev/
19+
BINDHUB_DEFAULT_WEB_URL: https://app-staging.bindhub.com
1920

2021
jobs:
2122
macos-cli:
@@ -58,6 +59,6 @@ jobs:
5859
esac
5960
gh release create "$RELEASE_TAG" "${assets[@]}" \
6061
--title "Bindhub CLI $RELEASE_TAG" \
61-
--notes "Alpha command-line tools for Loom and Bindhub. The default API is https://staging-api.bindhub.dev/. OAuth, signed installers, and production hardening are not included yet." \
62+
--notes "Alpha command-line tools for Loom and Bindhub. The default API is https://staging-api.bindhub.dev/ and browser login opens https://app-staging.bindhub.com. OAuth, signed installers, and production hardening are not included yet." \
6263
"${flags[@]}"
6364
fi

README.md

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -151,7 +151,8 @@ bindhub pause|resume|unlink [name]
151151

152152
Packaged builds can bake in the Bindhub API endpoint. Local/dev builds default to
153153
`http://127.0.0.1:8787`, and operators can override that with `bindhub login --api <URL>` or
154-
`BINDHUB_API_URL=<URL>`.
154+
`BINDHUB_API_URL=<URL>`. Browser login uses the packaged dashboard URL, or `--web <URL>` /
155+
`BINDHUB_WEB_URL=<URL>` when overriding it locally.
155156

156157
To remove the generated workspace after a passing run:
157158

bindhub/crates/bindhub-cli/src/product.rs

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2152,7 +2152,10 @@ fn default_api_url() -> String {
21522152
}
21532153

21542154
fn default_web_url() -> String {
2155-
std::env::var(WEB_URL_ENV).unwrap_or_else(|_| LOCAL_DEV_WEB_URL.to_string())
2155+
std::env::var(WEB_URL_ENV)
2156+
.ok()
2157+
.or_else(|| option_env!("BINDHUB_DEFAULT_WEB_URL").map(ToString::to_string))
2158+
.unwrap_or_else(|| LOCAL_DEV_WEB_URL.to_string())
21562159
}
21572160

21582161
fn update_installer_url(repo: &str, installer: &str) -> String {

scripts/install-bindhub.sh

Lines changed: 3 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,8 @@ detect_target() {
1818

1919
latest_tag() {
2020
curl_github "https://api.github.com/repos/$repo/releases" \
21-
| sed -n 's/.*"tag_name": "\(v[^"]*\)".*/\1/p' \
21+
| tr ',' '\n' \
22+
| sed -n 's/.*"tag_name"[[:space:]]*:[[:space:]]*"\(v[^"]*\)".*/\1/p' \
2223
| head -n 1
2324
}
2425

@@ -42,18 +43,7 @@ curl_github_asset() {
4243

4344
asset_url() {
4445
asset_name="$1"
45-
curl_github "https://api.github.com/repos/$repo/releases/tags/$tag" \
46-
| awk -v name="$asset_name" '
47-
/"url":/ {
48-
url=$0
49-
sub(/^[[:space:]]*"url": "/, "", url)
50-
sub(/",?$/, "", url)
51-
}
52-
/"name":/ && index($0, "\"" name "\"") {
53-
print url
54-
exit
55-
}
56-
'
46+
printf 'https://github.com/%s/releases/download/%s/%s\n' "$repo" "$tag" "$asset_name"
5747
}
5848

5949
add_path_hint() {

scripts/package-cli.ps1

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,7 @@ param(
22
[string]$Version = "",
33
[string]$Target = "x86_64-pc-windows-msvc",
44
[string]$ApiUrl = "",
5+
[string]$WebUrl = "",
56
[switch]$SkipBuild
67
)
78

@@ -17,6 +18,13 @@ if (-not $ApiUrl) {
1718
"https://staging-api.bindhub.dev/"
1819
}
1920
}
21+
if (-not $WebUrl) {
22+
$WebUrl = if ($env:BINDHUB_DEFAULT_WEB_URL) {
23+
$env:BINDHUB_DEFAULT_WEB_URL
24+
} else {
25+
"https://app-staging.bindhub.com"
26+
}
27+
}
2028

2129
$RepoRoot = Resolve-Path (Join-Path $PSScriptRoot "..")
2230
Set-Location $RepoRoot
@@ -36,8 +44,10 @@ New-Item -ItemType Directory -Force -Path $StageDir | Out-Null
3644
New-Item -ItemType Directory -Force -Path $DistDir | Out-Null
3745

3846
$previousApiUrl = $env:BINDHUB_DEFAULT_API_URL
47+
$previousWebUrl = $env:BINDHUB_DEFAULT_WEB_URL
3948
try {
4049
$env:BINDHUB_DEFAULT_API_URL = $ApiUrl
50+
$env:BINDHUB_DEFAULT_WEB_URL = $WebUrl
4151
if (-not $SkipBuild) {
4252
rustup target add $Target
4353
cargo build --release --locked `
@@ -49,6 +59,7 @@ try {
4959
}
5060
} finally {
5161
$env:BINDHUB_DEFAULT_API_URL = $previousApiUrl
62+
$env:BINDHUB_DEFAULT_WEB_URL = $previousWebUrl
5263
}
5364

5465
$ReleaseDir = Join-Path $RepoRoot "target\$Target\release"
@@ -64,6 +75,7 @@ Copy-Item -Force -Path (Join-Path $RepoRoot "LICENSE") -Destination (Join-Path $
6475
# Packaged production builds should already know the Bindhub API endpoint.
6576
6677
# BINDHUB_API_URL=https://staging-api.bindhub.dev/
78+
# BINDHUB_WEB_URL=https://app-staging.bindhub.com
6779
BINDHUB_CONFIG_DIR=.bindhub
6880
"@ | Set-Content -Encoding UTF8 -Path (Join-Path $StageDir ".env.example")
6981

scripts/package-cli.sh

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,7 @@ Builds and packages Bindhub alpha command-line tools for the current macOS/Linux
1010
Environment:
1111
BINDHUB_RELEASE_TARGET Optional Rust target triple.
1212
BINDHUB_DEFAULT_API_URL Optional default Bindhub API URL baked into the CLI.
13+
BINDHUB_DEFAULT_WEB_URL Optional default Bindhub dashboard URL baked into the CLI.
1314
1415
Examples:
1516
scripts/package-cli.sh v0.1.0-alpha.1
@@ -28,6 +29,7 @@ cd "$repo_root"
2829
version="${1:-$(git rev-parse --short HEAD)}"
2930
target="${BINDHUB_RELEASE_TARGET:-}"
3031
export BINDHUB_DEFAULT_API_URL="${BINDHUB_DEFAULT_API_URL:-https://staging-api.bindhub.dev/}"
32+
export BINDHUB_DEFAULT_WEB_URL="${BINDHUB_DEFAULT_WEB_URL:-https://app-staging.bindhub.com}"
3133

3234
if [[ -z "$target" ]]; then
3335
os="$(uname -s)"
@@ -87,6 +89,7 @@ cat > "$stage_dir/.env.example" <<'ENV'
8789
# Packaged production builds should already know the Bindhub API endpoint.
8890
8991
# BINDHUB_API_URL=https://staging-api.bindhub.dev/
92+
# BINDHUB_WEB_URL=https://app-staging.bindhub.com
9093
BINDHUB_CONFIG_DIR=.bindhub
9194
ENV
9295
cp "$repo_root/.env.example" "$stage_dir/.env.operator.example"

scripts/publish-cli-release.ps1

Lines changed: 11 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,8 @@
11
param(
22
[Parameter(Mandatory = $true)]
33
[string]$Tag,
4-
[string]$ApiUrl = ""
4+
[string]$ApiUrl = "",
5+
[string]$WebUrl = ""
56
)
67

78
$ErrorActionPreference = "Stop"
@@ -13,6 +14,13 @@ if (-not $ApiUrl) {
1314
"https://staging-api.bindhub.dev/"
1415
}
1516
}
17+
if (-not $WebUrl) {
18+
$WebUrl = if ($env:BINDHUB_DEFAULT_WEB_URL) {
19+
$env:BINDHUB_DEFAULT_WEB_URL
20+
} else {
21+
"https://app-staging.bindhub.com"
22+
}
23+
}
1624

1725
$RepoRoot = Resolve-Path (Join-Path $PSScriptRoot "..")
1826
Set-Location $RepoRoot
@@ -31,7 +39,7 @@ if ($LASTEXITCODE -ne 0) {
3139

3240
git push origin $Tag
3341

34-
& "$PSScriptRoot\package-cli.ps1" -Version $Tag -ApiUrl $ApiUrl
42+
& "$PSScriptRoot\package-cli.ps1" -Version $Tag -ApiUrl $ApiUrl -WebUrl $WebUrl
3543

3644
$Assets = @(
3745
Join-Path $RepoRoot "dist\bindhub-$Tag-x86_64-pc-windows-msvc.zip"
@@ -60,7 +68,7 @@ if ($ReleaseExists) {
6068
"release", "create", $Tag
6169
) + $Assets + @(
6270
"--title", "Bindhub CLI $Tag",
63-
"--notes", "Alpha command-line tools for Loom and Bindhub. The default API is https://staging-api.bindhub.dev/. OAuth, signed installers, and production hardening are not included yet."
71+
"--notes", "Alpha command-line tools for Loom and Bindhub. The default API is https://staging-api.bindhub.dev/ and browser login opens https://app-staging.bindhub.com. OAuth, signed installers, and production hardening are not included yet."
6472
)
6573
if ($Tag.Contains("-")) {
6674
$ghArgs += "--prerelease"

0 commit comments

Comments
 (0)