This is a fork of openwrt/gh-action-sdk.
Differences from upstream:
- ccache support: set
CCACHE: '1'to enable compiler caching across runs via GitHub Actions cache, with configurable size (CCACHE_MAXSIZE) and key prefix (CCACHE_CACHE_PREFIX).- SDK intermediate cache support: set
SDK_CACHE: '1'to cache pruned OpenWrt SDK build and staging intermediates across runs.- Docker layer cache disabled: the SDK wrapper image is built without BuildKit's GitHub Actions cache so repository cache quota can be reserved for ccache and SDK intermediates.
- golang replacement: set
REPLACE_GOLANG: '1'to replace the SDKfeeds/packages/lang/golangpackage with a newer external golang feed before building packages.
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.
This fork intentionally does not cache Docker image layers. The upstream action uses BuildKit's GitHub Actions cache for the small SDK wrapper image, but those cached SDK layers can consume most of a repository's default 10 GB Actions cache quota. Prefer enabling ccache and, when useful, the optional SDK intermediate cache for repeated package builds.
The following YAML code can be used to build all packages of a repository and
store created ipk files as artifacts.
name: Test Build
on:
pull_request:
branches:
- main
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: mywrt/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/*.ipkThe action reads a few env variables:
ARCHdetermines the used OpenWrt SDK Docker container. E.g.x86_64orx86_64-22.03.2.ARTIFACTS_DIRdetermines where built packages and build logs are saved. Defaults to the default working directory (GITHUB_WORKSPACE).BUILD_LOGstores build logs in./logs.CCACHEenables ccache when set to1. The action restores and saves a GitHub Actions cache for the selected SDK container and architecture.CCACHE_CACHE_PREFIXoverrides the GitHub Actions cache key prefix used for ccache. Defaults to the runner OS, SDK container, and architecture.CCACHE_DIRsets the host-side ccache directory cached by GitHub Actions. Defaults to$GITHUB_WORKSPACE/.ccacheand is mounted as/ccachein the SDK container.CCACHE_MAXSIZEsets the ccache maximum size. Defaults to1G.CCACHE_COMPILERCHECKandCCACHE_RECACHEare passed through to ccache when ccache is enabled.CONTAINERcan set other SDK containers thanopenwrt/sdk.EXTRA_FEEDSare added to thefeeds.conf, where|are replaced by white spaces.FEED_DIRused in the createdfeeds.conffor the current repo. Defaults to the default working directory (GITHUB_WORKSPACE).FEEDNAMEused in the createdfeeds.conffor the current repo. Defaults toaction.IGNORE_ERRORScan ignore failing packages builds.INDEXmakes the action build the package index. Default is 0. Set to 1 to enable.KEY_BUILDcan be a private Signify/usignkey to sign the packages (ipk) feed.PRIVATE_KEYcan be a private key to sign the packages (apk) feed.NO_DEFAULT_FEEDSdisable adding the default SDK feedsNO_REFRESH_CHECKdisable check if patches need a refresh.NO_SHFMT_CHECKdisable check if init files are formatedPACKAGES(Optional) specify the list of packages (space separated) to be builtREPLACE_GOLANGreplaces the SDKfeeds/packages/lang/golangpackage when set to1. This is useful when packages need a newer Go toolchain than the SDK default.REPLACE_GOLANG_REPOsets the replacement golang repository. Defaults tohttps://github.com/sbwml/packages_lang_golang.REPLACE_GOLANG_BRANCHsets the replacement golang repository branch. Defaults to26.x.REPLACE_GOLANG_COMMIToptionally checks out a specific commit after cloning the replacement golang repository for reproducible builds.SDK_CACHEenables OpenWrt SDK intermediate-file caching when set to1. The action caches prunedbuild_dir/target-*,build_dir/hostpkg,staging_dir/target-*, andstaging_dir/hostpkgentries. It intentionally does not cachedl/,bin/, orlogs/. When enabled, the action also avoidsCONFIG_AUTOREMOVE=yand skips the post-refreshpackage/$PKG/cleanstep so restored package build directories are not immediately deleted.SDK_CACHE_DIRsets the host-side SDK cache directory cached by GitHub Actions. Defaults to$RUNNER_TEMP/openwrt-sdk-cacheand is mounted as/sdk-cachein the SDK container. Keeping this outside the workspace avoids exposing cached SDK build trees through the default/feedmount.SDK_CACHE_PREFIXoverrides the GitHub Actions cache key prefix used for the SDK intermediate cache. Defaults to the runner OS, SDK container, and architecture.Vchanges the build verbosity level.
Example using a newer golang package:
env:
REPLACE_GOLANG: '1'
REPLACE_GOLANG_BRANCH: 26.x