Build OpenWrt for specific target and release #4214
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
name: Build OpenWrt for specific target and release | |
on: | |
workflow_dispatch: | |
push: | |
schedule: | |
- cron: "0 */2 * * *" | |
env: | |
REMOTE_REPOSITORY: qosmio/openwrt-ipq | |
REMOTE_BRANCH: main-nss | |
CONFIG_FILE: ax3600.config | |
CUSTOM_FILES_PATH: files/ | |
RELEASE_PREFIX: main-nss | |
NSS_PACKAGES_REPOSITORY: qosmio/nss-packages | |
NSS_PACKAGES_REPOSITORY_BRANCH: NSS-12.5-K6.x | |
jobs: | |
check_commits: | |
name: Check for new commits | |
runs-on: ubuntu-24.04 | |
outputs: | |
new_commits: ${{ steps.check_commits.outputs.new_commits }} | |
latest_commit_sha: ${{ steps.check_commits.outputs.latest_commit_sha }} | |
nss_packages_repo_new_commits: ${{ steps.check_commits.outputs.nss_packages_repo_new_commits }} | |
nss_packages_repo_latest_commit_sha: ${{ steps.check_commits.outputs.nss_packages_repo_latest_commit_sha }} | |
steps: | |
- name: Check for new commits in both repositories | |
id: check_commits | |
env: | |
GH_TOKEN: ${{ github.token }} | |
run: | | |
# Fetch latest commits and release info | |
latest_sha=$(gh api "repos/${{ env.REMOTE_REPOSITORY }}/commits/${{ env.REMOTE_BRANCH }}" --jq .sha) | |
packages_sha=$(gh api "repos/${{ env.NSS_PACKAGES_REPOSITORY }}/commits/${{ env.NSS_PACKAGES_REPOSITORY_BRANCH }}" --jq .sha) | |
# Try to get release body, handle case where it might not exist | |
release_body=$(gh api "repos/${{ github.repository }}/releases/latest" --jq .body || echo "") | |
# Debug output | |
echo "Latest upstream commit: $latest_sha" | |
echo "Latest packages commit: $packages_sha" | |
if [ -n "$release_body" ]; then | |
echo "Release body contains latest base commit: $(echo "$release_body" | grep -q "$latest_sha" && echo "Yes" || echo "No")" | |
echo "Release body contains latest packages commit: $(echo "$release_body" | grep -q "$packages_sha" && echo "Yes" || echo "No")" | |
else | |
echo "No previous release body found" | |
fi | |
# Set outputs - proceed if release body is empty | |
{ | |
echo "latest_commit_sha=$latest_sha" | |
echo "nss_packages_repo_latest_commit_sha=$packages_sha" | |
echo "new_commits=true" | |
echo "nss_packages_repo_new_commits=true" | |
if [ -n "$release_body" ]; then | |
echo "new_commits=$(if [[ "$release_body" != *"$latest_sha"* ]]; then echo true; else echo false; fi)" | |
echo "nss_packages_repo_new_commits=$(if [[ "$release_body" != *"$packages_sha"* ]]; then echo true; else echo false; fi)" | |
fi | |
} >> "$GITHUB_OUTPUT" | |
build: | |
name: Build OpenWrt | |
needs: check_commits | |
if: github.event_name == 'workflow_dispatch' || needs.check_commits.outputs.new_commits == 'true' || needs.check_commits.outputs.nss_packages_repo_new_commits == 'true' | |
runs-on: ubuntu-24.04 | |
steps: | |
- name: Install dependencies | |
run: | | |
sudo apt update | |
sudo apt install -y \ | |
build-essential clang flex bison g++ gawk \ | |
gcc-multilib g++-multilib gettext git libncurses5-dev libssl-dev \ | |
python3-setuptools rsync swig unzip zlib1g-dev file wget | |
sudo apt full-upgrade -y | |
- name: Checkout remote repository | |
uses: actions/checkout@v4 | |
with: | |
repository: ${{ env.REMOTE_REPOSITORY }} | |
ref: ${{ env.REMOTE_BRANCH }} | |
- name: Checkout current repository | |
uses: actions/checkout@v4 | |
with: | |
path: "custom_repo" | |
- name: Update and install feeds | |
run: | | |
./scripts/feeds update -a | |
./scripts/feeds install -a | |
- name: Configure firmware image | |
run: | | |
mv custom_repo/${{ env.CONFIG_FILE }} .config | |
make defconfig -j$(nproc) | |
- name: Include custom files | |
run: | | |
mkdir -p ${{ env.CUSTOM_FILES_PATH }} | |
mv custom_repo/${{ env.CUSTOM_FILES_PATH }}* ${{ env.CUSTOM_FILES_PATH }} | |
- name: Download dependencies | |
run: make download V=s -j$(nproc) | |
- name: Build the firmware image | |
run: make world V=s -j$(nproc) | |
- name: Upload artifacts | |
uses: actions/upload-artifact@v4 | |
with: | |
name: ipq807x-images | |
path: bin/targets/qualcommax/ipq807x | |
release: | |
name: Create release | |
needs: [check_commits, build] | |
if: needs.build.result == 'success' | |
runs-on: ubuntu-24.04 | |
steps: | |
- name: Download artifacts | |
uses: actions/download-artifact@v4 | |
with: | |
name: ipq807x-images | |
path: firmware | |
- name: Display structure of downloaded files | |
run: ls -R | |
- name: Get current date | |
run: echo "RELEASE_DATE=$(date +%F)" >> $GITHUB_ENV | |
- name: Create release | |
uses: softprops/action-gh-release@master | |
with: | |
files: firmware/* | |
tag_name: ${{ env.RELEASE_PREFIX }}-${{ env.RELEASE_DATE }} | |
name: π OpenWrt Build Release ${{ env.RELEASE_DATE }} | |
body: | | |
## π¦ OpenWrt Automated Build Release | |
**Build Date:** ${{ env.RELEASE_DATE }} | |
### π Main Repository | |
**Repository:** [${{ env.REMOTE_REPOSITORY }}](https://github.com/${{ env.REMOTE_REPOSITORY }}) | |
**Branch:** `${{ env.REMOTE_BRANCH }}` | |
**Commit:** `${{ needs.check_commits.outputs.latest_commit_sha }}` | |
### π¦ NSS Packages | |
**Repository:** [${{ env.NSS_PACKAGES_REPOSITORY }}](https://github.com/${{ env.NSS_PACKAGES_REPOSITORY }}) | |
**Branch:** `${{ env.NSS_PACKAGES_REPOSITORY_BRANCH }}` | |
**Commit:** `${{ needs.check_commits.outputs.nss_packages_repo_latest_commit_sha }}` | |
### π Build Information | |
- **Target:** [Xiaomi Mi AIoT Router AX3600](https://openwrt.org/toh/xiaomi/ax3600) | |
- **Configuration:** [`${{ env.CONFIG_FILE }}`](${{ env.CONFIG_FILE }}) | |
### π Notes | |
- Automated build triggered by ${{ github.event_name }} | |
- Previous releases are automatically cleaned up (keeping latest 2) | |
--- | |
_Generated by GitHub Actions π€_ | |
- name: Clean up old releases | |
uses: dev-drprasad/delete-older-releases@master | |
with: | |
keep_latest: 2 | |
delete_tags: true | |
env: | |
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} |