5 Commits
Author SHA1 Message Date
Qiufeng 4f2ea26e8e ops: point CentOS recovery at v0.3.4 2026-08-04 17:44:25 +08:00
Qiufeng e295ad8b96 ci: provision Java for signed releases
Signed Release / release (push) Successful in 17m17s
2026-08-04 17:18:25 +08:00
Qiufeng 99b8126b59 test: isolate release checks across platforms
Signed Release / release (push) Failing after 35s
2026-08-04 17:11:45 +08:00
Qiufeng b472581622 fix: pull runner from Gitea registry 2026-08-04 16:14:59 +08:00
Qiufeng 8fe558f6c1 ops: add one-command Gitea runner setup 2026-08-04 15:59:52 +08:00
4 changed files with 176 additions and 3 deletions
+6
View File
@@ -25,6 +25,12 @@ jobs:
with: with:
fetch-depth: 0 fetch-depth: 0
- name: Set up Java 17
uses: actions/setup-java@v4
with:
distribution: temurin
java-version: "17"
- name: Build, sign, and publish release - name: Build, sign, and publish release
shell: bash shell: bash
run: | run: |
+1 -1
View File
@@ -3,7 +3,7 @@ set -Eeuo pipefail
GITEA_BASE_URL="http://38.76.196.225:10099" GITEA_BASE_URL="http://38.76.196.225:10099"
REPOSITORY="awaioi/ERP" REPOSITORY="awaioi/ERP"
VERSION="0.3.1" VERSION="0.3.4"
TAG="v${VERSION}" TAG="v${VERSION}"
INSTALL_SHA256="89a3c45e76f500c9475cb596ea29e3518bfafdc59f36dd3c7b316ed3cdd0448c" INSTALL_SHA256="89a3c45e76f500c9475cb596ea29e3518bfafdc59f36dd3c7b316ed3cdd0448c"
UNINSTALL_SHA256="98c56fed2fd4d01874e4ab5a1a4f3ec42ec3e29b315ffd87385a95488d587546" UNINSTALL_SHA256="98c56fed2fd4d01874e4ab5a1a4f3ec42ec3e29b315ffd87385a95488d587546"
+164
View File
@@ -0,0 +1,164 @@
#!/usr/bin/env bash
set -Eeuo pipefail
GITEA_URL="${GITEA_URL:-http://38.76.196.225:10099/}"
GITEA_REPOSITORY="${GITEA_REPOSITORY:-awaioi/ERP}"
RUNNER_IMAGE="${RUNNER_IMAGE:-}"
RUNNER_CONTAINER="${RUNNER_CONTAINER:-gitea-runner}"
RUNNER_VOLUME="${RUNNER_VOLUME:-gitea-runner-data}"
RUNNER_LABELS="${RUNNER_LABELS:-ubuntu-latest:docker://docker.gitea.com/runner-images:ubuntu-latest}"
log() {
printf '[Gitea Runner] %s\n' "$*"
}
fail() {
printf '[Gitea Runner] ERROR: %s\n' "$*" >&2
exit 1
}
command -v docker >/dev/null 2>&1 || fail "docker is not installed"
docker info >/dev/null 2>&1 || fail "docker is not running or the current user cannot access it"
find_gitea_container() {
local container_id image name
while read -r container_id image name; do
case "$image" in
gitea/gitea:* | gitea/gitea@* | */gitea/gitea:* | */gitea/gitea@* | docker.gitea.com/gitea:* | docker.gitea.com/gitea@*)
printf '%s\n' "$container_id"
return 0
;;
esac
done < <(docker ps --format '{{.ID}} {{.Image}} {{.Names}}')
while read -r container_id name; do
case "$name" in
*runner*) ;;
*gitea*)
printf '%s\n' "$container_id"
return 0
;;
esac
done < <(docker ps --format '{{.ID}} {{.Names}}')
return 1
}
pull_runner_image() {
local candidate
local -a candidates
if [[ -n "$RUNNER_IMAGE" ]]; then
candidates=("$RUNNER_IMAGE")
else
candidates=(
"docker.gitea.com/runner:3.0.2"
"docker.gitea.com/act_runner:3.0.2"
"gitea/runner:3.0.2"
)
fi
for candidate in "${candidates[@]}"; do
log "Pulling $candidate"
if docker pull "$candidate"; then
RUNNER_IMAGE="$candidate"
return 0
fi
log "Image source failed; trying the next source"
done
fail "all official Gitea Runner image sources failed"
}
GITEA_CONTAINER="$(find_gitea_container || true)"
[[ -n "$GITEA_CONTAINER" ]] || fail "no running Gitea container was found"
TMP_DIR="$(mktemp -d)"
TOKEN_FILE="$TMP_DIR/runner-token"
BOOTSTRAP_RUNNING=0
cleanup() {
if [[ "$BOOTSTRAP_RUNNING" == "1" ]]; then
docker rm -f "$RUNNER_CONTAINER" >/dev/null 2>&1 || true
fi
if [[ -f "$TOKEN_FILE" ]]; then
: >"$TOKEN_FILE"
fi
rm -rf -- "$TMP_DIR"
}
trap cleanup EXIT
log "Generating a repository-scoped registration token"
if ! docker exec -u git "$GITEA_CONTAINER" gitea actions generate-runner-token \
--scope "$GITEA_REPOSITORY" | tr -d '\r' | tail -n 1 >"$TOKEN_FILE"; then
fail "Gitea could not generate a runner token"
fi
[[ -s "$TOKEN_FILE" ]] || fail "Gitea returned an empty runner token"
chmod 600 "$TOKEN_FILE"
pull_runner_image
docker rm -f "$RUNNER_CONTAINER" >/dev/null 2>&1 || true
docker volume create "$RUNNER_VOLUME" >/dev/null
docker run --rm --entrypoint /bin/rm \
-v "$RUNNER_VOLUME:/data" \
"$RUNNER_IMAGE" -f /data/.runner
log "Registering the runner"
docker run -d \
--name "$RUNNER_CONTAINER" \
-v "$RUNNER_VOLUME:/data" \
-v "$TOKEN_FILE:/run/secrets/gitea_runner_token:ro,Z" \
-v /var/run/docker.sock:/var/run/docker.sock \
-e "GITEA_INSTANCE_URL=$GITEA_URL" \
-e GITEA_RUNNER_REGISTRATION_TOKEN_FILE=/run/secrets/gitea_runner_token \
-e "GITEA_RUNNER_NAME=erp-release-$(hostname -s)" \
-e "GITEA_RUNNER_LABELS=$RUNNER_LABELS" \
-e GITEA_MAX_REG_ATTEMPTS=24 \
"$RUNNER_IMAGE" >/dev/null
BOOTSTRAP_RUNNING=1
READY=0
for ((attempt = 1; attempt <= 60; attempt++)); do
if docker exec "$RUNNER_CONTAINER" test -s /data/.runner 2>/dev/null; then
READY=1
break
fi
if [[ "$(docker inspect -f '{{.State.Running}}' "$RUNNER_CONTAINER" 2>/dev/null || true)" != "true" ]]; then
break
fi
sleep 2
done
if [[ "$READY" != "1" ]]; then
docker logs --tail 100 "$RUNNER_CONTAINER" >&2 || true
fail "runner registration failed"
fi
docker logs --tail 30 "$RUNNER_CONTAINER" || true
docker rm -f "$RUNNER_CONTAINER" >/dev/null
BOOTSTRAP_RUNNING=0
: >"$TOKEN_FILE"
log "Starting the persistent runner without the registration token"
docker run -d \
--name "$RUNNER_CONTAINER" \
--restart unless-stopped \
-v "$RUNNER_VOLUME:/data" \
-v /var/run/docker.sock:/var/run/docker.sock \
-e "GITEA_INSTANCE_URL=$GITEA_URL" \
-e "GITEA_RUNNER_NAME=erp-release-$(hostname -s)" \
-e "GITEA_RUNNER_LABELS=$RUNNER_LABELS" \
"$RUNNER_IMAGE" >/dev/null
sleep 5
[[ "$(docker inspect -f '{{.State.Running}}' "$RUNNER_CONTAINER")" == "true" ]] || {
docker logs --tail 100 "$RUNNER_CONTAINER" >&2 || true
fail "runner container stopped after registration"
}
log "Runner is online; queued release jobs can now continue"
docker ps --filter "name=^/${RUNNER_CONTAINER}$" \
--format 'table {{.Names}}\t{{.Image}}\t{{.Status}}'
docker logs --tail 80 "$RUNNER_CONTAINER" || true
+5 -2
View File
@@ -312,7 +312,7 @@ PY
NO_SERVICE=0 NO_SERVICE=0
PUBLIC_KEY="$(<"$tmp/public.pem")" PUBLIC_KEY="$(<"$tmp/public.pem")"
detect_platform() { PLATFORM=darwin; } detect_platform() { PLATFORM=darwin; ARCH=amd64; }
check_and_install_dependencies() { JAVA_BIN="$(command -v java)"; return 0; } check_and_install_dependencies() { JAVA_BIN="$(command -v java)"; return 0; }
start_service() { return 0; } start_service() { return 0; }
wait_for_installer() { return 0; } wait_for_installer() { return 0; }
@@ -323,7 +323,7 @@ PY
[[ -r "$INSTALL_ROOT/current/app/kaidi-erp.jar" ]] || return 1 [[ -r "$INSTALL_ROOT/current/app/kaidi-erp.jar" ]] || return 1
( (
source "$ERP_CONFIG_ROOT/erp.env" source "$ERP_CONFIG_ROOT/erp.env"
[[ "$SPRING_PROFILES_ACTIVE" == "postgres" ]] [[ -z "${SPRING_PROFILES_ACTIVE:-}" ]]
[[ "$OA_UPDATE_ENABLED" == "true" ]] [[ "$OA_UPDATE_ENABLED" == "true" ]]
[[ "$OA_UPDATE_GITEA_BASE_URL" == "http://127.0.0.1:$port" ]] [[ "$OA_UPDATE_GITEA_BASE_URL" == "http://127.0.0.1:$port" ]]
[[ "$ERP_SETUP_TOKEN" =~ ^[0-9a-f]{64}$ ]] [[ "$ERP_SETUP_TOKEN" =~ ^[0-9a-f]{64}$ ]]
@@ -528,6 +528,7 @@ test_installer_requires_explicit_gitea_url() (
set -- set --
source "$root/install.sh" source "$root/install.sh"
GITEA_BASE_URL= GITEA_BASE_URL=
NO_SERVICE=1
main main
' _ "$PROJECT_ROOT" 2>&1)" || status=$? ' _ "$PROJECT_ROOT" 2>&1)" || status=$?
[[ "$status" -ne 0 && "$output" == *'Gitea URL is required'* ]] [[ "$status" -ne 0 && "$output" == *'Gitea URL is required'* ]]
@@ -680,6 +681,8 @@ test_release_workflow_uses_scoped_job_token() (
grep -Fqx ' releases: write' "$workflow" grep -Fqx ' releases: write' "$workflow"
grep -Fq 'GITEA_BASE_URL: ${{ github.server_url }}' "$workflow" grep -Fq 'GITEA_BASE_URL: ${{ github.server_url }}' "$workflow"
grep -Fq 'GITEA_TOKEN: ${{ secrets.GITEA_TOKEN }}' "$workflow" grep -Fq 'GITEA_TOKEN: ${{ secrets.GITEA_TOKEN }}' "$workflow"
grep -Fq 'uses: actions/setup-java@v4' "$workflow"
grep -Fq 'java-version: "17"' "$workflow"
! grep -Fq 'RELEASE_GITEA_TOKEN' "$workflow" ! grep -Fq 'RELEASE_GITEA_TOKEN' "$workflow"
! grep -Fq 'vars.GITEA_BASE_URL' "$workflow" ! grep -Fq 'vars.GITEA_BASE_URL' "$workflow"
) )