Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion .github/workflows/release-dev.yml
Original file line number Diff line number Diff line change
Expand Up @@ -654,7 +654,7 @@ jobs:

build-snap:
name: Build Snap
needs: [compute-versions]
needs: [compute-versions, build-cli-linux, build-gateway-binary-linux, build-supervisor-binary-linux]
uses: ./.github/workflows/snap-package.yml
with:
checkout-ref: ${{ github.sha }}
Expand Down
2 changes: 1 addition & 1 deletion .github/workflows/release-tag.yml
Original file line number Diff line number Diff line change
Expand Up @@ -690,7 +690,7 @@ jobs:

build-snap:
name: Build Snap
needs: [compute-versions]
needs: [compute-versions, build-cli-linux, build-gateway-binary-linux, build-supervisor-binary-linux]
uses: ./.github/workflows/snap-package.yml
with:
checkout-ref: ${{ inputs.tag || github.ref }}
Expand Down
50 changes: 50 additions & 0 deletions .github/workflows/snap-package.yml
Original file line number Diff line number Diff line change
Expand Up @@ -76,12 +76,62 @@ jobs:
set -euo pipefail
sudo snap install snapcraft --classic

- name: Download prebuilt CLI binary
uses: actions/download-artifact@3e5f45b2cfb9172054b40e67214ff5f5447ce83dd # v8
with:
name: cli-linux-${{ matrix.arch }}
path: prebuilt/cli

- name: Download prebuilt gateway binary
uses: actions/download-artifact@3e5f45b2cfb9172054b40e67214ff5f5447ce83dd # v8
with:
name: gateway-binary-linux-${{ matrix.arch }}
path: prebuilt/gateway

- name: Download prebuilt sandbox binary
uses: actions/download-artifact@3e5f45b2cfb9172054b40e67214ff5f5447ce83dd # v8
with:
name: supervisor-binary-linux-${{ matrix.arch }}
path: prebuilt/sandbox

- name: Extract prebuilt binaries
run: |
set -euo pipefail
mkdir -p prebuilt/{cli,gateway,sandbox}

for d in cli gateway sandbox; do
for tarball in prebuilt/$d/*.tar.gz; do
if [ -f "$tarball" ]; then
tar -xzf "$tarball" -C "prebuilt/$d"
else
echo "WARNING: no tarball found in prebuilt/$d/" >&2
fi
done
done
ls -laR prebuilt/

- name: Prepare snap build directory
run: |
set -euo pipefail
mkdir -p snap/prebuilt

cp prebuilt/cli/openshell snap/prebuilt/openshell
cp prebuilt/gateway/openshell-gateway snap/prebuilt/openshell-gateway
cp prebuilt/sandbox/openshell-sandbox snap/prebuilt/openshell-sandbox

cp deploy/snap/bin/openshell-gateway-wrapper snap/prebuilt/
cp LICENSE snap/prebuilt/
cp README.md snap/prebuilt/

python3 tasks/scripts/release.py get-version --snap > snap/prebuilt/version

- name: Build snap
run: |
set -euo pipefail
runtime_dir="/run/user/$(id -u)"
sudo install -d -m 0700 -o "$(id -u)" -g "$(id -g)" "$runtime_dir"
export XDG_RUNTIME_DIR="$runtime_dir"

sg lxd -c "XDG_RUNTIME_DIR=${runtime_dir} snapcraft pack -v"

- name: Upload snapcraft logs on failure
Expand Down
49 changes: 25 additions & 24 deletions snapcraft.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -52,39 +52,40 @@ apps:

parts:
openshell:
plugin: rust
rust-channel: "1.95.0"
source: .
build-packages:
- build-essential
- ca-certificates
- clang
- cmake
- git
- libclang-dev
- libssl-dev
- libz3-dev
- pkg-config
- python3
plugin: nil
source: ./snap/prebuilt
override-pull: |
craftctl default
craftctl set version="$(python3 "$CRAFT_PROJECT_DIR/tasks/scripts/release.py" get-version --snap)"
craftctl set version="$(cat "$CRAFT_PART_SRC/version")"
override-build: |
set -euo pipefail

cargo build --release --locked -p openshell-cli --features bundled-z3
cargo build --release --locked -p openshell-server --bin openshell-gateway --features bundled-z3
cargo build --release --locked -p openshell-sandbox --bin openshell-sandbox
MISSING=()
for bin in openshell openshell-gateway openshell-sandbox openshell-gateway-wrapper; do
if [ ! -f "$CRAFT_PART_SRC/$bin" ]; then
MISSING+=("$bin")
fi
done

install -D -m 0755 "$CRAFT_PART_BUILD/target/release/openshell" \
if [ ${#MISSING[@]} -gt 0 ]; then
printf '%s\n' \
"ERROR: snap/prebuilt/ is incomplete:" \
"${MISSING[@]/#/' - '}" \
"" \
"The snap build directory must be populated by CI before snapcraft pack." \
>&2
exit 1
fi

install -D -m 0755 "$CRAFT_PART_SRC/openshell" \
"$CRAFT_PART_INSTALL/bin/openshell"
install -D -m 0755 "$CRAFT_PART_BUILD/target/release/openshell-gateway" \
install -D -m 0755 "$CRAFT_PART_SRC/openshell-gateway" \
"$CRAFT_PART_INSTALL/bin/openshell-gateway"
install -D -m 0755 "$CRAFT_PART_BUILD/target/release/openshell-sandbox" \
install -D -m 0755 "$CRAFT_PART_SRC/openshell-sandbox" \
"$CRAFT_PART_INSTALL/bin/openshell-sandbox"
install -D -m 0755 "$CRAFT_PROJECT_DIR/deploy/snap/bin/openshell-gateway-wrapper" \
install -D -m 0755 "$CRAFT_PART_SRC/openshell-gateway-wrapper" \
"$CRAFT_PART_INSTALL/bin/openshell-gateway-wrapper"
install -D -m 0644 "$CRAFT_PROJECT_DIR/LICENSE" \
install -D -m 0644 "$CRAFT_PART_SRC/LICENSE" \
"$CRAFT_PART_INSTALL/usr/share/doc/openshell/LICENSE"
install -D -m 0644 "$CRAFT_PROJECT_DIR/README.md" \
install -D -m 0644 "$CRAFT_PART_SRC/README.md" \
"$CRAFT_PART_INSTALL/usr/share/doc/openshell/README.md"
Loading