Skip to content

Commit 359e7d9

Browse files
committed
added package install validation, strip_markdown, stub glow integration
1 parent d43292c commit 359e7d9

22 files changed

+742
-189
lines changed
Lines changed: 26 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,26 @@
1+
name: Build and Validate Packages
2+
3+
on:
4+
workflow_dispatch:
5+
pull_request:
6+
paths:
7+
- 'src/**'
8+
- 'templates/**'
9+
- 'build/**'
10+
11+
jobs:
12+
build-and-validate:
13+
runs-on: ubuntu-latest
14+
steps:
15+
- uses: actions/checkout@v4
16+
17+
- name: Build Docker image
18+
run: docker build -t giv-build -f build/Dockerfile.packages .
19+
20+
- name: Build packages inside container
21+
run: |
22+
docker run --rm -v ${{ github.workspace }}:/workspace giv-build /workspace/build/build.sh
23+
24+
- name: Validate installs inside container
25+
run: |
26+
docker run --rm -v ${{ github.workspace }}:/workspace giv-build /workspace/ci/install-validate.sh

.vscode/settings.json

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,12 @@
2121
"[ ]",
2222
"[x]",
2323
"ENHANCEMENT",
24-
"CHORE"
24+
"CHORE",
25+
"FEAT",
26+
"FEATURE",
27+
"DOC:",
28+
"DOCUMENTATION",
29+
"TEST:"
2530
],
2631
"shellcheck.customArgs": [
2732
"-x"
Lines changed: 28 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,7 @@ RUN apt-get update && \
1313
snapd \
1414
python3 \
1515
python3-pip \
16+
python3.12-venv \
1617
ruby \
1718
ruby-dev \
1819
flatpak-builder \
@@ -30,6 +31,8 @@ RUN locale-gen en_US.UTF-8
3031
ENV LANG=en_US.UTF-8
3132
ENV LANGUAGE=en_US:en
3233
ENV LC_ALL=en_US.UTF-8
34+
35+
3336
# Install snapd (for snap builds; install snaps at runtime)
3437
#RUN apt-get update && apt-get install -y --no-install-recommends snapd && rm -rf /var/lib/apt/lists/*
3538
# NOTE: To use snapcraft, start the container and run:
@@ -41,10 +44,6 @@ RUN gem install --no-document fpm
4144
# Install bats (for shell testing)
4245
RUN npm install -g bats
4346

44-
# Install Homebrew (for homebrew builds, on Linux)
45-
RUN /bin/bash -c "$(curl -fsSL https://raw.githubusercontent.com/Homebrew/install/HEAD/install.sh)" || true
46-
ENV PATH="/home/linuxbrew/.linuxbrew/bin:/home/linuxbrew/.linuxbrew/sbin:$PATH"
47-
RUN brew update || true
4847

4948
# Install GitHub CLI (gh)
5049
RUN type -p gh || (curl -fsSL https://cli.github.com/packages/githubcli-archive-keyring.gpg | \
@@ -54,6 +53,31 @@ RUN type -p gh || (curl -fsSL https://cli.github.com/packages/githubcli-archive-
5453
tee /etc/apt/sources.list.d/github-cli.list > /dev/null && \
5554
apt-get update && apt-get install -y gh)
5655

56+
# Install Homebrew (for homebrew builds, on Linux)
57+
58+
# 2) Ensure UTF-8 locale (prevents brew warnings)
59+
RUN localedef -i en_US -f UTF-8 en_US.UTF-8
60+
61+
# 3) Create a non-root user for Homebrew
62+
RUN useradd -m -s /bin/bash linuxbrew && \
63+
echo 'linuxbrew ALL=(ALL) NOPASSWD:ALL' >> /etc/sudoers
64+
65+
# 4) Switch to that user and install Homebrew (non-interactively)
66+
USER linuxbrew
67+
ENV CI=1 NONINTERACTIVE=1
68+
RUN /bin/bash -c \
69+
"$(curl -fsSL https://raw.githubusercontent.com/Homebrew/install/HEAD/install.sh)"
70+
71+
ENV PATH="/home/linuxbrew/.linuxbrew/bin:/home/linuxbrew/.linuxbrew/sbin:${PATH}"
72+
73+
# 6) Verify brew works
74+
RUN brew --version && brew update --quiet
75+
76+
# # 5) Switch back to root, expose brew on PATH
77+
USER root
78+
ENV PATH="/home/linuxbrew/.linuxbrew/bin:/home/linuxbrew/.linuxbrew/sbin:${PATH}"
79+
80+
5781
# Set workdir
5882
WORKDIR /workspace
5983

build/build.sh renamed to build/build-packages.sh

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -60,6 +60,9 @@ if [ "${FPM_INSTALLED}" = "true" ]; then
6060
fi
6161
./build/snap/build.sh "${VERSION}" "${BUILD_TEMP}"
6262
./build/flatpak/build.sh "${VERSION}" "${BUILD_TEMP}"
63+
./build/docker/build.sh "${VERSION}" "${BUILD_TEMP}"
6364

6465
#rm -rf "${BUILD_TEMP}"
6566
printf "Build completed. Files are in %s\n" "${DIST_DIR}"
67+
68+
rm -rf "${BUILD_TEMP}"

build/docker-build.sh

Lines changed: 0 additions & 3 deletions
This file was deleted.

build/docker/Dockerfile

Lines changed: 43 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,43 @@
1+
FROM debian:bookworm-slim
2+
3+
# Install required packages
4+
RUN apt-get update && \
5+
apt-get install -y --no-install-recommends \
6+
ca-certificates \
7+
git \
8+
curl \
9+
bash \
10+
&& rm -rf /var/lib/apt/lists/*
11+
12+
# # ---- Install Glow ----
13+
# ENV GLOW_VERSION="2.1.1"
14+
# RUN curl -fsSL "https://github.com/charmbracelet/glow/releases/download/v${GLOW_VERSION}/glow_${GLOW_VERSION}_linux_amd64.deb" -o /tmp/glow.deb \
15+
# && apt-get update \
16+
# && apt-get install -y /tmp/glow.deb \
17+
# && rm /tmp/glow.deb
18+
19+
# Copy your built files into place (from the repo root at build time)
20+
# Assume you have these in the build context!
21+
COPY src/giv.sh /usr/local/bin/giv
22+
COPY src/*.sh /usr/local/lib/giv/
23+
COPY templates/ /usr/local/share/giv/templates/
24+
COPY docs/ /usr/local/share/giv/docs/
25+
26+
RUN chmod +x /usr/local/bin/giv
27+
28+
# Set up environment
29+
ENV GIV_LIB_DIR="/usr/local/lib/giv"
30+
ENV GIV_TEMPLATE_DIR="/usr/local/share/giv/templates"
31+
ENV GIV_DOCS_DIR="/usr/local/share/giv/docs"
32+
ENV PATH="/usr/local/bin:$PATH"
33+
34+
# Test it works
35+
RUN giv --help || true
36+
37+
# Use bash shell by default
38+
SHELL ["/bin/bash", "-c"]
39+
40+
WORKDIR /workspace
41+
42+
ENTRYPOINT ["giv"]
43+
CMD ["--help"]

build/docker/build.sh

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
#! /bin/bash
2+
3+
VERSION="$1"
4+
IMAGE="giv-cli/giv"
5+
6+
docker build -f build/docker/Dockerfile \
7+
-t "${IMAGE}:$VERSION" \
8+
-t "${IMAGE}:latest" \
9+
.

build/docker/publish.sh

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,13 @@
1+
#! /bin/bash
2+
3+
VERSION="$1"
4+
IMAGE="giv-cli/giv"
5+
6+
# 2) Login to Docker Hub
7+
echo "$DOCKER_HUB_PASSWORD" | docker login \
8+
--username "$DOCKER_HUB_USERNAME" \
9+
--password-stdin
10+
11+
# 3) Push both tags
12+
docker push "${IMAGE}:${VERSION}"
13+
docker push "${IMAGE}:latest"

build/homebrew/build.sh

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -23,6 +23,10 @@ sed -e "s|{{VERSION}}|${VERSION}|g" \
2323
-e "s|{{SHA256}}|$SHA256|g" \
2424
build/homebrew/giv.rb > "$HOMEBREW_DIST_DIR/giv.rb"
2525

26+
sed -e "s|{{VERSION}}|${VERSION}|g" \
27+
-e "s|{{SHA256}}|$SHA256|g" \
28+
build/homebrew/giv.local.rb > "$HOMEBREW_DIST_DIR/giv.local.rb"
29+
2630
rm -rf "$HOMEBREW_DIST_DIR/package"
2731
printf "Homebrew build completed. Files are in %s\n" "${HOMEBREW_DIST_DIR}"
2832
printf "Upload %s to your releases, and update your tap with the new formula.\n" "$TARBALL_NAME"

build/homebrew/giv.local.rb

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

0 commit comments

Comments
 (0)