diff --git a/.goreleaser.yaml b/.goreleaser.yaml index 33312eb..39f648b 100644 --- a/.goreleaser.yaml +++ b/.goreleaser.yaml @@ -42,13 +42,6 @@ release: universal_binaries: - replace: true -brews: - - name: privateer - homepage: https://github.com/privateerproj/privateer - tap: - owner: privateerproj - name: homebrew-privateer - # The lines beneath this are called `modelines`. See `:help modeline` # Feel free to remove those if you don't want/use them. # yaml-language-server: $schema=https://goreleaser.com/static/schema.json diff --git a/Makefile b/Makefile index ad08cc2..2e4e670 100644 --- a/Makefile +++ b/Makefile @@ -1,8 +1,8 @@ # Ref: https://www.digitalocean.com/community/tutorials/using-ldflags-to-set-version-information-for-go-applications BUILD_FLAGS=-X 'main.GitCommitHash=`git rev-parse --short HEAD`' -X 'main.BuiltAt=`date +%FT%T%z`' -X 'main.Version=`git describe --tags`' -BUILD_WIN=@env GOOS=windows GOARCH=amd64 go build -o privateer.exe -BUILD_LINUX=@env GOOS=linux GOARCH=amd64 go build -o privateer +BUILD_WIN=@env GOOS=windows GOARCH=amd64 go build -o privateer-windows.exe +BUILD_LINUX=@env GOOS=linux GOARCH=amd64 go build -o privateer-linux BUILD_MAC=@env GOOS=darwin GOARCH=amd64 go build -o privateer-darwin binary: go-tidy go-test go-build diff --git a/README.md b/README.md index 465a8b7..7d0f097 100644 --- a/README.md +++ b/README.md @@ -12,7 +12,7 @@ Welcome to Privateer, your all-inclusive test harness designed to streamline the Privateer has been meticulously crafted with infrastructure engineers in mind. If you're seeking to validate your resources against regulations, taxonomies, or standards, Privateer is your trusted companion. With a user-friendly interface and powerful features, you can now effortlessly navigate the complexities of resource validation. -### Unlocking the Power of Raids +### Privateer Raids There are several key benefits to Privateer Raids: @@ -38,7 +38,10 @@ Privateer empowers you to ensure the security, compliance, and integrity of your ### Installation -1. **Download Privateer**: Obtain the latest release of Privateer from the [GitHub repository](https://github.com/privateerproj/privateer/releases). +1. **Download Privateer**: Obtain the latest release of Privateer: + - from GitHub Repository source, with `go build` + - from the [GitHub Releases](https://github.com/privateerproj/privateer/releases) + - from the [installation script](install.sh) 1. **Install Raids**: Choose the raid(s) you wish to use from the same release on GitHub. Install them to your preferred `binaries-path`. By default, this is `$HOME/privateer/bin`, but you can customize it in your configuration or via `--binaries-path`. #### Build Privateer from Source diff --git a/install.sh b/install.sh new file mode 100755 index 0000000..36ecf71 --- /dev/null +++ b/install.sh @@ -0,0 +1,127 @@ +#!/bin/bash + +set -e + +# Constants +DEFAULT_INSTALL_DIR="$HOME/.privateer/bin" +PRIVATEER_REPO="privateerproj/privateer" +LATEST_RELEASE_URL="https://api.github.com/repos/${PRIVATEER_REPO}/releases/latest" + +# Detect OS (darwin = macOS, linux = Linux, msys or cygwin = Windows) +OS="" +case "$(uname -s)" in + Darwin) + OS="darwin" + ;; + Linux) + OS="linux" + ;; + CYGWIN*|MSYS*|MINGW*) + OS="windows" + ;; + *) + echo "Unsupported Environment: $(uname -s)" + exit 1 + ;; +esac + +download_latest_release() { + local install_dir="$1" + local install_file="$install_dir/privateer" + + # Ensure the directory exists + mkdir -p "$install_dir" + + # Fetch the download URL for the latest release + local url + url=$(curl -s ${LATEST_RELEASE_URL} | grep "browser_download_url.*${OS}.*" | cut -d '"' -f 4) + + if [[ -z "$url" ]]; then + echo "Failed to fetch the download URL for the latest release." + exit 1 + fi + + echo "Downloading from: $url" + + # Download the binary to the specified install directory + curl -L -o "$install_file" "$url" + + if [[ $? -ne 0 ]]; then + echo "Failed to download the binary." + exit 1 + fi + + # Ensure the binary is executable + chmod +x "$install_file" + + echo "Downloaded binary to $install_file" +} + +update_path() { + local install_dir="$1" + + # Check if the install directory is already in PATH + if [[ ":$PATH:" != *":$install_dir:"* ]]; then + echo "$install_dir is not in the PATH." + + # Detect current shell + current_shell=$(basename "$SHELL") + + case "$current_shell" in + bash) + config_file="$HOME/.bashrc" + ;; + zsh) + config_file="$HOME/.zshrc" + ;; + fish) + config_file="$HOME/.config/fish/config.fish" + ;; + *) + echo "Unsupported shell: $current_shell. You may need to manually add $install_dir to your PATH." + return + ;; + esac + + # Check if the path is already added to the config file + if ! grep -q "$install_dir" "$config_file"; then + echo "export PATH=\"$install_dir:\$PATH\"" >> "$config_file" + echo "$install_dir added to $config_file" + source $config_file + else + echo "$install_dir is already in $config_file." + fi + else + echo "$install_dir is already in the PATH." + fi +} + +# Main logic +main() { + local install_dir="$DEFAULT_INSTALL_DIR" + + # Handle CLI arguments for installation path override + while getopts "p:" opt; do + case $opt in + p) + install_dir="$OPTARG" + ;; + *) + echo "Usage: $0 [-p install_path]" + exit 1 + ;; + esac + done + + mkdir -p "$install_dir" + + # Download the latest release + download_latest_release "$install_dir" + + # Ensure the binary is accessible via PATH + update_path "$install_dir" + + echo "Privateer installation complete!" +} + +main "$@" diff --git a/privateer.rb b/privateer.rb deleted file mode 100644 index 42ff914..0000000 --- a/privateer.rb +++ /dev/null @@ -1,37 +0,0 @@ -# typed: false -# frozen_string_literal: true - -# This file was generated by GoReleaser. DO NOT EDIT. -class Privateer < Formula - desc "" - homepage "https://github.com/privateerproj/privateer" - version "0.0.0-rc" - - on_macos do - url "https://github.com/privateerproj/privateer/releases/download/v0.0.0-rc/privateer_Darwin_all.tar.gz" - sha256 "850f06f019c7674f1e29da9d54a21d8542a3e6776b25ff44ac757b333db6aac4" - - def install - bin.install "privateer" - end - end - - on_linux do - if Hardware::CPU.arm? && Hardware::CPU.is_64_bit? - url "https://github.com/privateerproj/privateer/releases/download/v0.0.0-rc/privateer_Linux_arm64.tar.gz" - sha256 "9d35211b49db54a166648be9dfd1ba636d28335121517cfa5aa91114a20c1593" - - def install - bin.install "privateer" - end - end - if Hardware::CPU.intel? - url "https://github.com/privateerproj/privateer/releases/download/v0.0.0-rc/privateer_Linux_x86_64.tar.gz" - sha256 "514f870b8ec91297b7186ff41f2a7166ee4463504af58031c45e01abdae9cbe6" - - def install - bin.install "privateer" - end - end - end -end