fix: improve release scripts with .env loading and idempotent publish
Some checks are pending
CI / lint (push) Waiting to run
CI / typecheck (push) Waiting to run
CI / test (push) Waiting to run
CI / build (push) Blocked by required conditions
CI / package (push) Blocked by required conditions

Scripts now auto-load .env for GITEA_TOKEN, handle re-publishing
by deleting existing versions first, and release.sh does build +
publish + install in one command.

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
This commit is contained in:
Michal
2026-02-21 14:04:07 +00:00
parent 48fce7fe45
commit e1ed585e2a
4 changed files with 77 additions and 10 deletions

View File

@@ -17,7 +17,8 @@
"db:down": "docker compose -f deploy/docker-compose.yml down", "db:down": "docker compose -f deploy/docker-compose.yml down",
"typecheck": "tsc --build", "typecheck": "tsc --build",
"rpm:build": "bash scripts/build-rpm.sh", "rpm:build": "bash scripts/build-rpm.sh",
"rpm:publish": "bash scripts/publish-rpm.sh" "rpm:publish": "bash scripts/publish-rpm.sh",
"release": "bash scripts/release.sh"
}, },
"engines": { "engines": {
"node": ">=20.0.0", "node": ">=20.0.0",

View File

@@ -5,13 +5,17 @@ SCRIPT_DIR="$(cd "$(dirname "$0")" && pwd)"
PROJECT_ROOT="$(dirname "$SCRIPT_DIR")" PROJECT_ROOT="$(dirname "$SCRIPT_DIR")"
cd "$PROJECT_ROOT" cd "$PROJECT_ROOT"
export VERSION="${VERSION:-0.1.0}" # Load .env if present
if [ -f .env ]; then
set -a; source .env; set +a
fi
echo "==> Building TypeScript..." echo "==> Building TypeScript..."
pnpm build pnpm build
echo "==> Bundling standalone binary..." echo "==> Bundling standalone binary..."
mkdir -p dist mkdir -p dist
rm -f dist/mcpctl dist/mcpctl-*.rpm
bun build src/cli/src/index.ts --compile --outfile dist/mcpctl bun build src/cli/src/index.ts --compile --outfile dist/mcpctl
echo "==> Packaging RPM..." echo "==> Packaging RPM..."

View File

@@ -5,23 +5,44 @@ SCRIPT_DIR="$(cd "$(dirname "$0")" && pwd)"
PROJECT_ROOT="$(dirname "$SCRIPT_DIR")" PROJECT_ROOT="$(dirname "$SCRIPT_DIR")"
cd "$PROJECT_ROOT" cd "$PROJECT_ROOT"
# Load .env if present
if [ -f .env ]; then
set -a; source .env; set +a
fi
GITEA_URL="${GITEA_URL:-http://10.0.0.194:3012}" GITEA_URL="${GITEA_URL:-http://10.0.0.194:3012}"
GITEA_OWNER="${GITEA_OWNER:-michal}" GITEA_OWNER="${GITEA_OWNER:-michal}"
if [ -z "$GITEA_TOKEN" ]; then if [ -z "$GITEA_TOKEN" ]; then
echo "Error: GITEA_TOKEN environment variable is required" echo "Error: GITEA_TOKEN not set. Add it to .env or export it."
echo "Create one at: ${GITEA_URL}/user/settings/applications"
exit 1 exit 1
fi fi
RPM_FILE=$(ls dist/mcpctl-*.rpm 2>/dev/null | head -1) RPM_FILE=$(ls dist/mcpctl-*.rpm 2>/dev/null | head -1)
if [ -z "$RPM_FILE" ]; then if [ -z "$RPM_FILE" ]; then
echo "Error: No RPM file found in dist/. Run scripts/build-rpm.sh first." echo "Error: No RPM found in dist/. Run scripts/build-rpm.sh first."
exit 1 exit 1
fi fi
echo "==> Publishing $RPM_FILE to ${GITEA_URL}..." # Get version string as it appears in Gitea (e.g. "0.1.0-1")
curl --fail -X PUT \ RPM_VERSION=$(rpm -qp --queryformat '%{VERSION}-%{RELEASE}' "$RPM_FILE")
echo "==> Publishing $RPM_FILE (version $RPM_VERSION) to ${GITEA_URL}..."
# Check if version already exists and delete it first
EXISTING=$(curl -s -o /dev/null -w "%{http_code}" \
-H "Authorization: token ${GITEA_TOKEN}" \
"${GITEA_URL}/api/v1/packages/${GITEA_OWNER}/rpm/mcpctl/${RPM_VERSION}")
if [ "$EXISTING" = "200" ]; then
echo "==> Version $RPM_VERSION already exists, replacing..."
curl -s -o /dev/null -X DELETE \
-H "Authorization: token ${GITEA_TOKEN}" \
"${GITEA_URL}/api/v1/packages/${GITEA_OWNER}/rpm/mcpctl/${RPM_VERSION}"
fi
# Upload
curl --fail -s -X PUT \
-H "Authorization: token ${GITEA_TOKEN}" \ -H "Authorization: token ${GITEA_TOKEN}" \
--upload-file "$RPM_FILE" \ --upload-file "$RPM_FILE" \
"${GITEA_URL}/api/packages/${GITEA_OWNER}/rpm/upload" "${GITEA_URL}/api/packages/${GITEA_OWNER}/rpm/upload"
@@ -29,6 +50,6 @@ curl --fail -X PUT \
echo "" echo ""
echo "==> Published successfully!" echo "==> Published successfully!"
echo "" echo ""
echo "Users can install with:" echo "Install with:"
echo " dnf config-manager --add-repo ${GITEA_URL}/api/packages/${GITEA_OWNER}/rpm.repo" echo " sudo dnf config-manager --add-repo ${GITEA_URL}/api/packages/${GITEA_OWNER}/rpm.repo"
echo " dnf install mcpctl" echo " sudo dnf install mcpctl"

41
scripts/release.sh Executable file
View File

@@ -0,0 +1,41 @@
#!/bin/bash
set -e
SCRIPT_DIR="$(cd "$(dirname "$0")" && pwd)"
PROJECT_ROOT="$(dirname "$SCRIPT_DIR")"
cd "$PROJECT_ROOT"
# Load .env if present
if [ -f .env ]; then
set -a; source .env; set +a
fi
echo "=== mcpctl release ==="
echo ""
# Build
bash scripts/build-rpm.sh
echo ""
# Publish
bash scripts/publish-rpm.sh
echo ""
# Install locally
echo "==> Installing locally..."
RPM_FILE=$(ls dist/mcpctl-*.rpm 2>/dev/null | head -1)
sudo rpm -U --force "$RPM_FILE"
echo ""
echo "==> Installed:"
mcpctl --version
echo ""
GITEA_URL="${GITEA_URL:-http://10.0.0.194:3012}"
GITEA_OWNER="${GITEA_OWNER:-michal}"
echo "=== Done! ==="
echo "Others can install with:"
echo " sudo dnf config-manager --add-repo ${GITEA_URL}/api/packages/${GITEA_OWNER}/rpm.repo"
echo " sudo dnf install mcpctl"