Skip to content

Commit 96cf0f2

Browse files
authored
chore: added shell installer (#525)
This pull request introduces a new shell installer for MACH Composer, improving the installation process and updating the documentation accordingly. The key changes include the addition of the shell script, updates to the `README.md` file to reflect the new installation method, and a changelog entry documenting the update. ### Shell Installer Addition: * Added a new shell script, `scripts/install-mach-composer.sh`, to simplify the installation process. The script automatically detects the operating system and architecture, downloads the appropriate binary, and installs it to `$HOME/.local/bin`. It also provides support for specifying a version via the `VERSION` environment variable. ### Documentation Updates: * Updated the `README.md` file to include a new "Shell script" section under installation methods. This section provides instructions for using the shell installer, including commands for installing the latest version or a specific version. Adjustments were also made to clarify other installation methods. ### Changelog Update: * Added an entry to the changelog (`.changes/unreleased/Fixed-20250704-115212.yaml`) documenting the addition of the shell installer for ease of use.
2 parents ea09d38 + da34e07 commit 96cf0f2

File tree

3 files changed

+98
-2
lines changed

3 files changed

+98
-2
lines changed
Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
kind: Fixed
2+
body: Added shell installer for ease of use
3+
time: 2025-07-04T11:52:12.397309325+02:00

README.md

Lines changed: 18 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -34,14 +34,30 @@ organisation.
3434

3535
## Installation
3636

37-
### MacOS
37+
### Shell script
38+
39+
Run the following command to install MACH composer on your system. The script will download the latest release of MACH composer and install it in your
40+
`$HOME/bin` directory. Make sure that this directory is in your `$PATH`.
41+
42+
```
43+
$ curl -sfL https://raw.githubusercontent.com/mach-composer/mach-composer-cli/f08424b1bc38086696767a1ce05e1b0fbb199326/scripts/install-mach-composer.sh | bash
44+
```
45+
46+
If you want to install a specific version, you can specify the `VERSION` environment variable:
47+
48+
```
49+
$ export VERSION=v2.20.0
50+
$ curl -sfL https://raw.githubusercontent.com/mach-composer/mach-composer-cli/blob/main/scripts/install-mach-composer.sh | bash
51+
```
52+
53+
### Brew
3854

3955
```bash
4056
brew tap mach-composer/mach-composer
4157
brew install mach-composer
4258
```
4359

44-
### Windows
60+
### Chocolatey (Windows)
4561

4662
Windows installation through Chocolatery is currently unstable. We recommend to [download the latest release from GitHub
4763
Releases](https://github.com/mach-composer/mach-composer-cli/releases/latest). Also, it is recommended to run MACH composer through [WSL](https://learn.microsoft.com/en-us/windows/wsl/install).

scripts/install-mach-composer.sh

Lines changed: 77 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,77 @@
1+
#!/usr/bin/env bash
2+
3+
if ! (set -o pipefail 2>/dev/null); then
4+
echo "❌ This script requires bash. Please run it with: bash $0"
5+
exit 1
6+
fi
7+
8+
set -euo pipefail
9+
10+
# Optional version from environment variable (default to latest from GitHub)
11+
VERSION="${VERSION:-$(curl -s https://api.github.com/repos/mach-composer/mach-composer-cli/releases/latest | jq -r .tag_name)}"
12+
VERSION_NO_V="${VERSION#v}"
13+
14+
# Detect OS
15+
OS="$(uname -s | tr '[:upper:]' '[:lower:]')"
16+
case "$OS" in
17+
linux|darwin|freebsd) ;;
18+
msys*|mingw*|cygwin*) OS="windows" ;;
19+
*)
20+
echo "❌ Unsupported OS: $OS"
21+
exit 1
22+
;;
23+
esac
24+
25+
# Detect architecture
26+
ARCH="$(uname -m)"
27+
case "$ARCH" in
28+
x86_64|amd64) ARCH="amd64" ;;
29+
aarch64|arm64) ARCH="arm64" ;;
30+
armv6l) ARCH="armv6" ;;
31+
*)
32+
echo "❌ Unsupported architecture: $ARCH"
33+
exit 1
34+
;;
35+
esac
36+
37+
# Determine file extension
38+
EXT="tar.gz"
39+
[[ "$OS" == "windows" ]] && EXT="zip"
40+
41+
FILENAME="mach-composer-${VERSION_NO_V}-${OS}-${ARCH}.${EXT}"
42+
URL="https://github.com/mach-composer/mach-composer-cli/releases/download/${VERSION}/${FILENAME}"
43+
44+
# Setup directories
45+
TARGET_DIR="$HOME/.local/bin"
46+
mkdir -p "$TARGET_DIR"
47+
48+
TMP_DIR="$(mktemp -d)"
49+
trap 'rm -rf "$TMP_DIR"' EXIT
50+
51+
echo "⬇️ Downloading $FILENAME..."
52+
curl -sL "$URL" -o "$TMP_DIR/$FILENAME"
53+
54+
echo "📦 Extracting $FILENAME..."
55+
if [[ "$EXT" == "zip" ]]; then
56+
unzip -q "$TMP_DIR/$FILENAME" -d "$TMP_DIR"
57+
else
58+
tar -xzf "$TMP_DIR/$FILENAME" -C "$TMP_DIR"
59+
fi
60+
61+
# Move binary from bin/ to target dir
62+
BIN_PATH="$TMP_DIR/bin/mach-composer"
63+
if [[ ! -f "$BIN_PATH" ]]; then
64+
echo "❌ Binary not found at expected path: $BIN_PATH"
65+
exit 1
66+
fi
67+
68+
mv "$BIN_PATH" "$TARGET_DIR/mach-composer"
69+
chmod +x "$TARGET_DIR/mach-composer"
70+
71+
echo "✅ mach-composer $VERSION installed to $TARGET_DIR"
72+
73+
# Warn if not in PATH
74+
if ! echo "$PATH" | grep -q "$HOME/.local/bin"; then
75+
echo "⚠️ $HOME/.local/bin is not in your PATH. You can add this to your shell config:"
76+
echo 'export PATH="$HOME/.local/bin:$PATH"'
77+
fi

0 commit comments

Comments
 (0)