Skip to content

Commit 8463f3e

Browse files
committed
Add build scripts for Linux, Snap, and improve PyPi
* feat: Introduced new build scripts for Linux and Snap packages * build: Updated the main build script to call new Linux and Snap build scripts * fix: Corrected the output path in PyPi build script for clarity * chore: Added snapcraft.yaml for Snap package configuration
1 parent 8bc5fc9 commit 8463f3e

File tree

5 files changed

+99
-2
lines changed

5 files changed

+99
-2
lines changed

build/build.sh

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,9 @@ printf "Building GIV CLI version %s...\n" "${VERSION}"
99

1010
./build/npm/build.sh "${VERSION}" "${BUILD_TEMP}"
1111
./build/pypi/build.sh "${VERSION}" "${BUILD_TEMP}"
12+
./build/snap/build.sh "${VERSION}" "${BUILD_TEMP}"
13+
./build/linux.sh "${VERSION}" "${BUILD_TEMP}" "deb"
14+
./build/linux.sh "${VERSION}" "${BUILD_TEMP}" "rpm"
1215

1316
rm -rf "${BUILD_TEMP}"
14-
printf "Build completed. Files are in %s\n" "${DIST_DIR}/pypi"
17+
printf "Build completed. Files are in %s\n" "${DIST_DIR}"

build/linux.sh

Lines changed: 43 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,43 @@
1+
#!/usr/bin/env bash
2+
set -euo pipefail
3+
4+
VERSION="$1"
5+
BUILD_TEMP="$2"
6+
TARGET="${3:-deb}" # deb or rpm
7+
8+
PKG_ROOT="$BUILD_TEMP/${TARGET}_pkgroot"
9+
BIN_DIR="$PKG_ROOT/usr/local/bin"
10+
LIB_DIR="$PKG_ROOT/usr/local/lib/giv"
11+
SHARE_TEMPLATES_DIR="$PKG_ROOT/usr/local/share/giv/templates"
12+
13+
# Clean and prepare dirs
14+
rm -rf "$PKG_ROOT"
15+
mkdir -p "$BIN_DIR" "$LIB_DIR" "$SHARE_TEMPLATES_DIR"
16+
17+
# Install main script
18+
cp src/giv.sh "$BIN_DIR/giv"
19+
chmod +x "$BIN_DIR/giv"
20+
21+
# Copy supporting scripts
22+
find src -type f -name '*.sh' ! -name 'giv.sh' -exec cp {} "$LIB_DIR/" \;
23+
24+
# Copy templates
25+
cp -r templates/* "$SHARE_TEMPLATES_DIR/"
26+
27+
# fpm build
28+
PKG_NAME="giv"
29+
DESC="Image and vector viewer CLI"
30+
MAINTAINER="itlackey <noreply@github.com>"
31+
32+
OUT_DIR="./dist/${VERSION}/${TARGET}"
33+
mkdir -p "$OUT_DIR"
34+
fpm -s dir -t "$TARGET" \
35+
-n "$PKG_NAME" \
36+
-v "$VERSION" \
37+
--description "$DESC" \
38+
--maintainer "$MAINTAINER" \
39+
--prefix=/ \
40+
-C "$PKG_ROOT" \
41+
-p "$OUT_DIR/${PKG_NAME}_VERSION_ARCH.$TARGET"
42+
43+
printf "%s build completed. Files are in %s\n" "$TARGET" "$OUT_DIR"

build/pypi/build.sh

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -40,4 +40,4 @@ rm -rf "${PIP_DIST_DIR}/pypi"
4040
mv -f "${PIP_BUILD_TEMP}" "${PIP_DIST_DIR}/"
4141

4242

43-
printf "PyPi build completed. Files are in %s\n" "${PIP_DIST_DIR}"
43+
printf "PyPi build completed. Files are in %s\n" "${PIP_DIST_DIR}/pypi"

build/snap/build.sh

Lines changed: 29 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,29 @@
1+
#!/usr/bin/env bash
2+
set -euo pipefail
3+
4+
VERSION="$1"
5+
SNAP_BUILD_TEMP="$2/snap"
6+
SNAP_DIST_DIR="./dist/${VERSION}/snap"
7+
8+
# Prepare build directory
9+
rm -rf "$SNAP_BUILD_TEMP"
10+
mkdir -p "$SNAP_BUILD_TEMP"/src "$SNAP_BUILD_TEMP"/templates
11+
12+
# Copy and rename entry script
13+
cp src/giv.sh "$SNAP_BUILD_TEMP/src/giv"
14+
chmod +x "$SNAP_BUILD_TEMP/src/giv"
15+
# Copy helper libs
16+
find src -type f -name '*.sh' ! -name 'giv.sh' -exec cp {} "$SNAP_BUILD_TEMP/src/" \;
17+
# Copy templates
18+
cp -r templates/* "$SNAP_BUILD_TEMP/templates/"
19+
20+
# Fill in version in snapcraft.yaml template
21+
sed "s/{{VERSION}}/${VERSION}/g" build/snap/snapcraft.yaml > "$SNAP_BUILD_TEMP/snapcraft.yaml"
22+
23+
# Move to dist
24+
mkdir -p "${SNAP_DIST_DIR}"
25+
rm -rf "${SNAP_DIST_DIR:?}/"*
26+
mv "$SNAP_BUILD_TEMP"/* "${SNAP_DIST_DIR}/"
27+
28+
printf "Snap build completed. Files are in %s\n" "${SNAP_DIST_DIR}"
29+
printf "To build the snap, run:\n cd %s && snapcraft\n" "${SNAP_DIST_DIR}"

build/snap/snapcraft.yaml

Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,22 @@
1+
name: giv
2+
version: "{{VERSION}}"
3+
summary: Git history AI assistant CLI tool
4+
description: |
5+
giv is a CLI utility for generating changelogs and summaries.
6+
grade: stable
7+
confinement: strict
8+
base: core22
9+
10+
apps:
11+
giv:
12+
command: bin/giv
13+
plugs: [home, network]
14+
15+
parts:
16+
giv:
17+
plugin: dump
18+
source: .
19+
organize:
20+
src/giv: bin/giv
21+
src/*: lib/giv/
22+
templates/*: share/giv/templates/

0 commit comments

Comments
 (0)