config: Add 6 files
All checks were successful
Build-Test-Publish / build (linux/amd64) (push) Successful in 12s
Build-Test-Publish / build (linux/arm64) (push) Successful in 13s

This commit is contained in:
Your Name
2025-09-02 20:14:10 +12:00
parent 23b3752322
commit dac2d08aef
3 changed files with 113 additions and 0 deletions

View File

@@ -0,0 +1,35 @@
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: 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

5
.gitignore vendored Normal file
View File

@@ -0,0 +1,5 @@
output/
*.swp
*.tmp
*~
.DS_Store

73
publish.sh Executable file
View File

@@ -0,0 +1,73 @@
#!/bin/bash
set -euo pipefail
SCRIPT_DIR="$( cd "$( dirname "${BASH_SOURCE[0]}" )" &> /dev/null && pwd )"
ARCH=$(uname -m)
PROJECT="$(basename "${SCRIPT_DIR}")"
OUTPUT="${SCRIPT_DIR}/output"
function heading() {
# print a heading with a line of dashes
echo "--------------------------------"
echo "$1"
echo "--------------------------------"
}
#--------------------------------------------------------------------------------
heading "Publishing ${PROJECT}"
function die() {
heading "error: $1"
exit 1
}
[[ -n ${SOS_WRITE_TOKEN:-} ]] || die "SOS_WRITE_TOKEN not specified"
# clear output dir
rm -rf "${OUTPUT}"
mkdir -p "${OUTPUT}"
#--------------------------------------------------------------------------------
# install getpkg
GETPKG_PATH="${HOME}/.local/bin/getpkg/getpkg"
if [ ! -f "${GETPKG_PATH}" ]; then
heading "Installing getpkg"
curl https://getbin.xyz/getpkg-install | bash
if [ ! -f "${GETPKG_PATH}" ]; then
die "getpkg failed to install to ${GETPKG_PATH}"
fi
fi
#--------------------------------------------------------------------------------
heading "Publishing ${PROJECT} as tool to ${PROJECT}:${ARCH} (on getpkg.xyz)"
TOOLDIR="${OUTPUT}/tool"
mkdir "${TOOLDIR}"
cp "${PROJECT}" "${TOOLDIR}/${PROJECT}"
"${GETPKG_PATH}" server set-token getpkg.xyz "${SOS_WRITE_TOKEN}"
"${GETPKG_PATH}" publish "${PROJECT}:${ARCH}" "${TOOLDIR}"
#--------------------------------------------------------------------------------
heading "Publishing ${PROJECT} to getbin.xyz"
# Download sos if not already present
SOS="${OUTPUT}/sos"
if [ ! -f "${SOS}" ]; then
heading "Downloading sos tool"
curl -L -s -o "${SOS}" "https://getbin.xyz/sos:latest" || die "Failed to download sos"
chmod +x "${SOS}"
fi
# Upload architecture-specific binary to getbin.xyz
heading "Uploading ${PROJECT} binary to getbin.xyz as ${PROJECT}:latest-${ARCH}"
"${SOS}" upload "getbin.xyz" "${PROJECT}" "${PROJECT}:latest-${ARCH}" || die "Failed to upload ${PROJECT} binary to getbin.xyz"
# Check if there's an install script to upload
if [ -f "${SCRIPT_DIR}/install.sh" ]; then
heading "Uploading install.sh to getbin.xyz as ${PROJECT}-install:latest"
"${SOS}" upload "getbin.xyz" "${SCRIPT_DIR}/install.sh" "${PROJECT}-install:latest" || die "Failed to upload install script to getbin.xyz"
fi
heading "Successfully published ${PROJECT} to both getpkg.xyz and getbin.xyz"