Skip to content

Commit

Permalink
Initial release
Browse files Browse the repository at this point in the history
  • Loading branch information
RadxaYuntian committed Sep 7, 2023
0 parents commit 8b4ae0e
Show file tree
Hide file tree
Showing 34 changed files with 559 additions and 0 deletions.
7 changes: 7 additions & 0 deletions .github/dependabot.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
version: 2
updates:
# Maintain dependencies for GitHub Actions
- package-ecosystem: "github-actions"
directory: "/"
schedule:
interval: "daily"
33 changes: 33 additions & 0 deletions .github/workflows/new_version.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,33 @@
name: Create release
on:
workflow_dispatch:

permissions:
contents: write

jobs:
build:
runs-on: ubuntu-latest
steps:
- name: Checkout
uses: actions/checkout@v4
with:
submodules: recursive
fetch-depth: 0
token: ${{secrets.GIT_PUSH_TOKEN}}
- name: Create release commit
run: |
sudo apt-get update
sudo apt-get install --no-install-recommends -y git-buildpackage
export DEBEMAIL="dev@radxa.com"
export DEBFULLNAME='"Radxa Computer Co., Ltd"'
git config user.name "github-actions[bot]"
git config user.email "41898282+github-actions[bot]@users.noreply.github.com"
make dch
- name: Test
run: |
sudo apt-get build-dep --no-install-recommends -y .
make all test deb
- name: Push
run: |
git push
99 changes: 99 additions & 0 deletions .github/workflows/release.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,99 @@
name: Build & Release
on:
workflow_dispatch:
pull_request:
push:

permissions:
contents: write

jobs:
build:
runs-on: ubuntu-latest
steps:
- name: Checkout
uses: actions/checkout@v4
with:
submodules: recursive
fetch-depth: 0
- name: Test
run: |
make test
- name: Build
run: |
sudo apt-get update
sudo apt-get build-dep --no-install-recommends -y .
make all
sudo apt install -y binfmt-support qemu-user-static
container/build-deb
- name: Workaround actions/upload-artifact#176
run: |
echo "artifacts_path=$(realpath ..)" >> $GITHUB_ENV
- name: Upload artifacts
uses: actions/upload-artifact@v3
with:
name: ${{ github.event.repository.name }}
path: |
${{ env.artifacts_path }}/*.deb
release:
runs-on: ubuntu-latest
needs: build
if: ${{ github.event_name != 'pull_request' && github.ref_name == 'main' }}
steps:
- name: Checkout
uses: actions/checkout@v4
with:
submodules: recursive
fetch-depth: 0
- uses: actions/download-artifact@v3
with:
name: ${{ github.event.repository.name }}
- name: Check if the latest version is releasable
run: |
version="$(dpkg-parsechangelog -S Version)"
echo "version=$version" >> $GITHUB_ENV
echo "changes<<EOF" >> $GITHUB_ENV
echo '```' >> $GITHUB_ENV
echo "$(dpkg-parsechangelog -S Changes)" >> $GITHUB_ENV
echo '```' >> $GITHUB_ENV
echo "EOF" >> $GITHUB_ENV
if [[ -n "$(git tag -l "$version")" ]]
then
echo "distro=UNRELEASED" >> $GITHUB_ENV
else
echo "distro=$(dpkg-parsechangelog -S Distribution)" >> $GITHUB_ENV
fi
echo "$version" > VERSION
if [[ -f pkg.conf.template ]]
then
sed "s/VERSION/$(dpkg-parsechangelog -S Version)/g" pkg.conf.template > pkg.conf
fi
- name: Release
if: env.distro != 'UNRELEASED'
uses: softprops/action-gh-release@v1
with:
tag_name: ${{ env.version }}
body_path: README.md
token: ${{ secrets.GITHUB_TOKEN }}
target_commitish: main
draft: false
fail_on_unmatched_files: false
files: |
*.deb
pkg.conf
VERSION
- name: Append changelog
if: env.distro != 'UNRELEASED'
uses: softprops/action-gh-release@v1
with:
tag_name: ${{ env.version }}
body: |
## Changelog for ${{ env.version }}
${{ env.changes }}
append_body: true
- name: Update Test repos
if: env.distro != 'UNRELEASED'
uses: radxa-repo/update-repo-action@main
with:
test-repo: true
token: ${{ secrets.RADXA_APT_TEST_REPO_TOKEN }}
4 changes: 4 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
/.vscode*
/SOURCE
/VERSION
/rknnlite2
6 changes: 6 additions & 0 deletions .gitmodules
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
[submodule "rknpu2"]
path = rknpu2
url = https://github.com/rockchip-linux/rknpu2.git
[submodule "rknn-toolkit2"]
path = rknn-toolkit2
url = https://github.com/rockchip-linux/rknn-toolkit2.git
70 changes: 70 additions & 0 deletions Makefile
Original file line number Diff line number Diff line change
@@ -0,0 +1,70 @@
PROJECT ?= rknn2
PREFIX ?= /usr
BINDIR ?= $(PREFIX)/bin
LIBDIR ?= $(PREFIX)/lib
MANDIR ?= $(PREFIX)/share/man

.PHONY: all
all: build

#
# Test
#
.PHONY: test
test:

#
# Build
#
.PHONY: build
build: build-doc rknnlite2/rknn_toolkit_lite2-1.4.0/rknnlite.egg-info

SRC-DOC := .
DOCS := $(SRC-DOC)/SOURCE
.PHONY: build-doc
build-doc: $(DOCS)

$(SRC-DOC):
mkdir -p $(SRC-DOC)

.PHONY: $(SRC-DOC)/SOURCE
$(SRC-DOC)/SOURCE: $(SRC-DOC)
echo -e "git clone $(shell git remote get-url origin)\ngit checkout $(shell git rev-parse HEAD)" > "$@"

rknnlite2: rknn-toolkit2/rknn_toolkit_lite2/packages/rknn_toolkit_lite2-1.4.0-cp39-cp39-linux_aarch64.whl
wheel unpack -d "$@" "$<"

rknnlite2/rknn_toolkit_lite2-1.4.0/setup.py: rknnlite2.setup.py rknnlite2
cp "$<" "$@"

rknnlite2/rknn_toolkit_lite2-1.4.0/rknnlite.egg-info: rknnlite2/rknn_toolkit_lite2-1.4.0/setup.py
cd rknnlite2/rknn_toolkit_lite2-1.4.0 && \
python3 setup.py bdist_egg

#
# Clean
#
.PHONY: distclean
distclean: clean

.PHONY: clean
clean: clean-doc clean-deb

.PHONY: clean-doc
clean-doc:
rm -rf $(DOCS)

.PHONY: clean-deb
clean-deb:
rm -rf rknnlite2 obj-aarch64-linux-gnu debian/.debhelper debian/python3-rknnlite2/ debian/rknpu2-*/ debian/tmp/ debian/debhelper-build-stamp debian/files debian/*.debhelper.log debian/*.*.debhelper debian/*.substvars

#
# Release
#
.PHONY: dch
dch: debian/changelog
gbp dch --debian-branch=main

.PHONY: deb
deb: debian
debuild --no-lintian --lintian-hook "lintian --fail-on error,warning --suppress-tags bad-distribution-in-changes-file -- %p_%v_*.changes" --no-sign -b -aarm64 -Pcross
7 changes: 7 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
# rknn2

[![Release](https://github.com/radxa-pkg/rknn2/actions/workflows/release.yml/badge.svg)](https://github.com/radxa-pkg/rknn2/actions/workflows/release.yml)

Rockchip RKNN2, packaged by Radxa.

Supports RK356X and RK3588 SoC.
11 changes: 11 additions & 0 deletions container/Dockerfile
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
FROM debian:bullseye

RUN dpkg --add-architecture arm64 && \
apt-get update && \
apt-get full-upgrade --no-install-recommends -y \
build-essential crossbuild-essential-arm64 git \
debhelper devscripts lintian dh-exec \
libc6:arm64 libstdc++6:arm64 \
python-wheel-common python3-pkg-resources python3-distutils python3-setuptools && \
adduser --gecos runner --disabled-password runner && \
rm -rf /var/lib/apt/lists/*
98 changes: 98 additions & 0 deletions container/build-deb
Original file line number Diff line number Diff line change
@@ -0,0 +1,98 @@
#!/bin/bash

set -euo pipefail
shopt -s nullglob

build() {
local SCRIPT_DIR="$(dirname "$(realpath "$0")")"

local NATIVE_BUILD="false"
local CONTAINER_BACKEND="podman"
local CONTAINER_REGISTRY=""
local NO_CONTAINER_UPDATE="false"
local CONTAINER_SHELL="false"

if ! $NATIVE_BUILD
then
if [[ "$(basename "$CONTAINER_BACKEND")" == "docker" ]] && "$CONTAINER_BACKEND" -h | grep -q podman
then
echo "'$CONTAINER_BACKEND' backend is selected, but the functionality is actually provided by 'podman' backend. Updating accordingly..."
CONTAINER_BACKEND="$(command -v podman)"
fi

local CONTAINER_IMAGE="$($CONTAINER_BACKEND image ls "-qf=reference=${CONTAINER_REGISTRY}rknn2:master")"
local CONTAINER_EXIT_CODE=0

if ! $NO_CONTAINER_UPDATE
then
if [[ -z $CONTAINER_REGISTRY ]]
then
$CONTAINER_BACKEND build --force-rm -t "${CONTAINER_REGISTRY}rknn2:master" "$SCRIPT_DIR"
else
$CONTAINER_BACKEND pull "${CONTAINER_REGISTRY}rknn2:master"
fi
fi

if [[ $CONTAINER_IMAGE != "$($CONTAINER_BACKEND image ls "-qf=reference=${CONTAINER_REGISTRY}rknn2:master")" ]]
then
$CONTAINER_BACKEND container rm rknn2 &>/dev/null || true
$CONTAINER_BACKEND image rm "${CONTAINER_REGISTRY}rknn2:builder" &>/dev/null || true
fi

CONTAINER_BUILDER="$($CONTAINER_BACKEND image ls "-qf=reference=${CONTAINER_REGISTRY}rknn2:builder")"
if [[ -z $CONTAINER_BUILDER ]]
then
$CONTAINER_BACKEND tag "${CONTAINER_REGISTRY}rknn2:master" "${CONTAINER_REGISTRY}rknn2:builder"
fi

CONTAINER_OPTIONS=( "--name" "rknn2" )
CONTAINER_OPTIONS+=( "--workdir" "$PWD" )
CONTAINER_OPTIONS+=( "--mount" "type=bind,source=$PWD,destination=$PWD" )
CONTAINER_OPTIONS+=( "--mount" "type=bind,source=$(realpath $SCRIPT_DIR/../../..),destination=$(realpath $SCRIPT_DIR/../../..)" )
if [[ -t 0 ]]
then
CONTAINER_OPTIONS+=( "-it" )
fi
if [[ "$PWD" != "$SCRIPT_DIR" ]]
then
CONTAINER_OPTIONS+=( "--mount" "type=bind,source=$SCRIPT_DIR,destination=$SCRIPT_DIR" )
fi
$CONTAINER_BACKEND container kill rknn2 &>/dev/null || true
$CONTAINER_BACKEND container rm rknn2 &>/dev/null || true
if [[ "$(basename "$CONTAINER_BACKEND")" == "podman" ]]
then
CONTAINER_OPTIONS+=( "--user" "root" )
if $CONTAINER_SHELL
then
if ! $CONTAINER_BACKEND run "${CONTAINER_OPTIONS[@]}" "${CONTAINER_REGISTRY}rknn2:builder" bash
then
CONTAINER_EXIT_CODE="$($CONTAINER_BACKEND inspect rknn2 --format='{{.State.ExitCode}}')"
fi
else
if ! $CONTAINER_BACKEND run "${CONTAINER_OPTIONS[@]}" "${CONTAINER_REGISTRY}rknn2:builder" make deb
then
CONTAINER_EXIT_CODE="$($CONTAINER_BACKEND inspect rknn2 --format='{{.State.ExitCode}}')"
fi
$CONTAINER_BACKEND container rm rknn2
fi
else
local CONTAINER_SUDO="sed -i -E \"s/^(runner):(x?):([0-9]+):([0-9]+):(.*):(.*):(.*)$/\1:\2:$(id -u):$(id -g):\5:\6:\7/\" /etc/passwd && sudo -u runner"
if $CONTAINER_SHELL
then
if ! $CONTAINER_BACKEND run "${CONTAINER_OPTIONS[@]}" "${CONTAINER_REGISTRY}rknn2:builder" bash -c "$CONTAINER_SUDO -i"
then
CONTAINER_EXIT_CODE="$($CONTAINER_BACKEND inspect rknn2 --format='{{.State.ExitCode}}')"
fi
else
if ! $CONTAINER_BACKEND run "${CONTAINER_OPTIONS[@]}" "${CONTAINER_REGISTRY}rknn2:builder" bash -c "$CONTAINER_SUDO make deb"
then
CONTAINER_EXIT_CODE="$($CONTAINER_BACKEND inspect rknn2 --format='{{.State.ExitCode}}')"
fi
$CONTAINER_BACKEND container rm rknn2
fi
fi
return $CONTAINER_EXIT_CODE
fi
}

build
9 changes: 9 additions & 0 deletions debian/.gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
/.debhelper
/debhelper-build-stamp
/files
/rknpu2-*/
/python3-rknnlite2/
/*.debhelper.log
/*.postrm.debhelper
/*.substvars
/tmp/
5 changes: 5 additions & 0 deletions debian/changelog
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
rknn2 (1.4.0-1) stable; urgency=medium

* Initial release

-- "Radxa Computer Co., Ltd" <dev@radxa.com> Thu, 07 Sep 2023 20:41:16 +0800
1 change: 1 addition & 0 deletions debian/compat
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
12
Loading

0 comments on commit 8b4ae0e

Please sign in to comment.