Skip to content

Commit f52fc22

Browse files
committed
Add build support for PyPI, NPM, Homebrew, Scoop
1 parent 8463f3e commit f52fc22

File tree

16 files changed

+217
-37
lines changed

16 files changed

+217
-37
lines changed

.gitignore

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -6,5 +6,5 @@ history.md
66
.test-logs
77
tests/.logs
88
tests/.tmp
9-
bashdb-5.0-1.1.2
10-
changes.0.2.0.sh
9+
.tmp
10+
dist

build/build.sh

Lines changed: 12 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -6,12 +6,19 @@ VERSION=$(sed -n 's/^__VERSION="\([^"]*\)"/\1/p' ../giv/src/giv.sh)
66
DIST_DIR="./dist/${VERSION}"
77

88
printf "Building GIV CLI version %s...\n" "${VERSION}"
9-
9+
mkdir -p "${BUILD_TEMP}/package"
10+
cp -r src templates docs "${BUILD_TEMP}/package/"
11+
cp README.md "${BUILD_TEMP}/package/"
12+
mv "${BUILD_TEMP}/package/src/giv.sh" "${BUILD_TEMP}/package/src/giv"
13+
printf "Using build temp directory: %s\n" "${BUILD_TEMP}"
1014
./build/npm/build.sh "${VERSION}" "${BUILD_TEMP}"
1115
./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"
16+
# ./build/snap/build.sh "${VERSION}" "${BUILD_TEMP}"
17+
# ./build/linux/build.sh "${VERSION}" "${BUILD_TEMP}" "deb"
18+
# ./build/linux/build.sh "${VERSION}" "${BUILD_TEMP}" "rpm"
19+
# ./build/flatpak/build.sh "${VERSION}" "${BUILD_TEMP}"
20+
# ./build/homebrew/build.sh "${VERSION}" "${BUILD_TEMP}"
21+
#./build/scoop/build.sh "${VERSION}" "${BUILD_TEMP}"
1522

16-
rm -rf "${BUILD_TEMP}"
23+
#rm -rf "${BUILD_TEMP}"
1724
printf "Build completed. Files are in %s\n" "${DIST_DIR}"

build/flatpak/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+
FLATPAK_BUILD_TEMP="$2/flatpak"
6+
FLATPAK_DIST_DIR="./dist/${VERSION}/flatpak"
7+
8+
# Prepare staging dir
9+
rm -rf "$FLATPAK_BUILD_TEMP"
10+
mkdir -p "$FLATPAK_BUILD_TEMP/src" "$FLATPAK_BUILD_TEMP/templates"
11+
12+
# Copy and rename main script
13+
cp src/giv.sh "$FLATPAK_BUILD_TEMP/src/giv"
14+
chmod +x "$FLATPAK_BUILD_TEMP/src/giv"
15+
# Copy libraries
16+
find src -type f -name '*.sh' ! -name 'giv.sh' -exec cp {} "$FLATPAK_BUILD_TEMP/src/" \;
17+
# Copy templates
18+
cp -r templates/* "$FLATPAK_BUILD_TEMP/templates/"
19+
20+
# Copy and substitute version in manifest
21+
sed "s/{{VERSION}}/${VERSION}/g" build/flatpak/flatpak.json > "$FLATPAK_BUILD_TEMP/flatpak.json"
22+
23+
# Move to dist dir
24+
mkdir -p "${FLATPAK_DIST_DIR}"
25+
rm -rf "${FLATPAK_DIST_DIR:?}/"*
26+
mv "$FLATPAK_BUILD_TEMP"/* "${FLATPAK_DIST_DIR}/"
27+
28+
printf "Flatpak build completed. Files are in %s\n" "${FLATPAK_DIST_DIR}"
29+
printf "To build the flatpak, run:\n flatpak-builder build-dir flatpak.json --force-clean\n"

build/flatpak/flatpak.json

Lines changed: 30 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,30 @@
1+
{
2+
"app-id": "com.github.giv-cli.giv",
3+
"runtime": "org.freedesktop.Platform",
4+
"runtime-version": "23.08",
5+
"sdk": "org.freedesktop.Sdk",
6+
"command": "giv",
7+
"modules": [
8+
{
9+
"name": "giv",
10+
"buildsystem": "simple",
11+
"build-commands": [
12+
"install -D src/giv /app/bin/giv",
13+
"install -Dm644 src/*.sh /app/lib/giv/",
14+
"install -Dm644 templates/* /app/share/giv/templates/"
15+
],
16+
"sources": [
17+
{ "type": "file", "path": "src/giv" },
18+
{ "type": "file", "path": "src/helpers.sh" },
19+
{ "type": "file", "path": "src/markdown.sh" },
20+
{ "type": "file", "path": "templates/changelog_prompt.md" },
21+
{ "type": "file", "path": "templates/message_prompt.md" },
22+
{ "type": "file", "path": "templates/post_example.md" },
23+
{ "type": "file", "path": "templates/post_prompt.md" },
24+
{ "type": "file", "path": "templates/release_notes_prompt.md" },
25+
{ "type": "file", "path": "templates/summary_prompt.md" },
26+
{ "type": "file", "path": "templates/announcement_prompt.md" }
27+
]
28+
}
29+
]
30+
}

build/flatpak/publish.sh

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
#!/bin/bash
2+
set -euo
3+
4+
VERSION="$1"
5+
_CWD="$(dirname "$(readlink -f "$0")")"
6+
cd "./dist/${VERSION}/flatpak/"
7+
flatpak-builder build-dir flatpak.json --force-clean
8+
cd "${_CWD}"

build/homebrew/build.sh

Lines changed: 32 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,32 @@
1+
#!/usr/bin/env bash
2+
set -euo pipefail
3+
4+
VERSION="$1"
5+
HOMEBREW_BUILD_TEMP="$2/homebrew"
6+
HOMEBREW_DIST_DIR="./dist/${VERSION}/homebrew"
7+
8+
# Prepare temp
9+
rm -rf "$HOMEBREW_BUILD_TEMP"
10+
mkdir -p "$HOMEBREW_BUILD_TEMP/src" "$HOMEBREW_BUILD_TEMP/templates"
11+
12+
# Copy files
13+
cp src/giv.sh "$HOMEBREW_BUILD_TEMP/src/giv"
14+
chmod +x "$HOMEBREW_BUILD_TEMP/src/giv"
15+
find src -type f -name '*.sh' ! -name 'giv.sh' -exec cp {} "$HOMEBREW_BUILD_TEMP/src/" \;
16+
cp -r templates/* "$HOMEBREW_BUILD_TEMP/templates/"
17+
18+
# Tarball everything (relative to the root of temp)
19+
TARBALL_NAME="giv-${VERSION}.tar.gz"
20+
tar -czf "$HOMEBREW_DIST_DIR/$TARBALL_NAME" -C "$HOMEBREW_BUILD_TEMP" .
21+
22+
# Calculate SHA256 for Homebrew formula
23+
SHA256=$(shasum -a 256 "$HOMEBREW_DIST_DIR/$TARBALL_NAME" | awk '{print $1}')
24+
25+
# Prepare Formula (template below)
26+
sed -e "s|{{VERSION}}|${VERSION}|g" \
27+
-e "s|{{TARBALL_URL}}|https://github.com/itlackey/giv/releases/download/v${VERSION}/$TARBALL_NAME|g" \
28+
-e "s|{{SHA256}}|$SHA256|g" \
29+
build/homebrew/giv.rb > "$HOMEBREW_DIST_DIR/giv.rb"
30+
31+
printf "Homebrew build completed. Files are in %s\n" "${HOMEBREW_DIST_DIR}"
32+
printf "Upload %s to your releases, and update your tap with the new formula.\n" "$TARBALL_NAME"

build/homebrew/giv.rb

Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,21 @@
1+
class Giv < Formula
2+
desc "Git history AI assistant CLI tool"
3+
homepage "https://github.com/giv-cli/giv"
4+
url "{{TARBALL_URL}}"
5+
version "{{VERSION}}"
6+
sha256 "{{SHA256}}"
7+
8+
def install
9+
bin.install "src/giv" => "giv"
10+
libexec.install Dir["src/*.sh"]
11+
(share/"giv/templates").install Dir["templates/*"]
12+
13+
# Move all .sh libs to /usr/local/lib/giv for compatibility
14+
lib.mkpath
15+
(lib/"giv").install Dir[libexec/"*.sh"]
16+
end
17+
18+
test do
19+
system "#{bin}/giv", "--help"
20+
end
21+
end

build/homebrew/install.md

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
brew tap giv-cli/homebrew
2+
brew install giv
File renamed without changes.

build/npm/build.sh

Lines changed: 7 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -2,17 +2,18 @@
22

33
VERSION="$1"
44
NPM_DIST_DIR="./dist/${VERSION}"
5-
NPM_BUILD_TEMP="$2/npm/"
5+
BUILD_TEMP="$2" #/npm/"
66

77
# npm build section
8-
mkdir -p "${NPM_BUILD_TEMP}"
9-
cp -r src templates "${NPM_BUILD_TEMP}/"
10-
sed "s/{{VERSION}}/${VERSION}/g" build/npm/package.json > "${NPM_BUILD_TEMP}/package.json"
11-
cp README.md "${NPM_BUILD_TEMP}/"
8+
#mkdir -p "${NPM_BUILD_TEMP}"
9+
#cp -r src templates "${NPM_BUILD_TEMP}/"
10+
#sed "s/{{VERSION}}/${VERSION}/g" build/npm/package.json > "${NPM_BUILD_TEMP}/package.json"
11+
#cp README.md "${NPM_BUILD_TEMP}/"
1212

1313
# Copy BUILD_TEMP to DIST_DIR
1414
mkdir -p "${NPM_DIST_DIR}"
1515
rm -rf "${NPM_DIST_DIR}/npm"
16-
mv -f "${NPM_BUILD_TEMP}" "${NPM_DIST_DIR}/"
16+
cp -rf "${BUILD_TEMP}/package" "${NPM_DIST_DIR}/npm/"
17+
sed "s/{{VERSION}}/${VERSION}/g" build/npm/package.json > "${NPM_DIST_DIR}/npm/package.json"
1718

1819
printf "npm build completed. Files are in %s\n" "${NPM_DIST_DIR}/npm"

0 commit comments

Comments
 (0)