Skip to content

Commit 790e448

Browse files
committed
macosx pkg CI
1 parent d3b1633 commit 790e448

7 files changed

Lines changed: 141 additions & 0 deletions

File tree

.github/macosx.sh

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
bash extras/build_macos_pkg.sh
2+
3+
echo pushing kcli.pkg
4+
pip install --break-system-packages cloudsmith-cli
5+
cloudsmith push raw karmab/kcli kcli.pkg
Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,21 @@
1+
name: SNAPSHOT-MACOSX-DAILY
2+
on:
3+
schedule:
4+
- cron: '39 20 * * 0'
5+
6+
env:
7+
CLOUDSMITH_API_KEY: ${{ secrets.CLOUDSMITH_API_KEY }}
8+
PYTHONUNBUFFERED: true
9+
10+
jobs:
11+
12+
run-workflow:
13+
name: Workflow
14+
runs-on: macos-26
15+
steps:
16+
- name: Checkout Repo
17+
uses: actions/checkout@v2
18+
- if: github.ref == 'refs/heads/main' && github.repository_owner == 'karmab'
19+
name: Create MACOSX pkg
20+
run: |
21+
.github/macosx.sh

.github/workflows/macosx.yml

Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,21 @@
1+
name: MACOSX-PKG
2+
3+
on:
4+
workflow_dispatch:
5+
6+
env:
7+
CLOUDSMITH_API_KEY: ${{ secrets.CLOUDSMITH_API_KEY }}
8+
PYTHONUNBUFFERED: true
9+
10+
jobs:
11+
12+
run-workflow:
13+
name: Workflow
14+
runs-on: macos-26
15+
steps:
16+
- name: Checkout Repo
17+
uses: actions/checkout@v2
18+
- if: github.ref == 'refs/heads/main' && github.repository_owner == 'karmab'
19+
name: Create MACOSX pkg
20+
run: |
21+
.github/macosx.sh

.gitignore

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -18,3 +18,4 @@ kvirt/static/reports/*
1818
venv*
1919
.idea
2020
openshift_pull.json
21+
*.pkg

extras/build_macos_pkg.sh

Lines changed: 67 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,67 @@
1+
#!/bin/bash
2+
set -e
3+
4+
RED='\033[0;31m'
5+
GREEN='\033[0;32m'
6+
BLUE='\033[0;36m'
7+
NC='\033[0m'
8+
9+
SCRIPT_DIR="$(cd "$(dirname "$0")" && pwd)"
10+
REPO_DIR="$(cd "$SCRIPT_DIR/.." && pwd)"
11+
MACOS_DIR="$SCRIPT_DIR/macos"
12+
VERSION="${GIT_CUSTOM_VERSION:-99.0.$(date +%Y%m%d%H%M).$(git -C "$REPO_DIR" rev-parse --short HEAD | python3 -c "import sys; print(int(sys.stdin.read().strip(), 16))")}"
13+
STAGING=$(mktemp -d)
14+
INSTALL_DIR="$STAGING/usr/local/kcli"
15+
BIN_DIR="$STAGING/usr/local/bin"
16+
17+
trap "rm -rf $STAGING" EXIT
18+
19+
echo -e "${BLUE}Building kcli macOS package...${NC}"
20+
21+
if [ "$(uname -s)" != "Darwin" ]; then
22+
echo -e "${RED}This script must be run on macOS${NC}"
23+
exit 1
24+
fi
25+
26+
if ! which python3 >/dev/null 2>&1; then
27+
echo -e "${RED}python3 not found. Install Xcode Command Line Tools: xcode-select --install${NC}"
28+
exit 1
29+
fi
30+
31+
echo -e "${BLUE}Creating virtualenv...${NC}"
32+
python3 -m venv "$INSTALL_DIR"
33+
34+
echo -e "${BLUE}Installing kcli...${NC}"
35+
SRC_DIR="$STAGING/src"
36+
cp -a "$REPO_DIR" "$SRC_DIR"
37+
/usr/bin/sed -i "" "s/, 'libvirt-python>=2.0.0'//" "${SRC_DIR}/setup.py"
38+
"$INSTALL_DIR/bin/pip" install --no-cache-dir "$SRC_DIR" 2>&1 | tail -1
39+
rm -rf "$SRC_DIR"
40+
41+
mkdir -p "$BIN_DIR"
42+
cat > "$BIN_DIR/kcli" << 'WRAPPER'
43+
#!/bin/bash
44+
exec /usr/local/kcli/bin/kcli "$@"
45+
WRAPPER
46+
chmod +x "$BIN_DIR/kcli"
47+
48+
echo -e "${BLUE}Building .pkg...${NC}"
49+
CORE_PKG="$STAGING/kcli-core.pkg"
50+
pkgbuild --root "$STAGING" \
51+
--identifier com.karmab.kcli \
52+
--version "$VERSION" \
53+
--install-location / \
54+
"$CORE_PKG"
55+
56+
RESOURCES="$STAGING/resources"
57+
mkdir -p "$RESOURCES"
58+
sed "s/@@VERSION@@/$VERSION/" "$MACOS_DIR/resources/welcome.html" > "$RESOURCES/welcome.html"
59+
cp "$REPO_DIR/kcli.png" "$RESOURCES/background.png"
60+
61+
productbuild --distribution "$MACOS_DIR/Distribution" \
62+
--resources "$RESOURCES" \
63+
--package-path "$STAGING" \
64+
"$REPO_DIR/kcli.pkg"
65+
66+
echo -e "${GREEN}Built kcli.pkg${NC}"
67+
echo -e "${BLUE}Install with: open kcli.pkg${NC}"

extras/macos/Distribution

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,18 @@
1+
<?xml version="1.0" encoding="utf-8"?>
2+
<installer-gui-script minSpecVersion="2">
3+
<title>kcli</title>
4+
<background file="background.png" alignment="bottomleft" scaling="proportional"/>
5+
<welcome file="welcome.html"/>
6+
<options customize="never" require-scripts="false"/>
7+
<domains enable_localSystem="true"/>
8+
<choices-outline>
9+
<line choice="default">
10+
<line choice="com.karmab.kcli"/>
11+
</line>
12+
</choices-outline>
13+
<choice id="default"/>
14+
<choice id="com.karmab.kcli" visible="false">
15+
<pkg-ref id="com.karmab.kcli"/>
16+
</choice>
17+
<pkg-ref id="com.karmab.kcli" version="99.0" onConclusion="none">kcli-core.pkg</pkg-ref>
18+
</installer-gui-script>
Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
<html>
2+
<body>
3+
<h2>kcli @@VERSION@@</h2>
4+
<p>This package installs <b>kcli</b>, a tool for managing virtual machines across multiple providers including UTM, Libvirt, AWS, GCP, Azure, Kubevirt, and more.</p>
5+
<p>On macOS, kcli works with <b>UTM</b> to create and manage local virtual machines. Make sure UTM is installed from <a href="https://mac.getutm.app">mac.getutm.app</a>.</p>
6+
<p>After installation, run <code>kcli</code> from any terminal.</p>
7+
</body>
8+
</html>

0 commit comments

Comments
 (0)