diff --git a/.github/workflows/publish.yml b/.github/workflows/publish.yml new file mode 100644 index 0000000..34da9c3 --- /dev/null +++ b/.github/workflows/publish.yml @@ -0,0 +1,38 @@ +name: brew pr-pull + +on: + pull_request_target: + types: + - labeled + +jobs: + pr-pull: + if: contains(github.event.pull_request.labels.*.name, 'pr-pull') + runs-on: ubuntu-22.04 + permissions: + contents: write + pull-requests: write + steps: + - name: Set up Homebrew + uses: Homebrew/actions/setup-homebrew@master + + - name: Set up git + uses: Homebrew/actions/git-user-config@master + + - name: Pull bottles + env: + HOMEBREW_GITHUB_API_TOKEN: ${{ github.token }} + PULL_REQUEST: ${{ github.event.pull_request.number }} + run: brew pr-pull --debug --tap="$GITHUB_REPOSITORY" "$PULL_REQUEST" + + - name: Push commits + uses: Homebrew/actions/git-try-push@master + with: + token: ${{ github.token }} + branch: main + + - name: Delete branch + if: github.event.pull_request.head.repo.fork == false + env: + BRANCH: ${{ github.event.pull_request.head.ref }} + run: git push --delete origin "$BRANCH" diff --git a/.github/workflows/tests.yml b/.github/workflows/tests.yml new file mode 100644 index 0000000..f4567f6 --- /dev/null +++ b/.github/workflows/tests.yml @@ -0,0 +1,41 @@ +name: brew test-bot + +on: + push: + branches: + - main + pull_request: + +jobs: + test-bot: + strategy: + matrix: + os: [ubuntu-22.04, macos-13] + runs-on: ${{ matrix.os }} + steps: + - name: Set up Homebrew + id: set-up-homebrew + uses: Homebrew/actions/setup-homebrew@master + + - name: Cache Homebrew Bundler RubyGems + uses: actions/cache@v4 + with: + path: ${{ steps.set-up-homebrew.outputs.gems-path }} + key: ${{ runner.os }}-rubygems-${{ steps.set-up-homebrew.outputs.gems-hash }} + restore-keys: ${{ runner.os }}-rubygems- + + - run: brew test-bot --only-cleanup-before + + - run: brew test-bot --only-setup + + - run: brew test-bot --only-tap-syntax + + - run: brew test-bot --only-formulae + if: github.event_name == 'pull_request' + + - name: Upload bottles as artifact + if: always() && github.event_name == 'pull_request' + uses: actions/upload-artifact@v4 + with: + name: bottles_${{ matrix.os }} + path: '*.bottle.*' diff --git a/.gitignore b/.gitignore new file mode 100644 index 0000000..cd78447 --- /dev/null +++ b/.gitignore @@ -0,0 +1 @@ +temp/ \ No newline at end of file diff --git a/Casks/g/galasactl.rb b/Casks/g/galasactl.rb new file mode 100644 index 0000000..492f2e8 --- /dev/null +++ b/Casks/g/galasactl.rb @@ -0,0 +1,22 @@ + +cask "galasactl" do + arch arm: "arm64", intel: "x86-64" + + version "0.36.0" + # Create the sha256 using shasum --algorithm 256 + sha256 arm: "d162571e1fa71d78f0d625d4feb6d17da21da54b5888f6fedc52902330accf98", + intel: "a1ad08b22a1ca6f8f0755e34aec2a4b69ffee19450966753ba9a9f938c481653" + + url "https://github.com/galasa-dev/cli/releases/download/v#{version}/galasactl-darwin-#{arch}", + verified: "github.com/galasa-dev/cli/releases/" + name "Galasa Client" + desc "Client to interact with the Galasa ecosystem or local development environment. Latest version." + homepage "https://galasa.dev/" + + livecheck do + url :url + strategy :github_latest + end + + binary "galasactl-darwin-#{arch}", target: "galasactl" +end diff --git a/Casks/g/galasactl@0.33.0.rb b/Casks/g/galasactl@0.33.0.rb new file mode 100644 index 0000000..b10d6f5 --- /dev/null +++ b/Casks/g/galasactl@0.33.0.rb @@ -0,0 +1,21 @@ +cask "galasactl@0.33.0" do + arch arm: "arm64", intel: "x86-64" + + version "0.33.0" + # Create the sha256 using shasum --algorithm 256 + sha256 arm: "2965195ff7da084a3b60e48547f6ffc26bada6ae7bfebcf3c804041cd829f8cc", + intel: "c60ab567dc246422507146460feb44f367e176bbfa69b33bdf232c56977f768e" + + url "https://github.com/galasa-dev/cli/releases/download/v#{version}/galasactl-darwin-#{arch}", + verified: "github.com/galasa-dev/cli/releases/" + name "Galasa Client" + desc "Client to interact with the Galasa ecosystem or local development environment" + homepage "https://galasa.dev/" + + livecheck do + url :url + strategy :github_latest + end + + binary "galasactl-darwin-#{arch}", target: "galasactl" +end diff --git a/Casks/g/galasactl@0.34.0.rb b/Casks/g/galasactl@0.34.0.rb new file mode 100644 index 0000000..a2c63b3 --- /dev/null +++ b/Casks/g/galasactl@0.34.0.rb @@ -0,0 +1,21 @@ +cask "galasactl@0.34.0" do + arch arm: "arm64", intel: "x86-64" + + version "0.34.0" + # Create the sha256 using shasum --algorithm 256 + sha256 arm: "f6db24d394dcda85d0a6c93d24279f0e99a149c842fb2628b13c82409f794fd0", + intel: "47971b6d3427f4f3d9721ddcd98e6bfde73560d95df43f6a40837d6fd79f0f08" + + url "https://github.com/galasa-dev/cli/releases/download/v#{version}/galasactl-darwin-#{arch}", + verified: "github.com/galasa-dev/cli/releases/" + name "Galasa Client" + desc "Client to interact with the Galasa ecosystem or local development environment" + homepage "https://galasa.dev/" + + livecheck do + url :url + strategy :github_latest + end + + binary "galasactl-darwin-#{arch}", target: "galasactl" +end diff --git a/Casks/g/galasactl@0.34.1.rb b/Casks/g/galasactl@0.34.1.rb new file mode 100644 index 0000000..b086e86 --- /dev/null +++ b/Casks/g/galasactl@0.34.1.rb @@ -0,0 +1,21 @@ +cask "galasactl@0.34.1" do + arch arm: "arm64", intel: "x86-64" + + version "0.34.1" + # Create the sha256 using shasum --algorithm 256 + sha256 arm: "9336ff87dfe927a5fd07f5d59cffeb165680e4ce08ed199350810513b94ad85e", + intel: "f3be42f09c4b1dc0765c8c381bbb73f7095aa2d133bbd5916763ee025401ba17" + + url "https://github.com/galasa-dev/cli/releases/download/v#{version}/galasactl-darwin-#{arch}", + verified: "github.com/galasa-dev/cli/releases/" + name "Galasa Client" + desc "Client to interact with the Galasa ecosystem or local development environment" + homepage "https://galasa.dev/" + + livecheck do + url :url + strategy :github_latest + end + + binary "galasactl-darwin-#{arch}", target: "galasactl" +end diff --git a/Casks/g/galasactl@0.35.0.rb b/Casks/g/galasactl@0.35.0.rb new file mode 100644 index 0000000..56c98e8 --- /dev/null +++ b/Casks/g/galasactl@0.35.0.rb @@ -0,0 +1,21 @@ +cask "galasactl@0.35.0" do + arch arm: "arm64", intel: "x86-64" + + version "0.35.0" + # Create the sha256 using shasum --algorithm 256 + sha256 arm: "8bf6aa19fd5ea6e34c40379165892272c67f74c6b11992a9f1840cc72e79e08c", + intel: "fc0f31701c06e1cfda03ed9c3303776a214cbab3d0d863a3ee4eaf6d5d40c0ff" + + url "https://github.com/galasa-dev/cli/releases/download/v#{version}/galasactl-darwin-#{arch}", + verified: "github.com/galasa-dev/cli/releases/" + name "Galasa Client" + desc "Client to interact with the Galasa ecosystem or local development environment" + homepage "https://galasa.dev/" + + livecheck do + url :url + strategy :github_latest + end + + binary "galasactl-darwin-#{arch}", target: "galasactl" +end diff --git a/Casks/g/galasactl@0.36.0.rb b/Casks/g/galasactl@0.36.0.rb new file mode 100644 index 0000000..beebcaf --- /dev/null +++ b/Casks/g/galasactl@0.36.0.rb @@ -0,0 +1,21 @@ +cask "galasactl@0.36.0" do + arch arm: "arm64", intel: "x86-64" + + version "0.36.0" + # Create the sha256 using shasum --algorithm 256 + sha256 arm: "d162571e1fa71d78f0d625d4feb6d17da21da54b5888f6fedc52902330accf98", + intel: "a1ad08b22a1ca6f8f0755e34aec2a4b69ffee19450966753ba9a9f938c481653" + + url "https://github.com/galasa-dev/cli/releases/download/v#{version}/galasactl-darwin-#{arch}", + verified: "github.com/galasa-dev/cli/releases/" + name "Galasa Client" + desc "Client to interact with the Galasa ecosystem or local development environment. Version 0.36.0." + homepage "https://galasa.dev/" + + livecheck do + url :url + strategy :github_latest + end + + binary "galasactl-darwin-#{arch}", target: "galasactl" +end diff --git a/README.md b/README.md new file mode 100644 index 0000000..6e7be3c --- /dev/null +++ b/README.md @@ -0,0 +1,38 @@ +# Galasa Tap + +## How do I install these casks? + +`brew install galasa-dev/tap/` + +Or `brew tap galasa-dev/tap` and then `brew install `. + +## Casks +Currently different version of casks for the Galasa Command-Line interface (galasactl). To install the latest version use the following command + +``` +brew install --no-quarantine galasactl +``` + +for a specific version use + +``` +brew install --no-quarantine galasactl@x.xx.x +``` +for example +``` +brew install --no-quarantine galasactl@0.33.0 +``` + +At the moment the --no-quarantine is required because otherwise its not possible to run the galasactl. See documentation about this at +https://galasa.dev. + +## For maintainers: Releaseing a new version +Use the helper script `add-version.sh` + +For example: +```bash +./add-version.sh --version 0.36.0 +``` + +The file Cask/g/galasactl.rb will be updated with that version, so people can get that as the latest version. +An extra formula will be added for that version specifically also. diff --git a/add-version.sh b/add-version.sh new file mode 100755 index 0000000..d71201a --- /dev/null +++ b/add-version.sh @@ -0,0 +1,209 @@ +#! /usr/bin/env bash + +# +# Copyright contributors to the Galasa project +# +# SPDX-License-Identifier: EPL-2.0 +# + +#----------------------------------------------------------------------------------------- +# +# Objectives: Add a new version of galasactl to this tool. +# +#----------------------------------------------------------------------------------------- + +# Where is this script executing from ? +BASEDIR=$(dirname "$0");pushd $BASEDIR 2>&1 >> /dev/null ;BASEDIR=$(pwd);popd 2>&1 >> /dev/null +# echo "Running from directory ${BASEDIR}" +export ORIGINAL_DIR=$(pwd) +# cd "${BASEDIR}" + +cd "${BASEDIR}/.." +WORKSPACE_DIR=$(pwd) + +#----------------------------------------------------------------------------------------- +# +# Set Colors +# +#----------------------------------------------------------------------------------------- +bold=$(tput bold) +underline=$(tput sgr 0 1) +reset=$(tput sgr0) +red=$(tput setaf 1) +green=$(tput setaf 76) +white=$(tput setaf 7) +tan=$(tput setaf 202) +blue=$(tput setaf 25) + +#----------------------------------------------------------------------------------------- +# +# Headers and Logging +# +#----------------------------------------------------------------------------------------- +underline() { printf "${underline}${bold}%s${reset}\n" "$@" ;} +h1() { printf "\n${underline}${bold}${blue}%s${reset}\n" "$@" ;} +h2() { printf "\n${underline}${bold}${white}%s${reset}\n" "$@" ;} +debug() { printf "${white}%s${reset}\n" "$@" ;} +info() { printf "${white}➜ %s${reset}\n" "$@" ;} +success() { printf "${green}✔ %s${reset}\n" "$@" ;} +error() { printf "${red}✖ %s${reset}\n" "$@" ;} +warn() { printf "${tan}➜ %s${reset}\n" "$@" ;} +bold() { printf "${bold}%s${reset}\n" "$@" ;} +note() { printf "\n${underline}${bold}${blue}Note:${reset} ${blue}%s${reset}\n" "$@" ;} + +#----------------------------------------------------------------------------------------- +# Functions +#----------------------------------------------------------------------------------------- +function usage { + info "Syntax: add-version.sh [OPTIONS]" + cat << EOF +Options are: +-v | --version {version}: For example 0.36.0. Whichever version you put here we will try to locate and process. +-h | --help : Display this help text. +EOF +} + +#------------------------------------------------------------- +function check_exit_code () { + # This function takes 2 parameters in the form: + # $1 an integer value of the returned exit code + # $2 an error message to display if $1 is not equal to 0 + if [[ "$1" != "0" ]]; then + error "$2" + exit 1 + fi +} + +function download_executable() { + url_to_download_from=$1 + download_target_file_path=$2 + h2 "Downloading from $url_to_download_from to $download_target_file_path" + response_code=$(curl -L --silent --write-out '%{response_code}' -o $download_target_file_path $url_to_download_from) + if [[ "$response_code" != "200" ]]; then error "Failed to download version $version_to_add from url $url_to_download_from. Exit code from curl was $response_code" ; exit 1 ; fi + success "downloaded OK." +} + +function create_new_version_formula() { + x86_checksum=$1 + arm64_checksum=$2 + formula_file_path="$BASEDIR/Casks/g/galasactl@$version_to_add.rb" + h2 "Creating new formula file $formula_file_path" + + cat << EOF > $formula_file_path +cask "galasactl@${version_to_add}" do + arch arm: "arm64", intel: "x86-64" + + version "${version_to_add}" + # Create the sha256 using shasum --algorithm 256 + sha256 arm: "${arm64_checksum}", + intel: "${x86_checksum}" + + url "https://github.com/galasa-dev/cli/releases/download/v#{version}/galasactl-darwin-#{arch}", + verified: "github.com/galasa-dev/cli/releases/" + name "Galasa Client" + desc "Client to interact with the Galasa ecosystem or local development environment. Version ${version_to_add}." + homepage "https://galasa.dev/" + + livecheck do + url :url + strategy :github_latest + end + + binary "galasactl-darwin-#{arch}", target: "galasactl" +end +EOF + + check_exit_code $? "Failed to create the formula file $formula_file_path" + success "Formula file created OK." +} + + +function update_latest_formula() { + x86_checksum=$1 + arm64_checksum=$2 + formula_file_path="$BASEDIR/Casks/g/galasactl.rb" + h2 "Updating latest-version formula file $formula_file_path" + + cat << EOF > $formula_file_path + +cask "galasactl" do + arch arm: "arm64", intel: "x86-64" + + version "$version_to_add" + # Create the sha256 using shasum --algorithm 256 + sha256 arm: "${arm64_checksum}", + intel: "${x86_checksum}" + + url "https://github.com/galasa-dev/cli/releases/download/v#{version}/galasactl-darwin-#{arch}", + verified: "github.com/galasa-dev/cli/releases/" + name "Galasa Client" + desc "Client to interact with the Galasa ecosystem or local development environment. Latest version." + homepage "https://galasa.dev/" + + livecheck do + url :url + strategy :github_latest + end + + binary "galasactl-darwin-#{arch}", target: "galasactl" +end +EOF + + check_exit_code $? "Failed to update the formula file $formula_file_path" + success "Formula file updated OK." +} + +#----------------------------------------------------------------------------------------- +# Process parameters +#----------------------------------------------------------------------------------------- +version_to_add="" +while [ "$1" != "" ]; do + case $1 in + -v | --version ) shift + version_to_add="$1" + ;; + -h | --help ) usage + exit + ;; + * ) error "Unexpected argument $1" + usage + exit 1 + esac + shift +done + +if [[ "${version_to_add}" == "" ]]; then + error "Need to use the --version {version} parameter." + usage + exit 1 +fi + +h1 "Adding version $version_to_add" + +mkdir -p $BASEDIR/temp +check_exit_code $? "couldn't create a temporary folder" + +url_to_download_from=https://github.com/galasa-dev/cli/releases/download/v${version_to_add}/galasactl-darwin-x86_64 + +# Work out the base name of the file we want to download. +target_file_name=$(echo $url_to_download_from | sed "s/.*\///") +target_file_path=${BASEDIR}/temp/$target_file_name +download_executable $url_to_download_from $target_file_path +x86_checksum=$(shasum --algorithm 256 $target_file_path | cut -f1 -d' ') +info "x86 checksum is $x86_checksum" + +url_to_download_from=https://github.com/galasa-dev/cli/releases/download/v${version_to_add}/galasactl-darwin-arm64 + +# Work out the base name of the file we want to download. +target_file_name=$(echo $url_to_download_from | sed "s/.*\///") +target_file_path=${BASEDIR}/temp/$target_file_name +download_executable $url_to_download_from $target_file_path + +arm64_checksum=$(shasum --algorithm 256 $target_file_path | cut -f1 -d' ') +info "arm64 checksum is $arm64_checksum" + +create_new_version_formula $x86_checksum $arm64_checksum + +update_latest_formula $x86_checksum $arm64_checksum + +success "All done OK." \ No newline at end of file