1 Commits

Author SHA1 Message Date
Jason Swank
670b747a4b terraform-docs: add 2026-01-24 10:34:53 -05:00
4 changed files with 124 additions and 207 deletions

203
README.md
View File

@@ -1,152 +1,96 @@
# binst
A curated collection of portable installation scripts for binary tools, powered by [binstaller](https://github.com/binary-install/binstaller).
A collection of installation scripts for binary tools, generated using [binstaller](https://github.com/binary-install/binstaller). These scripts are portable POSIX shell scripts that work across Linux, macOS, and Windows (Git Bash/WSL) and are designed to be a simple, secure way to install self-contained binaries from GitHub releases.
## Overview
This repository provides POSIX-compliant shell scripts that simplify the installation of popular binary tools from GitHub releases. Each script is:
- **Portable**: Works across Linux, macOS, and Windows (Git Bash/WSL)
- **Secure**: Includes checksum verification for downloaded binaries
- **Simple**: Single command installation with no dependencies
- **Self-contained**: No package manager or runtime required
## Table of Contents
- [Quick Start](#quick-start)
- [Available Tools](#available-tools)
- [Usage](#usage)
- [Installing Binaries](#installing-binaries)
- [Using Task Commands](#using-task-commands)
- [Creating New Scripts](#creating-new-scripts)
- [Prerequisites](#prerequisites)
- [Automatic Generation](#automatic-generation)
- [Manual Configuration](#manual-configuration)
- [Configuration](#configuration)
- [Binary Names](#binary-names)
- [Contributing](#contributing)
- [License](#license)
* [Quick Start](#quick-start)
* [Workflows](#workflows)
* [Creating New Installation Scripts](#creating-new-installation-scripts)
* [Notes](#notes)
* [Binary Names](#binary-names)
## Quick Start
Install any binary directly using its installation script:
Install any binary using its generated script:
```bash
# Install trufflehog
./scripts/trufflehog-install.sh
# install trufflehog
$ scripts/trufflehog-install.sh
# Install task
./scripts/task-install.sh
# Install checkov
./scripts/checkov-install.sh
# install task
$ scripts/task-install.sh
```
Binaries are installed to `~/.local/bin` by default (customizable via environment variables).
## Workflows
## Available Tools
Installation scripts are located in the `scripts/` directory. Run `ls scripts/` to see all available tools, or browse the directory on GitHub.
## Usage
### Installing Binaries
Run any installation script directly:
Common workflows for the creation, maintenance, usage of the installation scripts are encapsulated in [Task](https://taskfile.dev) tasks.
```bash
./scripts/<tool-name>-install.sh
# list available tasks
$ task --list
task: Available tasks for this project:
* default: Create a new installation script for a binary
* embed-checksums: Embed checksums into a binst configuration file.
* gen: Generate installation script from binst configuration.
* init: Initialize binst configuration for a GitHub project.
* install-*: Install a binary using its installation script.
* latest-release: Determine the latest release available for a given repo.
# install a binary
$ task install-trufflehog
```
The script will:
1. Detect your OS and architecture
2. Download the latest release from GitHub
3. Verify checksums
4. Install the binary to your PATH
### Creating New Installation Scripts
### Using Task Commands
This repository includes [Taskfile](https://taskfile.dev) automation for common workflows:
The default task uses binstaller to creates a new installation script for a binary from
its GitHub repository. This is often the only step needed to add a new installation
script to the collection.
To install binstaller, run:
```bash
# List all available tasks
task --list
# Install a specific binary via Task
task install-trufflehog
task install-aichat
task install-checkov
$ scripts/binstaller-install.sh
```
Available tasks:
- `task` - Create a new installation script (requires `REPO` variable)
- `task install-*` - Install a binary using its script
- `task init` - Initialize binstaller configuration for a GitHub project
- `task embed-checksums` - Embed checksums into a configuration file
- `task gen` - Generate installation script from configuration
- `task latest-release` - Check the latest release version
## Creating New Scripts
### Prerequisites
First, install binstaller:
To create a new installation script:
```bash
./scripts/binstaller-install.sh
# create a new installation script by providing the GitHub repository as an argument:
$ task REPO=owner/repo-name
# detailes summary
$ task --summary
task: default
Create a new installation script for a binary by initializing a binst config,
embedding checksums, and generating the installation script. The latest release, as
determined by the latest-release task, will be used unless a specific version is
provided.
Invoke this task like:
task default REPO=trufflesecurity/trufflehog
vars:
CONFIG_DIR: "./config"
SCRIPT_DIR: "./scripts"
BINARY: "{{.REPO | base}}"
VERSION: "latest"
requires:
vars:
- REPO
commands:
- Task: init
- Task: embed-checksums
- Task: gen
```
### Automatic Generation
The easiest way to add a new installation script is using the default Task workflow:
```bash
# Create script for a GitHub repository
task REPO=owner/repo-name
# Example: Add installation script for trufflehog
task REPO=trufflesecurity/trufflehog
```
This command will:
1. Initialize a binstaller configuration file
2. Fetch and embed checksums from the latest release
3. Generate the installation script
For more details on the default task:
```bash
task --summary
```
### Manual Configuration
For advanced use cases, you can manually create or edit configuration files:
1. **Initialize configuration**:
```bash
task init REPO=owner/repo-name
```
2. **Edit the configuration** in `config/repo-name.binstaller.yml` as needed
3. **Embed checksums**:
```bash
task embed-checksums BINARY=repo-name
```
4. **Generate the script**:
```bash
task gen BINARY=repo-name
```
## Configuration
## Notes
### Binary Names
In some cases, the binary executable name differs from the GitHub repository name. When this occurs, specify the actual binary name in the `asset.binaries` section of the configuration file.
Sometimes the binary executable name differs from the GitHub repository name. When this occurs, the `asset.binaries` section in the configuration file defines the actual binary name. If this is the case, the generated installation script will need to be manually edited.
**Example**: The [stacklok/toolhive](https://github.com/stacklok/toolhive) repository releases a binary named `thv`. The [configuration file](config/toolhive.binstaller.yml) handles this:
As an example, the released artifact for [stacklok/toolhive](https://github.com/stacklok/toolhive) is named `thv` rather than `toolhive`. The [configuration file](config/toolhive.binstaller.yml) specifies the correct name for the binary in the `asset.binaries` section.
```yaml
repo: stacklok/toolhive
@@ -156,22 +100,5 @@ asset:
path: thv
```
After generation, you may wish to rename the installation script from `thv-install.sh` to `toolhive-install.sh` for consistency.
## Contributing
Contributions are welcome! To add a new binary installation script:
1. Fork this repository
2. Create a new script using `task REPO=owner/repo-name`
3. Test the installation script
4. Submit a pull request
Please ensure:
- The binary is a popular, well-maintained tool
- The installation script works across all supported platforms
- Checksums are embedded for security
## License
MIT. See [LICENSE](LICENSE) for details.

View File

@@ -1,35 +0,0 @@
# yaml-language-server: $schema=https://raw.githubusercontent.com/binary-install/binstaller/main/schema/InstallSpec.json
schema: v1
repo: asciinema/asciinema
asset:
template: asciinema-${ARCH}-${OS}${EXT}
rules:
- when:
arch: amd64
arch: x86_64
- when:
arch: arm64
arch: aarch64
- when:
os: darwin
os: apple-darwin
- when:
os: linux
arch: amd64
os: unknown-linux-musl
- when:
os: linux
arch: arm64
os: unknown-linux-gnu
checksums:
algorithm: sha256
embedded_checksums:
v3.1.0:
- filename: asciinema-aarch64-apple-darwin
hash: c354d4abcbeae94c592df0d70417d6fca8400546c3b4b5b666761fa8b1a9bca8
- filename: asciinema-aarch64-unknown-linux-gnu
hash: dd6a08eed98d200b0a00d6756b564c10d95f7b6de940c8bac52098a55221f300
- filename: asciinema-x86_64-apple-darwin
hash: 5f0531ada539ce32224e2c680d8022b77ee82fd7b4fd24569f78f1772d38750c
- filename: asciinema-x86_64-unknown-linux-musl
hash: 7c5dc9172a9a9202dd8f558b9df2220785e9b4ce2763091fc22e9f9a458a161b

View File

@@ -0,0 +1,35 @@
# yaml-language-server: $schema=https://raw.githubusercontent.com/binary-install/binstaller/main/schema/InstallSpec.json
schema: v1
repo: terraform-docs/terraform-docs
asset:
template: terraform-docs-${TAG}-${OS}-${ARCH}${EXT}
default_extension: .tar.gz
rules:
- when:
os: windows
ext: .zip
checksums:
algorithm: sha256
template: terraform-docs-${TAG}.sha256sum
embedded_checksums:
v0.21.0:
- filename: terraform-docs-v0.21.0-darwin-amd64.tar.gz
hash: ddf4b53925d857ae81210ebeda32b429a17385d6e4561ab1972067a9ccb36873
- filename: terraform-docs-v0.21.0-darwin-arm64.tar.gz
hash: 92d6988d8c59c25aa1724068f4bc2d0f01a9d4706077e258e946e944ad7eee03
- filename: terraform-docs-v0.21.0-freebsd-amd64.tar.gz
hash: 0be85796f3709a5b42807b8d25cb5c4c8d0fd1c1dc7aa14388c212c34376a638
- filename: terraform-docs-v0.21.0-freebsd-arm.tar.gz
hash: 5b2e3e0cf7e71cadec2f493b2aca017d8ff10536090f41764ac73bf598b9acb7
- filename: terraform-docs-v0.21.0-freebsd-arm64.tar.gz
hash: 775e1bf444917d8706890f66eb0f2af535a436c5d6b03a31f0b29d79e27e5ed2
- filename: terraform-docs-v0.21.0-linux-amd64.tar.gz
hash: 2fdd81b8d21ff1498cd559af0dcc5d155835f84600db06d3923e217124fc735a
- filename: terraform-docs-v0.21.0-linux-arm.tar.gz
hash: bf05a610710c25551b66a8b536a5b945da8fa26b8d68a2ade4af59119492e4f5
- filename: terraform-docs-v0.21.0-linux-arm64.tar.gz
hash: 35b2e6846268841484e6eea7d00d7dfe2c94b4725e52cfe19aa6c26a86c32edc
- filename: terraform-docs-v0.21.0-windows-amd64.zip
hash: 9f45957d50656ec91c6172d73a6c9e6a22df2ccc7ca880cf288d19d6f5e349db
- filename: terraform-docs-v0.21.0-windows-arm64.zip
hash: a9ca3577209b2c5f21a0d89afdee82e6ad912058d64c364b7a7535abb57e3092

View File

@@ -13,7 +13,7 @@ Usage: $this [-b bindir] [-d] [-q] [-n] [tag]
-q turns on quiet mode (errors only)
-n turns on dry run mode
[tag] is a tag from
https://github.com/asciinema/asciinema/releases
https://github.com/terraform-docs/terraform-docs/releases
If tag is missing, then latest will be used.
Environment variables:
@@ -410,10 +410,16 @@ github_release() {
# --- Embedded Checksums (Format: VERSION:FILENAME:HASH) ---
EMBEDDED_CHECKSUMS="
3.1.0:asciinema-aarch64-apple-darwin:c354d4abcbeae94c592df0d70417d6fca8400546c3b4b5b666761fa8b1a9bca8
3.1.0:asciinema-aarch64-unknown-linux-gnu:dd6a08eed98d200b0a00d6756b564c10d95f7b6de940c8bac52098a55221f300
3.1.0:asciinema-x86_64-apple-darwin:5f0531ada539ce32224e2c680d8022b77ee82fd7b4fd24569f78f1772d38750c
3.1.0:asciinema-x86_64-unknown-linux-musl:7c5dc9172a9a9202dd8f558b9df2220785e9b4ce2763091fc22e9f9a458a161b"
0.21.0:terraform-docs-v0.21.0-darwin-amd64.tar.gz:ddf4b53925d857ae81210ebeda32b429a17385d6e4561ab1972067a9ccb36873
0.21.0:terraform-docs-v0.21.0-darwin-arm64.tar.gz:92d6988d8c59c25aa1724068f4bc2d0f01a9d4706077e258e946e944ad7eee03
0.21.0:terraform-docs-v0.21.0-freebsd-amd64.tar.gz:0be85796f3709a5b42807b8d25cb5c4c8d0fd1c1dc7aa14388c212c34376a638
0.21.0:terraform-docs-v0.21.0-freebsd-arm.tar.gz:5b2e3e0cf7e71cadec2f493b2aca017d8ff10536090f41764ac73bf598b9acb7
0.21.0:terraform-docs-v0.21.0-freebsd-arm64.tar.gz:775e1bf444917d8706890f66eb0f2af535a436c5d6b03a31f0b29d79e27e5ed2
0.21.0:terraform-docs-v0.21.0-linux-amd64.tar.gz:2fdd81b8d21ff1498cd559af0dcc5d155835f84600db06d3923e217124fc735a
0.21.0:terraform-docs-v0.21.0-linux-arm.tar.gz:bf05a610710c25551b66a8b536a5b945da8fa26b8d68a2ade4af59119492e4f5
0.21.0:terraform-docs-v0.21.0-linux-arm64.tar.gz:35b2e6846268841484e6eea7d00d7dfe2c94b4725e52cfe19aa6c26a86c32edc
0.21.0:terraform-docs-v0.21.0-windows-amd64.zip:9f45957d50656ec91c6172d73a6c9e6a22df2ccc7ca880cf288d19d6f5e349db
0.21.0:terraform-docs-v0.21.0-windows-arm64.zip:a9ca3577209b2c5f21a0d89afdee82e6ad912058d64c364b7a7535abb57e3092"
# Find embedded checksum for a given version and filename
find_embedded_checksum() {
@@ -464,28 +470,12 @@ resolve_asset_filename() {
# --- Apply Rules ---
ASSET_FILENAME=""
if [ "${UNAME_ARCH}" = 'amd64' ] && true
if [ "${UNAME_OS}" = 'windows' ] && true
then
ARCH='x86_64'
fi
if [ "${UNAME_ARCH}" = 'arm64' ] && true
then
ARCH='aarch64'
fi
if [ "${UNAME_OS}" = 'darwin' ] && true
then
OS='apple-darwin'
fi
if [ "${UNAME_OS}" = 'linux' ] && [ "${UNAME_ARCH}" = 'amd64' ] && true
then
OS='unknown-linux-musl'
fi
if [ "${UNAME_OS}" = 'linux' ] && [ "${UNAME_ARCH}" = 'arm64' ] && true
then
OS='unknown-linux-gnu'
EXT='.zip'
fi
if [ -z "${ASSET_FILENAME}" ]; then
ASSET_FILENAME="asciinema-${ARCH}-${OS}${EXT}"
ASSET_FILENAME="terraform-docs-${TAG}-${OS}-${ARCH}${EXT}"
fi
}
# Cleanup function to remove temporary files and stop progress
@@ -501,7 +491,7 @@ cleanup() {
execute() {
STRIP_COMPONENTS=0
CHECKSUM_FILENAME=""
CHECKSUM_FILENAME="terraform-docs-${TAG}.sha256sum"
# --- Construct URLs ---
GITHUB_DOWNLOAD="https://github.com/${REPO}/releases/download"
@@ -550,11 +540,11 @@ execute() {
log_info "Extracting ${ASSET_FILENAME}..."
(cd "${TMPDIR}" && untar "${ASSET_FILENAME}" "${STRIP_COMPONENTS}")
fi
BINARY_NAME='asciinema'
BINARY_NAME='terraform-docs'
if [ -z "${EXT}" ] || [ "${EXT}" = ".exe" ]; then
BINARY_PATH="${TMPDIR}/${ASSET_FILENAME}"
else
BINARY_PATH="${TMPDIR}/${ASSET_FILENAME}"
BINARY_PATH="${TMPDIR}/terraform-docs"
fi
if [ "${UNAME_OS}" = "windows" ]; then
@@ -588,9 +578,9 @@ execute() {
}
# --- Configuration ---
NAME='asciinema'
REPO='asciinema/asciinema'
EXT=''
NAME='terraform-docs'
REPO='terraform-docs/terraform-docs'
EXT='.tar.gz'
# use in logging routines
log_prefix() {
@@ -607,7 +597,7 @@ OS="${BINSTALLER_OS:-$(uname_os)}"
UNAME_OS="${OS}"
ARCH="${BINSTALLER_ARCH:-$(uname_arch)}"
UNAME_ARCH="${ARCH}"
log_info "Detected Platform: ${OS}/${ARCH}"
# --- Validate platform ---