-
Notifications
You must be signed in to change notification settings - Fork 2
feat: single-command production installer + versioned releases #25
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Merged
Merged
Changes from all commits
Commits
Show all changes
4 commits
Select commit
Hold shift + click to select a range
81d2461
feat: single-command production installer with versioned releases
chr1syy 4ab505c
fix(install): address review feedback on installer and control script
chr1syy b1dc1c9
fix(install): second-round review fixes
chr1syy b6e082a
fix(install): preserve legacy .env and enable headless slash deploy
chr1syy File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,66 @@ | ||
| name: Release | ||
|
|
||
| on: | ||
| push: | ||
| tags: | ||
| - 'v*' | ||
|
|
||
| permissions: | ||
| contents: write | ||
|
|
||
| jobs: | ||
| release: | ||
| runs-on: ubuntu-latest | ||
| steps: | ||
| - uses: actions/checkout@v6 | ||
| with: | ||
| fetch-depth: 0 | ||
|
|
||
| - uses: actions/setup-node@v6 | ||
| with: | ||
| node-version: '22' | ||
| cache: 'npm' | ||
|
|
||
| - name: Install dependencies | ||
| run: npm ci | ||
|
|
||
| - name: Verify tag matches package.json version | ||
| run: | | ||
| tag="${GITHUB_REF#refs/tags/v}" | ||
| pkg="$(node -p 'require("./package.json").version')" | ||
| if [ "$tag" != "$pkg" ]; then | ||
| echo "Tag v$tag does not match package.json version $pkg" >&2 | ||
| exit 1 | ||
| fi | ||
|
|
||
| - name: Lint and type-check | ||
| run: npx tsc --noEmit | ||
|
|
||
| - name: Test | ||
| run: npm test | ||
|
|
||
| - name: Build | ||
| run: npm run build | ||
|
|
||
| - name: Package release tarball | ||
| id: package | ||
| run: | | ||
| tag="${GITHUB_REF#refs/tags/}" | ||
| staging="maestro-discord-${tag}" | ||
| mkdir -p "$staging" | ||
| cp -R dist "$staging/" | ||
| cp -R bin templates "$staging/" | ||
| cp package.json package-lock.json .env.example README.md "$staging/" | ||
| cp LICENSE "$staging/" 2>/dev/null || true | ||
| tar -czf "${staging}.tar.gz" "$staging" | ||
| sha256sum "${staging}.tar.gz" > "${staging}.tar.gz.sha256" | ||
| echo "tarball=${staging}.tar.gz" >> "$GITHUB_OUTPUT" | ||
| echo "checksum=${staging}.tar.gz.sha256" >> "$GITHUB_OUTPUT" | ||
|
|
||
| - name: Create GitHub Release | ||
| uses: softprops/action-gh-release@v2 | ||
| with: | ||
| generate_release_notes: true | ||
| files: | | ||
| ${{ steps.package.outputs.tarball }} | ||
| ${{ steps.package.outputs.checksum }} |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,177 @@ | ||
| #!/usr/bin/env bash | ||
| # Service wrapper for the Maestro Discord bot. | ||
| # Subcommands: start | stop | restart | status | logs | deploy | update | uninstall | version | ||
|
|
||
| set -euo pipefail | ||
|
|
||
| INSTALL_DIR="${MAESTRO_DISCORD_HOME:-$HOME/.local/share/maestro-discord}" | ||
| CONFIG_DIR="${XDG_CONFIG_HOME:-$HOME/.config}/maestro-discord" | ||
| BIN_DIR="${MAESTRO_DISCORD_BIN_DIR:-$HOME/.local/bin}" | ||
| REPO="${MAESTRO_DISCORD_REPO:-RunMaestro/Maestro-Discord}" | ||
| SERVICE_NAME="maestro-discord" | ||
| LAUNCHD_LABEL="sh.maestro.discord" | ||
| LAUNCHD_PLIST="$HOME/Library/LaunchAgents/${LAUNCHD_LABEL}.plist" | ||
|
|
||
| die() { printf '✗ %s\n' "$*" >&2; exit 1; } | ||
| info() { printf '==> %s\n' "$*"; } | ||
|
|
||
| detect_os() { | ||
| case "$(uname -s)" in | ||
| Linux) echo linux ;; | ||
| Darwin) echo macos ;; | ||
| *) echo unsupported ;; | ||
| esac | ||
| } | ||
|
|
||
| usage() { | ||
| cat <<'EOF' | ||
| maestro-discord-ctl — control the Maestro Discord bot service. | ||
|
|
||
| Usage: | ||
| maestro-discord-ctl <command> | ||
|
|
||
| Commands: | ||
| start Start the bot service | ||
| stop Stop the bot service | ||
| restart Restart the bot service | ||
| status Show service status | ||
| logs Tail service logs (Ctrl+C to stop) | ||
| deploy Deploy slash commands to Discord | ||
| update Reinstall the latest release (preserves config) | ||
| uninstall Remove the bot, service files, and CLI symlink | ||
| version Print installed version | ||
|
|
||
| Environment: | ||
| MAESTRO_DISCORD_HOME Override install dir (default: ~/.local/share/maestro-discord) | ||
| XDG_CONFIG_HOME Config dir parent (default: ~/.config) | ||
| EOF | ||
| } | ||
|
|
||
| require_install() { | ||
| [ -d "$INSTALL_DIR" ] || die "Not installed at $INSTALL_DIR. Run install.sh first." | ||
| } | ||
|
|
||
| cmd_start() { | ||
| require_install | ||
| case "$(detect_os)" in | ||
| linux) | ||
| systemctl --user start "$SERVICE_NAME" | ||
| info "Started $SERVICE_NAME (systemd user)" | ||
| ;; | ||
| macos) | ||
| [ -f "$LAUNCHD_PLIST" ] || die "Plist not installed: $LAUNCHD_PLIST" | ||
| launchctl load -w "$LAUNCHD_PLIST" 2>/dev/null || launchctl start "$LAUNCHD_LABEL" | ||
| info "Started $LAUNCHD_LABEL (launchd)" | ||
| ;; | ||
| *) die "Unsupported OS for service management" ;; | ||
| esac | ||
| } | ||
|
|
||
| cmd_stop() { | ||
| case "$(detect_os)" in | ||
| linux) | ||
| systemctl --user stop "$SERVICE_NAME" || true | ||
| info "Stopped $SERVICE_NAME" | ||
| ;; | ||
| macos) | ||
| launchctl unload -w "$LAUNCHD_PLIST" 2>/dev/null || launchctl stop "$LAUNCHD_LABEL" || true | ||
| info "Stopped $LAUNCHD_LABEL" | ||
| ;; | ||
| *) die "Unsupported OS for service management" ;; | ||
| esac | ||
| } | ||
|
|
||
| cmd_restart() { | ||
| cmd_stop || true | ||
| cmd_start | ||
| } | ||
|
|
||
| cmd_status() { | ||
| case "$(detect_os)" in | ||
| linux) systemctl --user status "$SERVICE_NAME" --no-pager || true ;; | ||
| macos) launchctl list | grep -F "$LAUNCHD_LABEL" || echo "(not loaded)" ;; | ||
| *) die "Unsupported OS for service management" ;; | ||
| esac | ||
| } | ||
|
|
||
| cmd_logs() { | ||
| case "$(detect_os)" in | ||
| linux) journalctl --user -u "$SERVICE_NAME" -f --no-pager ;; | ||
| macos) | ||
| local log_file="$INSTALL_DIR/logs/maestro-discord.log" | ||
| mkdir -p "$INSTALL_DIR/logs" | ||
| [ -f "$log_file" ] || touch "$log_file" | ||
| tail -f "$log_file" | ||
| ;; | ||
| *) die "Unsupported OS for log tailing" ;; | ||
| esac | ||
| } | ||
|
coderabbitai[bot] marked this conversation as resolved.
|
||
|
|
||
| cmd_deploy() { | ||
| require_install | ||
| [ -f "$INSTALL_DIR/.env" ] || die "Config missing: $INSTALL_DIR/.env" | ||
| (cd "$INSTALL_DIR" && node dist/deploy-commands.js) | ||
| } | ||
|
|
||
| cmd_update() { | ||
| info "Re-running installer to pull the latest release" | ||
| local tag config_parent | ||
| tag="$(curl -fsSL "https://api.github.com/repos/${REPO}/releases/latest" | sed -nE 's/.*"tag_name"[[:space:]]*:[[:space:]]*"([^"]+)".*/\1/p' | head -n1)" | ||
| [ -n "$tag" ] || die "Could not resolve latest release tag" | ||
| config_parent="${CONFIG_DIR%/maestro-discord}" | ||
| curl -fsSL "https://raw.githubusercontent.com/${REPO}/${tag}/install.sh" \ | ||
| | env \ | ||
| MAESTRO_DISCORD_HOME="$INSTALL_DIR" \ | ||
| MAESTRO_DISCORD_BIN_DIR="$BIN_DIR" \ | ||
| MAESTRO_DISCORD_REPO="$REPO" \ | ||
| XDG_CONFIG_HOME="$config_parent" \ | ||
| bash | ||
| } | ||
|
coderabbitai[bot] marked this conversation as resolved.
|
||
|
|
||
| cmd_uninstall() { | ||
| read -r -p "Remove $INSTALL_DIR, service files, and CLI symlink? [y/N] " ans | ||
| case "${ans:-n}" in | ||
| y|Y|yes|YES) ;; | ||
| *) info "Aborted"; exit 0 ;; | ||
| esac | ||
| cmd_stop || true | ||
| case "$(detect_os)" in | ||
| linux) | ||
| systemctl --user disable --now "$SERVICE_NAME" 2>/dev/null || true | ||
| rm -f "${XDG_CONFIG_HOME:-$HOME/.config}/systemd/user/${SERVICE_NAME}.service" | ||
| systemctl --user daemon-reload || true | ||
| systemctl --user reset-failed "$SERVICE_NAME" 2>/dev/null || true | ||
| ;; | ||
|
coderabbitai[bot] marked this conversation as resolved.
|
||
| macos) rm -f "$LAUNCHD_PLIST" ;; | ||
| esac | ||
| rm -rf "$INSTALL_DIR" | ||
| rm -f "$BIN_DIR/maestro-discord-ctl" | ||
| info "Uninstalled. Config preserved at $CONFIG_DIR (delete manually if desired)." | ||
| } | ||
|
|
||
| cmd_version() { | ||
| if [ -f "$INSTALL_DIR/.version" ]; then | ||
| cat "$INSTALL_DIR/.version" | ||
| else | ||
| die "No version file at $INSTALL_DIR/.version" | ||
| fi | ||
| } | ||
|
|
||
| main() { | ||
| local sub="${1:-}" | ||
| case "$sub" in | ||
| start) cmd_start ;; | ||
| stop) cmd_stop ;; | ||
| restart) cmd_restart ;; | ||
| status) cmd_status ;; | ||
| logs) cmd_logs ;; | ||
| deploy) cmd_deploy ;; | ||
| update) cmd_update ;; | ||
| uninstall) cmd_uninstall ;; | ||
| version) cmd_version ;; | ||
| -h|--help|help|"") usage ;; | ||
| *) usage; exit 2 ;; | ||
| esac | ||
| } | ||
|
|
||
| main "$@" | ||
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.