From 5af4b246b56ab9a13f89992d934ce8ab26fc1bb7 Mon Sep 17 00:00:00 2001 From: Your Name Date: Sat, 9 Aug 2025 17:02:24 +1200 Subject: [PATCH] hmmm --- .gitea/workflows/BuildTestPublish.yaml | 38 +++++++++++ install.sh | 88 +++++++++----------------- 2 files changed, 68 insertions(+), 58 deletions(-) create mode 100644 .gitea/workflows/BuildTestPublish.yaml diff --git a/.gitea/workflows/BuildTestPublish.yaml b/.gitea/workflows/BuildTestPublish.yaml new file mode 100644 index 0000000..786f090 --- /dev/null +++ b/.gitea/workflows/BuildTestPublish.yaml @@ -0,0 +1,38 @@ +name: Build-Test-Publish +run-name: Build test and publish all tools + +on: [push] + +defaults: + run: + shell: bash + +jobs: + build: + strategy: + matrix: + platform: + - linux/amd64 + - linux/arm64 + runs-on: ${{ matrix.platform }} + steps: + - name: Checkout + uses: actions/checkout@v4 + - name: Login to Gitea + uses: docker/login-action@v3 + with: + registry: gitea.jde.nz + username: DoesntMatter + password: ${{ secrets.DOCKER_PUSH_TOKEN }} + - name: Build + run: | + ./build.sh + - name: Test + run: | + ./test.sh + - name: Publish + run: | + SOS_WRITE_TOKEN=${{ secrets.SOS_WRITE_TOKEN }} \ + RELEASE_WRITE_TOKEN=${{ secrets.RELEASE_WRITE_TOKEN }} \ + GITEA_CONTAINER_NAME=${{ env.JOB_CONTAINER_NAME }} \ + ./publish.sh diff --git a/install.sh b/install.sh index 4eb31d9..c8bc76b 100755 --- a/install.sh +++ b/install.sh @@ -1,69 +1,41 @@ #!/bin/bash -set -e +set -euo pipefail -# Installs bb64 on the local machine. -# 1. determines the architecture of the local machine -# 2. downloads the appropriate bb64 binary from the latest public release on Gitea (https://gitea.jde.nz/public/bb64/releases) -# 3. makes the bb64 binary executable -# 4. moves the bb64 binary to /usr/local/bin -# 5. prints a message to the user +# install bb64 using getpkg for current user. -# 0. see if we were passed a folder to install to -# ----------------------------------------------------------------------------- -INSTALL_DIR="$1" -if [[ -z "$INSTALL_DIR" ]]; then - INSTALL_DIR="/usr/local/bin" -else - echo "Installing bb64 to $INSTALL_DIR" - if [[ ! -d "$INSTALL_DIR" ]]; then - mkdir -p "$INSTALL_DIR" +PROJECT="bb64" + +#SCRIPT_DIR="$( cd "$( dirname "${BASH_SOURCE[0]}" )" &> /dev/null && pwd )" + +echo "Installing $PROJECT" + +ARCH=$(uname -m) + +# check if getpkg is installed +GETPKG_PATH="${HOME}/.local/bin/getpkg/getpkg" +if [ ! -f "$GETPKG_PATH" ]; then + wget -nv "https://getbin.xyz/getpkg:latest-${ARCH}" -O bootstrap && chmod a+x bootstrap + ./bootstrap install getpkg + rm ./bootstrap + + if [ ! -f "$GETPKG_PATH" ]; then + echo "getpkg failed to install to $GETPKG_PATH" + exit 1 fi fi -# 0. see if we were passed a user to chown to -# ----------------------------------------------------------------------------- -CHOWN_USER="$2" -if [[ -z "$CHOWN_USER" ]]; then - CHOWN_USER=$(id -u) -fi +echo "getpkg found in $GETPKG_PATH" -# 1. Determine architecture -# ----------------------------------------------------------------------------- +# install bb64 +$GETPKG_PATH install $PROJECT -ARCH=$(uname -m) -if [[ "$ARCH" == "x86_64" ]]; then - BIN=bb64.amd64 -elif [[ "$ARCH" == "aarch64" || "$ARCH" == "arm64" ]]; then - BIN=bb64.arm64 -else - echo "Unsupported architecture: $ARCH" >&2 +# confirm bb64 is installed +PROJPATH="${HOME}/.local/bin/getpkg/${PROJECT}" +if [ ! -f "$PROJPATH" ]; then + echo "getpkg failed to install $PROJECT to $PROJPATH" exit 1 fi -# 3. Download the appropriate binary to a temp directory -# ----------------------------------------------------------------------------- -TMPDIR=$(mktemp -d) -trap 'rm -rf "$TMPDIR"' EXIT -URL="https://gitea.jde.nz/public/bb64/releases/download/latest/$BIN" -echo "Downloading $BIN from $URL..." - -curl -fsSL -o "$TMPDIR/bb64" "$URL" - -# 4. Make it executable -# ----------------------------------------------------------------------------- -chmod +x "$TMPDIR/bb64" - -# 5. Move to /usr/local/bin -# ----------------------------------------------------------------------------- -docker run --rm -v "$TMPDIR:/tmp" -v "$INSTALL_DIR:/target" alpine sh -c "cp /tmp/bb64 /target/bb64; chown $CHOWN_USER /target/bb64" -rm "$TMPDIR/bb64" - -# 6. Print success message -# ----------------------------------------------------------------------------- -echo "bb64 installed successfully to $INSTALL_DIR/bb64 (arch $ARCH)" -# echo " " -# echo "Update bb64 with:" -# echo " bb64 -u" -# echo " " -# echo "try it out with:" -# echo " bb64 ZWNobyAiSGVsbG8td29ybGQhIGJiNjQgaXMgd29ya2luZy4i" +# check version +VERSION=$(${PROJPATH} version) +echo "${PROJECT} ${VERSION} installed"