From 41f61aa419aaaa3d534bed2f5aa7e8e48761a8e7 Mon Sep 17 00:00:00 2001 From: Mark Pashmfouroush Date: Tue, 26 Nov 2024 02:03:06 +0000 Subject: [PATCH] test Signed-off-by: Mark Pashmfouroush --- .github/workflows/build-firmware.yaml | 47 ++++----------------------- src/build.bash | 27 ++++++++------- 2 files changed, 19 insertions(+), 55 deletions(-) diff --git a/.github/workflows/build-firmware.yaml b/.github/workflows/build-firmware.yaml index 0cff712..a8a546a 100644 --- a/.github/workflows/build-firmware.yaml +++ b/.github/workflows/build-firmware.yaml @@ -2,7 +2,8 @@ name: Build the Neighbor Link Firmware on: push: - branches: [main] + release: + types: [published] jobs: build: @@ -14,12 +15,6 @@ jobs: - 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 @@ -31,49 +26,19 @@ jobs: - 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} + 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 }} + tag: ${{ github.ref }} file_glob: true diff --git a/src/build.bash b/src/build.bash index 6f8e740..a9f9bd1 100644 --- a/src/build.bash +++ b/src/build.bash @@ -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. @@ -43,34 +42,34 @@ for target in "${target_info[@]}"; do IFS=' ' read -r profile cpu_arch chipset device_model <<< "$target" 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 + 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-|$device_model-$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" ) @@ -78,7 +77,7 @@ for target in "${target_info[@]}"; do fi done - + cd ../ done \ No newline at end of file