Skip to content
Draft
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
212 changes: 212 additions & 0 deletions .github/workflows/build.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,212 @@
name: Build & Package

on:
push:
branches: [main]
tags: ['v*']
pull_request:
branches: [main]

env:
ARCH: arm64

jobs:
lint:
name: Lint
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4

- name: Set up Python
uses: actions/setup-python@v5
with:
python-version: '3.11'

- name: Install ruff
run: pip install ruff

- name: Lint Python services
run: ruff check services/

# Reusable version computation — PR builds get a ~prN suffix
version:
name: Compute version
runs-on: ubuntu-latest
outputs:
version: ${{ steps.version.outputs.version }}
steps:
- uses: actions/checkout@v4

- name: Read version
id: version
run: |
base=$(cat VERSION | tr -d '[:space:]')
if [ "${{ github.event_name }}" = "pull_request" ]; then
echo "version=${base}~pr${{ github.event.number }}" >> "$GITHUB_OUTPUT"
else
echo "version=${base}" >> "$GITHUB_OUTPUT"
fi

build-python-packages:
name: Package Python services
runs-on: ubuntu-latest
needs: [lint, version]
steps:
- uses: actions/checkout@v4

- name: Install tools
run: |
curl -sfL https://github.com/goreleaser/nfpm/releases/download/v2.41.1/nfpm_2.41.1_linux_amd64.tar.gz \
| tar xzf - -C /usr/local/bin nfpm
pip install pyyaml

- name: Generate packaging files
run: python3 packaging/generate.py

- name: Build Python .deb packages
working-directory: packaging/generated
env:
VERSION: ${{ needs.version.outputs.version }}
run: |
mkdir -p ../../dist
for svc in autopilot-manager connection-manager service-manager system-manager; do
echo "Packaging ark-${svc}..."
nfpm package --config "ark-${svc}.yaml" --packager deb --target ../../dist/
done

- name: Build Bash .deb packages
working-directory: packaging/generated
env:
VERSION: ${{ needs.version.outputs.version }}
run: |
for svc in hotspot-updater jetson-can; do
echo "Packaging ark-${svc}..."
nfpm package --config "ark-${svc}.yaml" --packager deb --target ../../dist/
done

- name: Upload Python/Bash package artifacts
uses: actions/upload-artifact@v4
with:
name: python-bash-packages
path: dist/*.deb

build-cpp-packages:
name: Build & package C++ services
runs-on: ubuntu-latest
needs: [lint, version]
steps:
- uses: actions/checkout@v4
with:
submodules: recursive

- name: Set up Docker Buildx
uses: docker/setup-buildx-action@v3

- name: Set up QEMU for ARM64
uses: docker/setup-qemu-action@v3
with:
platforms: arm64

- name: Build C++ services and package
run: |
docker buildx build \
--platform linux/arm64 \
--load \
-t ark-builder \
-f packaging/Dockerfile.build .

docker run --rm \
--platform linux/arm64 \
-v "$PWD:/build" \
-w /build \
-e VERSION=${{ needs.version.outputs.version }} \
-e ARCH=arm64 \
ark-builder \
bash -c "packaging/build-packages.sh build-cpp && packaging/build-packages.sh package"

- name: Upload C++ package artifacts
uses: actions/upload-artifact@v4
with:
name: cpp-packages
path: dist/*.deb

build-frontend-package:
name: Build & package frontend
runs-on: ubuntu-latest
needs: version
steps:
- uses: actions/checkout@v4

- name: Set up Node.js
uses: actions/setup-node@v4
with:
node-version: '20'

- name: Install tools
run: |
curl -sfL https://github.com/goreleaser/nfpm/releases/download/v2.41.1/nfpm_2.41.1_linux_amd64.tar.gz \
| tar xzf - -C /usr/local/bin nfpm
pip install pyyaml

- name: Build frontend
working-directory: frontend/ark-ui/ark-ui
run: |
npm ci
npm run build
mkdir -p ../../../build/ark-ui
cp -r dist ../../../build/ark-ui/

- name: Generate packaging files
run: python3 packaging/generate.py

- name: Package frontend
working-directory: packaging/generated
env:
VERSION: ${{ needs.version.outputs.version }}
run: |
mkdir -p ../../dist
nfpm package --config ark-ui.yaml --packager deb --target ../../dist/

- name: Upload frontend package artifact
uses: actions/upload-artifact@v4
with:
name: frontend-package
path: dist/*.deb

release:
name: Create Release
runs-on: ubuntu-latest
if: startsWith(github.ref, 'refs/tags/v')
needs: [build-python-packages, build-cpp-packages, build-frontend-package, version]
permissions:
contents: write
steps:
- uses: actions/checkout@v4

- name: Download all artifacts
uses: actions/download-artifact@v4
with:
path: dist
merge-multiple: true

- name: Build meta-packages
run: |
curl -sfL https://github.com/goreleaser/nfpm/releases/download/v2.41.1/nfpm_2.41.1_linux_amd64.tar.gz \
| tar xzf - -C /usr/local/bin nfpm
pip install pyyaml
python3 packaging/generate.py

cd packaging/generated
for pkg in ark-companion-base ark-companion-jetson ark-companion-pi ark-companion-ubuntu; do
echo "Packaging ${pkg}..."
VERSION="${{ needs.version.outputs.version }}" ARCH=arm64 nfpm package \
--config "${pkg}.yaml" \
--packager deb \
--target ../../dist/
done

- name: Create GitHub Release
uses: softprops/action-gh-release@v2
with:
files: dist/*.deb
generate_release_notes: true
93 changes: 93 additions & 0 deletions .github/workflows/publish-apt.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,93 @@
name: Publish APT Repository

on:
release:
types: [published]

jobs:
publish:
name: Publish to APT repository
runs-on: ubuntu-latest
permissions:
contents: write
steps:
- name: Install reprepro
run: sudo apt-get update && sudo apt-get install -y reprepro

- name: Import GPG key
env:
GPG_PRIVATE_KEY: ${{ secrets.APT_GPG_PRIVATE_KEY }}
GPG_PASSPHRASE: ${{ secrets.APT_GPG_PASSPHRASE }}
run: |
echo "${GPG_PRIVATE_KEY}" | gpg --batch --import
# Trust the imported key ultimately
GPG_KEYID=$(gpg --list-secret-keys --keyid-format long | grep sec | head -1 | awk '{print $2}' | cut -d'/' -f2)
echo "${GPG_KEYID}:6:" | gpg --import-ownertrust

- name: Check out gh-pages branch
id: checkout
run: |
git init repo
cd repo
git remote add origin "https://x-access-token:${{ github.token }}@github.com/${{ github.repository }}.git"

if git ls-remote --exit-code origin gh-pages; then
git fetch origin gh-pages
git checkout gh-pages
echo "existed=true" >> "$GITHUB_OUTPUT"
else
git checkout --orphan gh-pages
git commit --allow-empty -m "Initialize gh-pages"
echo "existed=false" >> "$GITHUB_OUTPUT"
fi

- name: Check out packaging config from main
uses: actions/checkout@v4
with:
path: main-src
sparse-checkout: packaging/apt

- name: Initialize reprepro config
working-directory: repo
run: |
# Only copy config if conf/ doesn't exist yet (first run)
if [ ! -d conf ]; then
mkdir -p conf
cp ../main-src/packaging/apt/distributions conf/
cp ../main-src/packaging/apt/options conf/
fi

- name: Download release .deb assets
env:
GH_TOKEN: ${{ github.token }}
run: |
mkdir -p debs
gh release download "${{ github.event.release.tag_name }}" \
--repo "${{ github.repository }}" \
--pattern "*.deb" \
--dir debs

- name: Add packages to repository
working-directory: repo
env:
GPG_PASSPHRASE: ${{ secrets.APT_GPG_PASSPHRASE }}
run: |
for deb in ../debs/*.deb; do
echo "Adding $(basename "$deb")..."
reprepro includedeb stable "$deb"
done

- name: Export GPG public key
working-directory: repo
run: |
gpg --export --armor > ark-archive-keyring.asc
gpg --export > ark-archive-keyring.gpg

- name: Commit and push to gh-pages
working-directory: repo
run: |
git config user.name "github-actions[bot]"
git config user.email "github-actions[bot]@users.noreply.github.com"
git add -A
git commit -m "Update APT repository for ${{ github.event.release.tag_name }}" || echo "No changes to commit"
git push origin gh-pages
6 changes: 5 additions & 1 deletion .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -2,4 +2,8 @@ libmavsdk*
polaris.key
output.txt
user.env
CLAUDE.md
build/
dist/
packaging/generated/
__pycache__/
*.pyc
Loading
Loading