diff --git a/.github/workflows/deploy.yml b/.github/workflows/deploy.yml index 0ae9c57..1ff8474 100644 --- a/.github/workflows/deploy.yml +++ b/.github/workflows/deploy.yml @@ -21,6 +21,11 @@ jobs: run-id: ${{ github.event.workflow_run.id }} github-token: ${{ secrets.GITHUB_TOKEN }} + - name: Extract binary from cargo-dist archive + run: | + tar -xzf dk-x86_64-unknown-linux-gnu.tar.gz + chmod +x dk + - name: Upload binary to server uses: appleboy/scp-action@ff85246acaad7bdce478db94a363cd2bf7c90345 # v1.0.0 with: diff --git a/.github/workflows/publish-linux-packages.yml b/.github/workflows/publish-linux-packages.yml new file mode 100644 index 0000000..e3fd106 --- /dev/null +++ b/.github/workflows/publish-linux-packages.yml @@ -0,0 +1,199 @@ +name: Publish Linux Packages + +on: + push: + tags: + - '*-?[0-9]+.[0-9]+.[0-9]+*' + workflow_dispatch: + +concurrency: + group: publish-linux-packages-${{ github.ref }} + cancel-in-progress: false + +jobs: + build-deb: + name: Build .deb package + runs-on: ubuntu-22.04 + steps: + - uses: actions/checkout@v4 + - uses: dtolnay/rust-toolchain@stable + - uses: actions/cache@v4 + with: + path: | + ~/.cargo/registry + ~/.cargo/git + target + key: ${{ runner.os }}-cargo-deb-${{ hashFiles('**/Cargo.lock') }} + - name: Install cargo-deb + run: cargo install cargo-deb --locked + - name: Build .deb package + run: cargo deb + - name: Upload deb artifact + uses: actions/upload-artifact@v4 + with: + name: deb-package + path: target/debian/*.deb + + build-rpm: + name: Build .rpm package + runs-on: ubuntu-22.04 + steps: + - uses: actions/checkout@v4 + - uses: dtolnay/rust-toolchain@stable + - uses: actions/cache@v4 + with: + path: | + ~/.cargo/registry + ~/.cargo/git + target + key: ${{ runner.os }}-cargo-rpm-${{ hashFiles('**/Cargo.lock') }} + - name: Install cargo-generate-rpm + run: cargo install cargo-generate-rpm --locked + - name: Build release binary + run: cargo build --release + - name: Build .rpm package + run: cargo generate-rpm + - name: Upload rpm artifact + uses: actions/upload-artifact@v4 + with: + name: rpm-package + path: target/generate-rpm/*.rpm + + publish-apt: + name: Publish to APT repository + needs: build-deb + runs-on: ubuntu-22.04 + steps: + - name: Download deb artifact + uses: actions/download-artifact@v4 + with: + name: deb-package + path: ./debs + + - name: Import GPG signing key + run: | + echo "${{ secrets.GPG_PRIVATE_KEY }}" | gpg --import --batch --yes + # Trust the key fully + KEY_ID=$(gpg --list-secret-keys --keyid-format LONG hello@dakera.ai \ + | grep sec | head -1 | awk '{print $2}' | cut -d/ -f2) + echo "${KEY_ID}:6:" | gpg --import-ownertrust + + - name: Checkout apt-repo + uses: actions/checkout@v4 + with: + repository: dakera-ai/apt-repo + token: ${{ secrets.APT_REPO_TOKEN }} + path: apt-repo + + - name: Install APT repo tools + run: sudo apt-get install -y dpkg-dev apt-utils + + - name: Add package and regenerate index + run: | + set -euo pipefail + DEB=$(ls ./debs/*.deb | head -1) + echo "Processing: $DEB" + + # Place deb in pool + mkdir -p apt-repo/pool/main/d/dk/ + cp "$DEB" apt-repo/pool/main/d/dk/ + + # Create Packages index + mkdir -p apt-repo/dists/stable/main/binary-amd64/ + cd apt-repo + dpkg-scanpackages --multiversion pool/ > dists/stable/main/binary-amd64/Packages + gzip -k -f dists/stable/main/binary-amd64/Packages + xz -k -f dists/stable/main/binary-amd64/Packages + + # Generate Release file + apt-ftparchive \ + -o APT::FTPArchive::Release::Origin="Dakera AI" \ + -o APT::FTPArchive::Release::Label="Dakera" \ + -o APT::FTPArchive::Release::Suite="stable" \ + -o APT::FTPArchive::Release::Codename="stable" \ + -o APT::FTPArchive::Release::Architectures="amd64" \ + -o APT::FTPArchive::Release::Components="main" \ + -o APT::FTPArchive::Release::Description="Dakera AI CLI packages" \ + release dists/stable/ > dists/stable/Release + + # Sign the Release file + gpg --batch --yes --default-key "hello@dakera.ai" \ + --clearsign -o dists/stable/InRelease dists/stable/Release + gpg --batch --yes --default-key "hello@dakera.ai" \ + -abs -o dists/stable/Release.gpg dists/stable/Release + + echo "APT repo updated successfully" + + - name: Commit and push + run: | + cd apt-repo + git config user.email "platform@dakera.ai" + git config user.name "Dakera Platform Bot" + git add -A + if git diff --cached --quiet; then + echo "No changes to commit" + else + VERSION="${{ github.ref_name }}" + git commit -m "feat: add dk ${VERSION} packages" + git push + fi + + publish-rpm: + name: Publish to RPM repository + needs: build-rpm + runs-on: ubuntu-22.04 + steps: + - name: Download rpm artifact + uses: actions/download-artifact@v4 + with: + name: rpm-package + path: ./rpms + + - name: Import GPG signing key + run: | + echo "${{ secrets.GPG_PRIVATE_KEY }}" | gpg --import --batch --yes + KEY_ID=$(gpg --list-secret-keys --keyid-format LONG hello@dakera.ai \ + | grep sec | head -1 | awk '{print $2}' | cut -d/ -f2) + echo "${KEY_ID}:6:" | gpg --import-ownertrust + + - name: Checkout rpm-repo + uses: actions/checkout@v4 + with: + repository: dakera-ai/rpm-repo + token: ${{ secrets.APT_REPO_TOKEN }} + path: rpm-repo + + - name: Install createrepo_c + run: sudo apt-get install -y createrepo-c + + - name: Add package and regenerate metadata + run: | + set -euo pipefail + RPM=$(ls ./rpms/*.rpm | head -1) + echo "Processing: $RPM" + + mkdir -p rpm-repo/packages/ + cp "$RPM" rpm-repo/packages/ + + # Regenerate all repository metadata + createrepo_c --update rpm-repo/ + + # Sign the repository metadata so dnf/yum clients can verify integrity + gpg --batch --yes --default-key "hello@dakera.ai" \ + -abs -o rpm-repo/repodata/repomd.xml.asc rpm-repo/repodata/repomd.xml + + echo "RPM repo updated and signed successfully" + + - name: Commit and push + run: | + cd rpm-repo + git config user.email "platform@dakera.ai" + git config user.name "Dakera Platform Bot" + git add -A + if git diff --cached --quiet; then + echo "No changes to commit" + else + VERSION="${{ github.ref_name }}" + git commit -m "feat: add dk ${VERSION} packages" + git push + fi diff --git a/.github/workflows/publish-snap.yml b/.github/workflows/publish-snap.yml new file mode 100644 index 0000000..3a6100a --- /dev/null +++ b/.github/workflows/publish-snap.yml @@ -0,0 +1,40 @@ +name: Publish Snap + +on: + push: + tags: + - '*-?[0-9]+.[0-9]+.[0-9]+*' + workflow_dispatch: + inputs: + channel: + description: 'Snap Store channel (stable/candidate/beta/edge)' + required: false + default: 'stable' + +jobs: + snap: + name: Build and publish Snap package + runs-on: ubuntu-latest + steps: + - uses: actions/checkout@v4 + + - name: Update version in snapcraft.yaml + run: | + # Extract version from tag: dk-v0.6.0 → 0.6.0 + VERSION="${{ github.ref_name }}" + VERSION="${VERSION#dk-v}" + VERSION="${VERSION#v}" + sed -i "s/^version: .*/version: \"${VERSION}\"/" snap/snapcraft.yaml + echo "Building snap version: ${VERSION}" + + - name: Build snap + id: build + uses: snapcore/action-build@v1 + + - name: Publish to Snap Store + uses: snapcore/action-publish@v1 + env: + SNAPCRAFT_STORE_CREDENTIALS: ${{ secrets.SNAPCRAFT_STORE_CREDENTIALS }} + with: + snap: ${{ steps.build.outputs.snap }} + release: ${{ github.event.inputs.channel || 'stable' }} diff --git a/Cargo.toml b/Cargo.toml index d50e3ec..bee1b39 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -55,6 +55,24 @@ httpmock = "0.8" assert_cmd = "2.2" predicates = "3.1" +[package.metadata.deb] +maintainer = "Dakera AI " +copyright = "2024-2026, Dakera AI" +section = "utility" +priority = "optional" +assets = [ + ["target/release/dk", "usr/bin/", "755"], +] +extended-description = """\ +Dakera CLI for querying and managing AI agent memory. \ +Connect to Dakera server instances to manage agent memories, \ +sessions, and knowledge graphs from the command line.""" + +[package.metadata.generate-rpm] +assets = [ + { source = "target/release/dk", dest = "/usr/bin/dk", mode = "0755" }, +] + [package.metadata.binstall] pkg-url = "{ repo }/releases/download/v{ version }/dk-{ target }.tar.gz" bin-dir = "dk{ binary-ext }" diff --git a/snap/snapcraft.yaml b/snap/snapcraft.yaml new file mode 100644 index 0000000..0ed9bb7 --- /dev/null +++ b/snap/snapcraft.yaml @@ -0,0 +1,29 @@ +name: dk +base: core24 +version: "0.6.0" +summary: Command-line interface for Dakera AI Agent Memory Platform +description: | + Dakera CLI for querying and managing AI agent memory. + Connect to Dakera server instances to manage agent memories, + sessions, and knowledge graphs from the command line. + + Configure with: dk init + Documentation: https://docs.dakera.ai/cli + +grade: stable +confinement: strict + +parts: + dakera-cli: + plugin: rust + source: . + build-packages: + - libssl-dev + - pkg-config + +apps: + dk: + command: bin/dk + plugs: + - network + - home