Skip to content

Commit

Permalink
test
Browse files Browse the repository at this point in the history
Signed-off-by: Mark Pashmfouroush <[email protected]>
  • Loading branch information
markpash committed Nov 26, 2024
1 parent 7ba08f6 commit c4d4bab
Show file tree
Hide file tree
Showing 2 changed files with 51 additions and 68 deletions.
60 changes: 17 additions & 43 deletions .github/workflows/build-firmware.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -2,78 +2,52 @@ name: Build the Neighbor Link Firmware

on:
push:
branches: [main]
release:
types: [published]

jobs:
build:
runs-on: ubuntu-22.04
permissions:
contents: write
strategy:
fail-fast: false
matrix:
profile:
- "tplink_archer-c7-v5"
- "tplink_archer-c7-v2"
- "tplink_archer-a7-v5"
- "glinet_gl-mt300a"
- "tplink_archer-ax23-v1"

steps:
- name: Checkout Code
uses: actions/checkout@v4

- name: Source Release Version
run: |
source RELEASE_VERSION
echo "release_version=$release_version"
echo "release_version=$release_version" >> $GITHUB_ENV
- name: Set up Build Environment
run: |
sudo apt-get update -y
sudo apt-get install -y \
curl build-essential libncurses-dev zlib1g-dev \
gawk git gettext libssl-dev xsltproc rsync wget unzip \
gawk git gettext libssl-dev xsltproc rsync unzip \
python3 python3-distutils jq
- name: Build the Firmware
run: |
cd src
bash build.bash ${{ env.release_version }}
echo "release_version=$release_version" >> build/RELEASE_VERSION
bash build.bash ${GITHUB_SHA::6} ${{ matrix.profile }}
echo "release_version=${GITHUB_SHA::6}" >> build/RELEASE_VERSION
- name: Upload Build Artifacts as a Single Artifact
uses: actions/upload-artifact@v4
with:
name: build-artifacts
path: src/build/*

release:
runs-on: ubuntu-22.04
needs: build

steps:
- name: Download Build Artifacts
uses: actions/download-artifact@v4
with:
name: build-artifacts
path: artifacts

- name: Source Release Version
run: |
source artifacts/RELEASE_VERSION
echo "release_version=$release_version"
echo "release_version=$release_version" >> $GITHUB_ENV
- name: Create Release
id: create_release
uses: actions/create-release@v1
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
with:
tag_name: v${{ env.release_version }}
release_name: Neighbor-Link v${{ env.release_version }}
draft: false
prerelease: false
body: |
This is a release for the Neighbor Link Firmware.
- name: Attach Artifacts to Release
uses: svenstaro/upload-release-action@v2
if: github.event_name == 'release'
with:
repo_token: ${{ secrets.GITHUB_TOKEN }}
file: artifacts/*
tag: v${{ env.release_version }}
file: src/build/*
tag: ${{ github.ref }}
file_glob: true
59 changes: 34 additions & 25 deletions src/build.bash
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@

#!/bin/bash
#!/usr/bin/env bash

# This script is designed to run on Ubuntu systems with AMD64 architecture.
# Please ensure you are running this script on a compatible system.
Expand All @@ -10,13 +9,18 @@ set -e
wrt_version="23.05.2"

#Target Device
# Profile Arch Chip Model
target_info=( "tplink_archer-c7-v5 ath79 generic tp-link_archer_c7_v5" \
"tplink_archer-c7-v2 ath79 generic tp-link_archer_c7_v2" \
"tplink_archer-a7-v5 ath79 generic tp-link_archer_a7_v5" \
"glinet_gl-mt300a ramips mt7620 gl-mt300a" \
"tplink_archer-ax23-v1 ramips mt7621 tp-link_archer-ax23-v1"
)
# Profile Arch Chip
targets=( "tplink_archer-c7-v5 ath79 generic" \
"tplink_archer-c7-v2 ath79 generic" \
"tplink_archer-a7-v5 ath79 generic" \
"glinet_gl-mt300a ramips mt7620" \
"tplink_archer-ax23-v1 ramips mt7621"
)

declare -A target_info
for entry in "${targets[@]}"; do
target_info["$(echo "$entry" | awk '{print $1}')"]="$(echo "$entry" | cut -d' ' -f2-)"
done

# Excluded packages
EXCLUDE_PACKAGES='-dnsmasq -wpad-basic-mbedtls'
Expand All @@ -37,48 +41,53 @@ else
release_version="0.0.0"
fi

if [ -n "$2" ]; then
profiles=$2
else
profiles="${!target_info[*]}"
fi

for target in "${target_info[@]}"; do
for profile in $profiles; do

IFS=' ' read -r profile cpu_arch chipset device_model <<< "$target"
IFS=' ' read -r cpu_arch chipset <<< "${target_info[$profile]}"

PATH_PART="$wrt_version-$cpu_arch-$chipset"

download_url="https://archive.openwrt.org/releases/$wrt_version/targets/$cpu_arch/$chipset/openwrt-imagebuilder-$PATH_PART.Linux-x86_64.tar.xz"

rm -rf openwrt-imagebuilder-*
wget $download_url
tar -J -x -f openwrt-imagebuilder-$PATH_PART.Linux-x86_64.tar.xz 2>/dev/null > /dev/null
curl -fsSL "$download_url" -O
tar -J -x -f openwrt-imagebuilder-"$PATH_PART".Linux-x86_64.tar.xz 2>/dev/null > /dev/null

sed -i "s/option version .*/option version '$release_version'/" "files/etc/config/routro"
IMAGEBUILDER_REPO="openwrt-imagebuilder-$PATH_PART.Linux-x86_64"
cd $IMAGEBUILDER_REPO
cd "$IMAGEBUILDER_REPO"

TEXT_FILE=../$BUILD_DIR/version-$device_model.txt
echo "new_version=$release_version" > $TEXT_FILE
TEXT_FILE=../$BUILD_DIR/version-$profile.txt
echo "new_version=$release_version" > "$TEXT_FILE"

#Make the images
make image PROFILE=$profile PACKAGES="$INCLUDE_PACKAGES $EXCLUDE_PACKAGES" FILES=$FILES
make image PROFILE="$profile" PACKAGES="$INCLUDE_PACKAGES $EXCLUDE_PACKAGES" FILES=$FILES

dest_of_bin="bin/targets/$arch/$chip/"
dest_of_bin="bin/targets/$cpu_arch/$chipset/"

# Loop over the files with .bin extension in the bin/ directory
for file in $(find $dest_of_bin -type f -name "*.bin"); do
for file in $(find "$dest_of_bin" -type f -name "*.bin"); do

newname=$(echo "$file" | sed " s|openwrt-$PATH_PART-$profile-|$profile-$release_version-| " )

newname=$(echo $file | sed " s|openwrt-$PATH_PART-$profile-|$device_model-$release_version-| " )

newfile=../$BUILD_DIR/$(basename "$newname")
echo "$newfile:"
# Rename the file
mv "$file" $newfile
mv "$file" "$newfile"

if [[ "$file" == *"sysupgrade"* ]];then
filename=$(basename "$newname" )
echo "firmwareUrl=https://github.com/nasnet-community/neighbor-link/blob/0f2001dd371d02357248beb61ec9a812d82a743a/builds/$filename" >> $TEXT_FILE
echo "firmwareUrl=https://github.com/nasnet-community/neighbor-link/blob/0f2001dd371d02357248beb61ec9a812d82a743a/builds/$filename" >> "$TEXT_FILE"
fi

done

cd ../

done

0 comments on commit c4d4bab

Please sign in to comment.