Skip to content

Commit

Permalink
initial fork
Browse files Browse the repository at this point in the history
  • Loading branch information
gretel committed Dec 4, 2024
1 parent 9f25772 commit 6c03392
Show file tree
Hide file tree
Showing 6 changed files with 351 additions and 325 deletions.
114 changes: 114 additions & 0 deletions .github/workflows/package.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,114 @@
name: Build RNS Packages for OpenWrt

on:
push:
branches:
- '*'
tags:
- "[0-9]+.[0-9]+.[0-9]+*"
pull_request:
branches:
- '*'
workflow_dispatch:

permissions:
contents: write
packages: write # needed for cache operations

concurrency:
group: ${{ github.workflow }}-${{ github.ref }}
cancel-in-progress: false

env:
V: ''
PRIVATE_KEY: ${{ secrets.SIGNING_KEY }}
EXTRA_FEEDS: >-
src-git|reticulum|https://github.com/gretel/feed-reticulum.git
PACKAGES: rns lxmf

jobs:
build:
name: ${{ matrix.arch }}-${{ matrix.release }}
runs-on: ubuntu-latest
environment: ${{ startsWith(github.ref, 'refs/tags/') && 'production' || 'development' }}
strategy:
fail-fast: false
matrix:
release:
- master
arch:
- aarch64_cortex-a53 # Modern 64-bit ARM (MT7981, newer RPis)
- arm_arm1176jzf-s_vfp # RPi Zero 1
- mips_24kc # Common in budget routers
- x86_64 # Generic "PC"

steps:
- uses: actions/checkout@v4

- name: Setup QEMU
uses: docker/setup-qemu-action@v3

- name: Setup Buildx
uses: docker/setup-buildx-action@v3
# with:
# buildkitd-flags: --debug

- name: Build SDK container
uses: docker/build-push-action@v6
env:
DOCKER_BUILD_SUMMARY: false
with:
tags: sdk
context: .
push: false
load: true
build-args: |
CONTAINER=ghcr.io/openwrt/sdk
ARCH=${{ matrix.arch }}-${{ matrix.release }}
cache-from: |
type=gha,scope=${{ matrix.arch }}-${{ matrix.release }}
cache-to: |
type=gha,mode=max,scope=${{ matrix.arch }}-${{ matrix.release }}
- name: Prepare artifacts directory
run: |
mkdir -p artifacts
sudo chown -R 1000:1000 artifacts
shell: bash

- name: Build packages
run: |
docker run --rm \
--env EXTRA_FEEDS \
--env IGNORE_ERRORS \
--env INDEX \
--env KEY_BUILD \
--env NO_DEFAULT_FEEDS \
--env PACKAGES \
--env PRIVATE_KEY \
--env V \
-v ${{ github.workspace }}/artifacts:/artifacts \
sdk
- name: Debug output locations
if: always()
run: |
find ${{ github.workspace }}/artifacts/bin | sed -e "s/[^-][^\/]*\// |/g" -e "s/|\([^ ]\)/|-\1/"
- name: Upload artifacts
uses: actions/upload-artifact@v4
with:
name: ${{ matrix.arch }}-${{ matrix.release }}-packages
path: artifacts/bin/**/*.*pk
retention-days: 7
compression-level: 0

- name: Release
uses: softprops/action-gh-release@v2
with:
files: |
artifacts/bin/**/*.*pk
draft: true
generate_release_notes: true
prerelease: ${{ contains(github.ref, '-') }}
fail_on_unmatched_files: true
41 changes: 0 additions & 41 deletions .github/workflows/test.yml

This file was deleted.

13 changes: 8 additions & 5 deletions Dockerfile
Original file line number Diff line number Diff line change
@@ -1,9 +1,12 @@
ARG CONTAINER=ghcr.io/openwrt/sdk
ARG ARCH=mips_24kc
FROM $CONTAINER:$ARCH
ARG ARCH=x86_64

LABEL "com.github.actions.name"="OpenWrt SDK"
FROM ${CONTAINER}:${ARCH}

ADD entrypoint.sh /
LABEL "com.github.actions.name"="OpenWrt Packager"
LABEL "repository"="https://github.com/gretel/openwrt-packager"
LABEL "maintainer"="gretel"

ENTRYPOINT ["/entrypoint.sh"]
COPY entrypoint.sh /entrypoint.sh

ENTRYPOINT ["/entrypoint.sh"]
141 changes: 82 additions & 59 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,72 +1,95 @@
# OpenWrt GitHub Action SDK
# OpenWrt Reticulum Package Builder 📡

GitHub CI action to build packages via SDK using official OpenWrt SDK Docker
containers. This is primary used to test build OpenWrt repositories but can
also be used for downstream projects maintaining their own package
repositories.
GitHub workflow for cross-compiling Reticulum Network Stack (RNS) packages for OpenWrt. Based on [openwrt/gh-action-sdk](https://github.com/openwrt/gh-action-sdk).

## Example usage
> **Note**: This is an experimental project currently under active development. The build process and package structure are still being refined and may change significantly. Not recommended for production use yet!
The following YAML code can be used to build all packages of a repository and
store created `ipk` files as artifacts.
## Features ✨

- Cross-compiles RNS packages for OpenWrt targets
- Uses official OpenWrt SDK containers
- Build artifact collection and release management
- Package signing support
- GitHub Actions cache integration

## Supported Platforms 🎯

This workflow builds `rns` and `lxmf` packages for:

| Architecture | Example Devices |
|--------------|----------------|
| `aarch64_cortex-a53` | GL.iNet MT3000 (Beryl AX), Raspberry Pi 4/Zero 2, MediaTek MT7981/MT7622 |
| `arm_arm1176jzf-s_vfp` | Raspberry Pi Zero (1st gen) |
| `mips_24kc` | GL.iNet AR750S (Slate), GL.iNet AR300M, Most Atheros AR71xx/AR72xx/AR93xx |
| `x86_64` | Generic x86_64 devices, Virtual Machines |

## Usage 🚀

Create a workflow file (e.g. `.github/workflows/build.yml`):

```yaml
name: Test Build
name: Build OpenWrt Packages

on:
push:
branches: [ main ]
tags: ["[0-9]+.[0-9]+.[0-9]+*"]
pull_request:
branches:
- main
workflow_dispatch:

env:
PACKAGES: rns lxmf
EXTRA_FEEDS: >-
src-git|reticulum|https://github.com/gretel/feed-reticulum.git
jobs:
build:
name: ${{ matrix.arch }} build
runs-on: ubuntu-latest
strategy:
matrix:
arch:
- x86_64
- mips_24kc

steps:
- uses: actions/checkout@v2
with:
fetch-depth: 0

- name: Build
uses: openwrt/gh-action-sdk@main
env:
ARCH: ${{ matrix.arch }}

- name: Store packages
uses: actions/upload-artifact@v2
with:
name: ${{ matrix.arch}}-packages
path: bin/packages/${{ matrix.arch }}/packages/*.ipk
# ... rest of workflow configuration
```

## Environmental variables
The action reads a few env variables:
* `ARCH` determines the used OpenWrt SDK Docker container.
E.g. `x86_64` or `x86_64-22.03.2`.
* `ARTIFACTS_DIR` determines where built packages and build logs are saved.
Defaults to the default working directory (`GITHUB_WORKSPACE`).
* `BUILD_LOG` stores build logs in `./logs`.
* `CONTAINER` can set other SDK containers than `openwrt/sdk`.
* `EXTRA_FEEDS` are added to the `feeds.conf`, where `|` are replaced by white
spaces.
* `FEED_DIR` used in the created `feeds.conf` for the current repo. Defaults to
the default working directory (`GITHUB_WORKSPACE`).
* `FEEDNAME` used in the created `feeds.conf` for the current repo. Defaults to
`action`.
* `IGNORE_ERRORS` can ignore failing packages builds.
* `INDEX` makes the action build the package index. Default is 0. Set to 1 to enable.
* `KEY_BUILD` can be a private Signify/`usign` key to sign the packages (ipk) feed.
* `PRIVATE_KEY` can be a private key to sign the packages (apk) feed.
* `NO_DEFAULT_FEEDS` disable adding the default SDK feeds
* `NO_REFRESH_CHECK` disable check if patches need a refresh.
* `NO_SHFMT_CHECK` disable check if init files are formated
* `PACKAGES` (Optional) specify the list of packages (space separated) to be built
* `V` changes the build verbosity level.
## Configuration ⚙️

### Environment Variables

| Variable | Description | Default |
|----------|-------------|---------|
| `PACKAGES` | Space-separated list (`rns lxmf`) | Required |
| `EXTRA_FEEDS` | Feed URL (`src-git\|reticulum\|url`) | Required |
| `V` | Build verbosity ('', 's', 'sc') | '' |
| `PRIVATE_KEY` | Package signing key | - |
| `INDEX` | Generate package index (0/1) | 0 |

### Build Cache

The workflow uses GitHub Actions cache storage to speed up builds:
- Cache is scoped per architecture/release
- Uses max mode for better hit rates
- Persists between workflow runs

## Artifacts 📦

The workflow produces:
- Built packages (`.ipk` format)
- Build logs (if enabled)
- Package index (if enabled)

All artifacts are:
- Collected from `/artifacts` directory
- Uploaded to GitHub Actions artifacts
- Published to GitHub Releases for tagged commits

## Requirements 📋

- GitHub Actions runner with Docker support
- OpenWrt-compatible package source code
- Valid package Makefiles in feed
- Package signing key (optional)

## Credits 🙏

- Mark Qvist - Creator of [Reticulum Network Stack](https://github.com/markqvist/Reticulum)
- OpenWrt team - [SDK action](https://github.com/openwrt/gh-action-sdk)

## License ⚖️

MIT
59 changes: 0 additions & 59 deletions action.yml

This file was deleted.

Loading

0 comments on commit 6c03392

Please sign in to comment.