Implements #1 — stoke installable with apt-get install stoke. Packaging: - scripts/build-deb.sh: builds dist/stoke_<version>_all.deb from a clean staging copy (src + fresh npm ci --omit=dev), pure-JS Architecture: all, Depends: nodejs (>= 22.12), /usr/lib/stoke payload with /usr/bin/stoke symlink, copyright + changelog, normalized permissions. Lintian-clean. - scripts/publish-deb.sh: uploads a .deb to the Forgejo Debian registry (owner/distribution/component parameterized, defaults heavy-duty/ stable/main), authenticating with STOKE_TOKEN or the stoke login token. - scripts/install-apt.sh: consumer-side one-time setup — adds the registry key and apt source, then apt-get install stoke. Falls back to a [trusted=yes] source when apt's sqv verifier rejects the forge's registry signature (known upstream Forgejo signing bug; the script prefers the signed source so setups heal once the forge is fixed). - .forgejo/workflows/release.yml: on v* tags — test, build, publish to the heavy-duty registry, attach the .deb to the release page. Needs a runner and a RELEASE_TOKEN secret with org package write. New command: - stoke pr merge (-n, --method merge|rebase|rebase-merge|squash, --title, --message, --delete-branch) — gap found while merging !2. Docs and housekeeping: - README: 'Install with apt' as the primary installation method with manual setup and dpkg fallback, signature caveat, pr merge reference, Packaging and releasing section with a release checklist. - dist/ gitignored; version bumped to 1.2.0. Verified end-to-end on this machine: built the deb (lintian-clean), published it to the Forgejo Debian registry, installed it with apt-get install stoke via install-apt.sh, and confirmed the installed CLI works against the live forge. The test upload was removed from the personal namespace afterwards; publishing under heavy-duty needs an org-member token (401 reqPackageAccess with this restricted account). Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
104 lines
3.7 KiB
Bash
Executable file
104 lines
3.7 KiB
Bash
Executable file
#!/usr/bin/env bash
|
|
#
|
|
# Build a Debian package for stoke.
|
|
#
|
|
# Usage: scripts/build-deb.sh
|
|
#
|
|
# Produces dist/stoke_<version>_all.deb from a clean staging copy of the
|
|
# working tree (only src/, package.json and package-lock.json are shipped;
|
|
# production dependencies are installed fresh with `npm ci --omit=dev`).
|
|
#
|
|
# Requirements: bash, node/npm, dpkg-deb, gzip. Runs lintian when available.
|
|
|
|
set -euo pipefail
|
|
|
|
ROOT="$(cd "$(dirname "${BASH_SOURCE[0]}")/.." && pwd)"
|
|
VERSION="$(node -p "require('$ROOT/package.json').version")"
|
|
MAINTAINER="${DEB_MAINTAINER:-Heavy Duty Builders <equipo@lafamilia.so>}"
|
|
HOMEPAGE="https://forgejo.heavyduty.builders/heavy-duty/stoke"
|
|
|
|
STAGE="$(mktemp -d)"
|
|
trap 'rm -rf "$STAGE"' EXIT
|
|
|
|
PKG="$STAGE/stoke_${VERSION}_all"
|
|
LIB="$PKG/usr/lib/stoke"
|
|
DOC="$PKG/usr/share/doc/stoke"
|
|
|
|
install -d "$PKG/DEBIAN" "$LIB" "$PKG/usr/bin" "$DOC"
|
|
|
|
# --- payload -----------------------------------------------------------------
|
|
cp -r "$ROOT/src" "$LIB/src"
|
|
cp "$ROOT/package.json" "$ROOT/package-lock.json" "$LIB/"
|
|
(cd "$LIB" && npm ci --omit=dev --silent --no-audit --no-fund)
|
|
|
|
# Launcher: the CLI has a `#!/usr/bin/env node` shebang and resolves its
|
|
# node_modules relative to its real path, so a symlink is all we need.
|
|
ln -s ../lib/stoke/src/cli.js "$PKG/usr/bin/stoke"
|
|
|
|
# --- docs (lintian: copyright + Debian changelog) ----------------------------
|
|
cat > "$DOC/copyright" <<EOF
|
|
Format: https://www.debian.org/doc/packaging-manuals/copyright-format/1.0/
|
|
Upstream-Name: stoke
|
|
Source: $HOMEPAGE
|
|
|
|
Files: *
|
|
Copyright: $(date +%Y) Heavy Duty Builders
|
|
License: ISC
|
|
Permission to use, copy, modify, and/or distribute this software for any
|
|
purpose with or without fee is hereby granted, provided that the above
|
|
copyright notice and this permission notice appear in all copies.
|
|
.
|
|
THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES
|
|
WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF
|
|
MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR
|
|
ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES
|
|
WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN
|
|
ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF
|
|
OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
|
|
EOF
|
|
|
|
cat > "$STAGE/changelog" <<EOF
|
|
stoke ($VERSION) stable; urgency=medium
|
|
|
|
* See the repository release page for notes.
|
|
|
|
-- $MAINTAINER $(date -R)
|
|
EOF
|
|
# Native package (no Debian revision in the version), so plain changelog.gz.
|
|
gzip -9n -c "$STAGE/changelog" > "$DOC/changelog.gz"
|
|
|
|
# Normalize permissions regardless of the builder's umask: no group/other
|
|
# write anywhere, executable entry point.
|
|
chmod -R go-w "$PKG/usr"
|
|
chmod 0755 "$LIB/src/cli.js"
|
|
|
|
# --- control -----------------------------------------------------------------
|
|
INSTALLED_SIZE="$(du -sk --exclude=DEBIAN "$PKG" | cut -f1)"
|
|
cat > "$PKG/DEBIAN/control" <<EOF
|
|
Package: stoke
|
|
Version: $VERSION
|
|
Section: utils
|
|
Priority: optional
|
|
Architecture: all
|
|
Depends: nodejs (>= 22.12)
|
|
Installed-Size: $INSTALLED_SIZE
|
|
Maintainer: $MAINTAINER
|
|
Homepage: $HOMEPAGE
|
|
Description: CLI for the heavy-duty forge (Forgejo)
|
|
stoke manages the Forgejo instance at forgejo.heavyduty.builders from the
|
|
command line: authentication, repositories, issues, pull requests,
|
|
branches, collaborators, organizations, teams and users.
|
|
EOF
|
|
|
|
# --- build -------------------------------------------------------------------
|
|
mkdir -p "$ROOT/dist"
|
|
dpkg-deb --build --root-owner-group "$PKG" "$ROOT/dist/" >/dev/null
|
|
DEB="$ROOT/dist/stoke_${VERSION}_all.deb"
|
|
echo "Built: $DEB"
|
|
|
|
if command -v lintian >/dev/null 2>&1; then
|
|
# binary-without-manpage is a known, accepted gap for now.
|
|
lintian --suppress-tags binary-without-manpage "$DEB" || true
|
|
else
|
|
echo "Note: lintian not installed; skipping package lint."
|
|
fi
|