Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 2 additions & 0 deletions .goreleaser.yml
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,8 @@ archives:
files:
- LICENSE
- README.md
- install.sh
- install.ps1

checksum:
name_template: checksums.txt
Expand Down
2 changes: 1 addition & 1 deletion .release-please-manifest.json
Original file line number Diff line number Diff line change
@@ -1,3 +1,3 @@
{
".": "0.1.0"
".": "0.0.0"
}
15 changes: 0 additions & 15 deletions CHANGELOG.md

This file was deleted.

10 changes: 8 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -75,10 +75,16 @@ repeatable build output.

## Quickstart

Install:
Install on Linux, macOS, or WSL:

```bash
go install github.com/This-Is-NPC/backstage/cmd/backstage@latest
curl -fsSL https://raw.githubusercontent.com/This-Is-NPC/backstage/master/install.sh | bash
```

Install on Windows PowerShell:

```powershell
irm https://raw.githubusercontent.com/This-Is-NPC/backstage/master/install.ps1 | iex
```

Record a scene:
Expand Down
51 changes: 51 additions & 0 deletions install.ps1
Original file line number Diff line number Diff line change
@@ -0,0 +1,51 @@
# install.ps1 - fetch the latest Backstage release and install backstage.exe.

$ErrorActionPreference = "Stop"

$Repo = "This-Is-NPC/backstage"
$InstallDir = if ($env:INSTALL_DIR) { $env:INSTALL_DIR } else { "$env:LOCALAPPDATA\Programs\backstage" }

function Get-LatestTag {
$release = Invoke-RestMethod -Uri "https://api.github.com/repos/$Repo/releases/latest"
return $release.tag_name.TrimStart("v")
}

function Get-Arch {
switch ($env:PROCESSOR_ARCHITECTURE) {
"AMD64" { return "x86_64" }
"ARM64" { return "arm64" }
default { throw "unsupported architecture: $env:PROCESSOR_ARCHITECTURE" }
}
}

function Add-ToPath {
param([string]$Dir)
$current = [Environment]::GetEnvironmentVariable("Path", "User")
if ($current -notlike "*$Dir*") {
[Environment]::SetEnvironmentVariable("Path", "$current;$Dir", "User")
Write-Host "=> Added $Dir to your user PATH. Restart your terminal to use 'backstage'."
}
}

$tag = if ($env:VERSION) { $env:VERSION.TrimStart("v") } else { Get-LatestTag }
$arch = Get-Arch
$asset = "backstage_Windows_${arch}.zip"
$url = "https://github.com/$Repo/releases/download/v$tag/$asset"
$tmpdir = [System.IO.Path]::GetTempPath() + [System.Guid]::NewGuid().ToString()

Write-Host "=> Installing backstage v$tag for Windows $arch..."
Write-Host "=> Downloading $url"

New-Item -ItemType Directory -Path $tmpdir -Force | Out-Null
Invoke-WebRequest -Uri $url -OutFile "$tmpdir\$asset"
Expand-Archive -Path "$tmpdir\$asset" -DestinationPath $tmpdir -Force

New-Item -ItemType Directory -Path $InstallDir -Force | Out-Null
Copy-Item -Path "$tmpdir\backstage.exe" -Destination "$InstallDir\backstage.exe" -Force
Remove-Item -Recurse -Force $tmpdir

Add-ToPath -Dir $InstallDir

$version = & "$InstallDir\backstage.exe" --version
Write-Host "=> Installed $version"
Write-Host "=> Run 'backstage --help' to get started"
70 changes: 70 additions & 0 deletions install.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,70 @@
#!/usr/bin/env bash
set -euo pipefail

# install.sh - fetch the latest Backstage release and install the binary.

REPO="This-Is-NPC/backstage"
INSTALL_DIR="${INSTALL_DIR:-$HOME/.local/bin}"

get_latest_tag() {
curl -fsSL "https://api.github.com/repos/${REPO}/releases/latest" |
grep -m1 '"tag_name":' |
sed -E 's/.*"tag_name" *: *"v?([^"]+)".*/\1/'
}

get_os() {
case "$(uname -s)" in
Linux*) echo Linux ;;
Darwin*) echo Darwin ;;
*) echo "unsupported OS: $(uname -s)" >&2; exit 1 ;;
esac
}

get_arch() {
case "$(uname -m)" in
x86_64|amd64) echo x86_64 ;;
arm64|aarch64) echo arm64 ;;
*) echo "unsupported architecture: $(uname -m)" >&2; exit 1 ;;
esac
}

ensure_path() {
command -v backstage >/dev/null 2>&1 && return
case ":${PATH}:" in
*":${INSTALL_DIR}:"*) return ;;
esac
echo "=> Adding ${INSTALL_DIR} to PATH"
case "${SHELL:-}" in
*/zsh) echo "export PATH=\"${INSTALL_DIR}:\${PATH}\"" >> "${HOME}/.zshrc" ;;
*/bash) echo "export PATH=\"${INSTALL_DIR}:\${PATH}\"" >> "${HOME}/.bashrc" ;;
*) echo "=> Please add ${INSTALL_DIR} to your PATH manually" ;;
esac
}

main() {
local tag="${VERSION:-$(get_latest_tag)}"
tag="${tag#v}"
local os; os="$(get_os)"
local arch; arch="$(get_arch)"
local asset="backstage_${os}_${arch}.tar.gz"
local url="https://github.com/${REPO}/releases/download/v${tag}/${asset}"
local tmpdir; tmpdir="$(mktemp -d)"

echo "=> Installing backstage v${tag} for ${os} ${arch}..."
echo "=> Downloading ${url}"

curl -fsSL "${url}" -o "${tmpdir}/${asset}"
tar -xzf "${tmpdir}/${asset}" -C "${tmpdir}"

mkdir -p "${INSTALL_DIR}"
install -m 755 "${tmpdir}/backstage" "${INSTALL_DIR}/backstage"

rm -rf "${tmpdir}"

ensure_path

echo "=> Installed $("${INSTALL_DIR}/backstage" --version)"
echo "=> Run 'backstage --help' to get started"
}

main "$@"
1 change: 1 addition & 0 deletions release-please-config.json
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
{
"$schema": "https://raw.githubusercontent.com/googleapis/release-please/main/schemas/config.json",
"bootstrap-sha": "d6a0e44cd330b6927966f026cf3805a82e0f73d9",
"packages": {
".": {
"release-type": "go",
Expand Down
Loading