Skip to content

Commit

Permalink
add github action
Browse files Browse the repository at this point in the history
  • Loading branch information
luochongjun committed Apr 24, 2022
1 parent 6da75ba commit 34d92af
Show file tree
Hide file tree
Showing 2 changed files with 240 additions and 0 deletions.
150 changes: 150 additions & 0 deletions .github/workflows/build-release.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,150 @@
name: Build and Release

on:
push:
tags:
- "*"

jobs:
release:
name: Build for ${{ matrix.arch }}
runs-on: ubuntu-latest
strategy:
fail-fast: false
matrix:
include:
- arch: aarch64_cortex-a53
sdk_url_path: https://downloads.openwrt.org/snapshots/targets/bcm27xx/bcm2710
sdk_name: -sdk-bcm27xx-bcm2710_
- arch: aarch64_cortex-a72
sdk_url_path: https://downloads.openwrt.org/snapshots/targets/mvebu/cortexa72
sdk_name: -sdk-mvebu-cortexa72_
- arch: aarch64_generic
sdk_url_path: http://downloads.openwrt.org/snapshots/targets/layerscape/armv8_64b
sdk_name: -sdk-layerscape-armv8_64b_
- arch: arm_arm1176jzf-s_vfp
sdk_url_path: https://downloads.openwrt.org/snapshots/targets/bcm27xx/bcm2708
sdk_name: -sdk-bcm27xx-bcm2708_
- arch: arm_arm926ej-s
sdk_url_path: https://downloads.openwrt.org/snapshots/targets/at91/legacy
sdk_name: -sdk-at91-legacy_
- arch: arm_cortex-a15_neon-vfpv4
sdk_url_path: https://downloads.openwrt.org/snapshots/targets/ipq806x/generic
sdk_name: -sdk-ipq806x-generic_
- arch: arm_cortex-a5-vfpv4
sdk_url_path: https://downloads.openwrt.org/snapshots/targets/at91/sama5
sdk_name: -sdk-at91-sama5_
- arch: arm_cortex-a7_neon-vfpv4
sdk_url_path: https://downloads.openwrt.org/snapshots/targets/bcm27xx/bcm2709
sdk_name: -sdk-bcm27xx-bcm2709_
- arch: arm_cortex-a8_vfpv3
sdk_url_path: https://downloads.openwrt.org/snapshots/targets/sunxi/cortexa8
sdk_name: -sdk-sunxi-cortexa8_
- arch: arm_cortex-a9
sdk_url_path: https://downloads.openwrt.org/snapshots/targets/bcm53xx/generic
sdk_name: -sdk-bcm53xx-generic_
- arch: arm_cortex-a9_neon
sdk_url_path: https://downloads.openwrt.org/snapshots/targets/imx6/generic
sdk_name: -sdk-imx6_
- arch: arm_cortex-a9_vfpv3
sdk_url_path: https://downloads.openwrt.org/releases/19.07.2/targets/mvebu/cortexa9
sdk_name: -sdk-19.07.2-mvebu-cortexa9_
- arch: arm_cortex-a9_vfpv3-d16
sdk_url_path: https://downloads.openwrt.org/snapshots/targets/mvebu/cortexa9
sdk_name: -sdk-mvebu-cortexa9_
- arch: arm_fa526
sdk_url_path: https://downloads.openwrt.org/snapshots/targets/gemini/generic
sdk_name: -sdk-gemini_
- arch: arm_mpcore
sdk_url_path: https://downloads.openwrt.org/snapshots/targets/oxnas/ox820
sdk_name: -sdk-oxnas-ox820_
- arch: arm_mpcore_vfp
sdk_url_path: https://downloads.openwrt.org/snapshots/targets/cns3xxx/generic
sdk_name: -sdk-cns3xxx_
- arch: arm_xscale
sdk_url_path: https://downloads.openwrt.org/snapshots/targets/kirkwood/generic
sdk_name: -sdk-kirkwood_
- arch: i386_pentium
sdk_url_path: https://downloads.openwrt.org/snapshots/targets/x86/legacy
sdk_name: -sdk-x86-legacy_
- arch: i386_pentium4
sdk_url_path: https://downloads.openwrt.org/snapshots/targets/x86/generic
sdk_name: -sdk-x86-generic_
- arch: mips64_octeon
sdk_url_path: http://downloads.openwrt.org/releases/18.06.5/targets/octeon/generic
sdk_name: -sdk-18.06.5-octeon_
- arch: mips64_octeonplus
sdk_url_path: https://downloads.openwrt.org/snapshots/targets/octeon/generic
sdk_name: -sdk-octeon_
- arch: mipsel_24kc
sdk_url_path: https://downloads.openwrt.org/snapshots/targets/ramips/mt7620
sdk_name: -sdk-ramips-mt7620_
- arch: mipsel_24kc_24kf
sdk_url_path: https://downloads.openwrt.org/snapshots/targets/pistachio/generic
sdk_name: -sdk-pistachio_
- arch: mipsel_74kc
sdk_url_path: https://downloads.openwrt.org/snapshots/targets/bcm47xx/mips74k
sdk_name: -sdk-bcm47xx-mips74k_
- arch: mipsel_mips32
sdk_url_path: https://downloads.openwrt.org/snapshots/targets/bcm47xx/generic
sdk_name: -sdk-bcm47xx-generic_
- arch: mips_24kc
sdk_url_path: https://downloads.openwrt.org/snapshots/targets/ath79/generic
sdk_name: -sdk-ath79-generic_
- arch: mips_mips32
sdk_url_path: https://downloads.openwrt.org/snapshots/targets/bcm63xx/generic
sdk_name: -sdk-bcm63xx-generic_
- arch: x86_64
sdk_url_path: https://downloads.openwrt.org/snapshots/targets/x86/64
sdk_name: -sdk-x86-64_
# - arch: arc_arc700
# sdk_url_path: https://downloads.openwrt.org/snapshots/targets/arc770/generic
# sdk_name: -sdk-arc770-generic_
# - arch: arc_archs
# sdk_url_path: https://downloads.openwrt.org/snapshots/targets/archs38/generic
# sdk_name: -sdk-archs38-generic_
# - arch: armeb_xscale
# sdk_url_path: https://downloads.openwrt.org/snapshots/targets/ixp4xx/generic
# sdk_name: -sdk-ixp4xx-generic_
# - arch: powerpc_464fp
# sdk_url_path: https://downloads.openwrt.org/snapshots/targets/apm821xx/nand
# sdk_name: -sdk-apm821xx-nand_
# - arch: powerpc_8540
# sdk_url_path: https://downloads.openwrt.org/snapshots/targets/mpc85xx/generic
# sdk_name: -sdk-mpc85xx-generic_

env:
SDK_URL_PATH: ${{ matrix.sdk_url_path }}
SDK_NAME: ${{ matrix.sdk_name }}
ARCH: ${{ matrix.arch }}
CACHE_DIR: ~/cache
steps:
- name: Checkout
uses: actions/checkout@v2

- name: Setup Cache
uses: actions/cache@v2
with:
path: ${{ env.CACHE_DIR }}
key: ${{ runner.os }}:luci-app-store:${{ env.ARCH }}:release:cache:${{ github.run_number }}
restore-keys: |
${{ runner.os }}:luci-app-store:${{ env.ARCH }}:cache:
- name: Install Dependencies
run: |
sudo apt-get update && \
sudo apt-get install -yq gettext libncurses5-dev xsltproc
- name: Prepare SDK Home
run: |
echo "SDK_HOME=$(mktemp -d)" >> $GITHUB_ENV
- name: Build package
run: sh compile.sh

- name: Release and Upload Assets
uses: softprops/action-gh-release@v1
with:
files: "*.ipk"
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
90 changes: 90 additions & 0 deletions compile.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,90 @@
#!/bin/sh -e
#
# Copyright (C) 2021 luochongjun
#

dir="$(cd "$(dirname "$0")" ; pwd)"

package_name="luci-app-store"

cache_dir=${CACHE_DIR:-"~/cache"}

sdk_url_path=${SDK_URL_PATH:-"https://downloads.openwrt.org/snapshots/targets/x86/64"}
sdk_name=${SDK_NAME:-"-sdk-x86-64_"}

sdk_home=${SDK_HOME:-"~/sdk"}

sdk_home_dir="$(eval echo "$sdk_home")"

test -d "$sdk_home_dir" || mkdir -p "$sdk_home_dir"

sdk_dir="$(eval echo "$cache_dir/sdk")"
dl_dir="$(eval echo "$cache_dir/dl")"
feeds_dir="$(eval echo "$cache_dir/feeds")"

test -d "$sdk_dir" || mkdir -p "$sdk_dir"
test -d "$dl_dir" || mkdir -p "$dl_dir"
test -d "$feeds_dir" || mkdir -p "$feeds_dir"

cd "$sdk_dir"

if ! ( wget -q -O - "$sdk_url_path/sha256sums" | \
grep -- "$sdk_name" > sha256sums.small 2>/dev/null ) ; then
echo "Can not find ${sdk_name} file in sha256sums."
exit 1
fi

sdk_file="$(cut -d' ' -f2 < sha256sums.small | sed 's/*//g')"

if ! sha256sum -c ./sha256sums.small >/dev/null 2>&1 ; then
wget -q -O "$sdk_file" "$sdk_url_path/$sdk_file"

if ! sha256sum -c ./sha256sums.small >/dev/null 2>&1 ; then
echo "SDK can not be verified!"
exit 1
fi
fi

cd "$dir"

file "$sdk_dir/$sdk_file"
tar -Jxf "$sdk_dir/$sdk_file" -C "$sdk_home_dir" --strip=1

cd "$sdk_home_dir"

( test -d "dl" && rm -rf "dl" ) || true
( test -d "feeds" && rm -rf "feeds" ) || true

ln -sf "$dl_dir" "dl"
ln -sf "$feeds_dir" "feeds"

cp -f feeds.conf.default feeds.conf

# use github repositories
sed -i \
-e 's#git.openwrt.org/openwrt/openwrt#github.com/openwrt/openwrt#' \
-e 's#git.openwrt.org/feed/packages#github.com/openwrt/packages#' \
-e 's#git.openwrt.org/project/luci#github.com/openwrt/luci#' \
-e 's#git.openwrt.org/feed/telephony#github.com/openwrt/telephony#' \
feeds.conf

./scripts/feeds update -a

( test -d "feeds/packages/net/$package_name" && \
rm -rf "feeds/packages/net/$package_name" ) || true


ln -sf "$dir" "package/$package_name"

./scripts/feeds install -a

make defconfig

make package/${package_name}/clean
make package/${package_name}/compile V=s

cd "$dir"

find "$sdk_home_dir/bin/" -type f -exec ls -lh {} \;

find "$sdk_home_dir/bin/" -type f -name "${package_name}*.ipk" -exec cp -f {} "$dir" \;

0 comments on commit 34d92af

Please sign in to comment.