feat routing balancer #18
Workflow file for this run
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: Package Build and Release | |
on: | |
push: | |
tags: | |
- '*' | |
env: | |
PACKAGE_NAME: luci-app-xray | |
CACHE_DIR: ~/cache | |
jobs: | |
push-and-build: | |
runs-on: ubuntu-20.04 | |
env: | |
SDK_URL_PATH: https://downloads.openwrt.org/releases/21.02.7/targets/x86/64 | |
SDK_NAME: -sdk-21.02.7-x86-64_ | |
CONFIG_CCACHE: y | |
ACTIONS_ALLOW_UNSECURE_COMMANDS: true | |
steps: | |
- name: Checkout | |
uses: actions/checkout@v3 | |
with: | |
persist-credentials: false | |
fetch-depth: 2 | |
- name: Setup Node.js | |
uses: actions/setup-node@v3 | |
with: | |
node-version: '16' | |
- name: Setup Node.js Cache | |
uses: actions/cache@v3 | |
with: | |
path: node_modules | |
key: node-${{ env.PACKAGE_NAME }}-${{ hashFiles('yarn.lock') }} | |
restore-keys: | | |
node-${{ env.PACKAGE_NAME }}- | |
- name: Test Source | |
run: | | |
yarn install | |
yarn lint | |
- name: Build Package Source | |
run: | | |
yarn install | |
yarn package | |
- name: Deploy Package Source | |
uses: peaceiris/actions-gh-pages@v3 | |
with: | |
github_token: ${{ secrets.GITHUB_TOKEN }} | |
publish_dir: ./package | |
publish_branch: luci2 | |
user_name: 'github-actions[bot]' | |
user_email: 'github-actions[bot]@users.noreply.github.com' | |
commit_message: ${{ github.event.head_commit.message }} | |
- name: Prepare Cache Key | |
id: cache_key | |
run: echo "timestamp=$(date +"%s")" >> $GITHUB_OUTPUT | |
- name: Setup OpenWrt Cache | |
uses: actions/cache@v3 | |
with: | |
path: ${{ env.CACHE_DIR }} | |
key: openwrt-${{ env.PACKAGE_NAME }}-${{ steps.cache_key.outputs.timestamp }} | |
restore-keys: | | |
openwrt-${{ env.PACKAGE_NAME }}- | |
- name: Set up Python 3.9.16 | |
uses: actions/setup-python@v4 | |
with: | |
python-version: 3.9.16 | |
- name: Install Dependencies | |
run: | | |
DEBIAN_FRONTEND=noninteractive \ | |
sudo apt-get install -y ccache gettext libncurses5-dev xsltproc gcc g++ | |
- name: Create Directories | |
run: | | |
CACHE_DIR_SDK="$(eval echo "$CACHE_DIR/sdk")" | |
CACHE_DIR_DL="$(eval echo "$CACHE_DIR/dl")" | |
CACHE_DIR_FEEDS="$(eval echo "$CACHE_DIR/feeds")" | |
CCACHE_DIR_HOST="$(eval echo "$CACHE_DIR/ccache/host")" | |
CCACHE_DIR_TARGET="$(eval echo "$CACHE_DIR/ccache/target")" | |
CCACHE_DIR_TOOLCHAIN="$(eval echo "$CACHE_DIR/ccache/toolchain")" | |
test -d "$CACHE_DIR_SDK" || mkdir -p "$CACHE_DIR_SDK" | |
test -d "$CACHE_DIR_DL" || mkdir -p "$CACHE_DIR_DL" | |
test -d "$CACHE_DIR_FEEDS" || mkdir -p "$CACHE_DIR_FEEDS" | |
test -d "$CCACHE_DIR_HOST" || mkdir -p "$CCACHE_DIR_HOST" | |
test -d "$CCACHE_DIR_TARGET" || mkdir -p "$CCACHE_DIR_TARGET" | |
test -d "$CCACHE_DIR_TOOLCHAIN" || mkdir -p "$CCACHE_DIR_TOOLCHAIN" | |
echo "::set-env name=CACHE_DIR_SDK::$CACHE_DIR_SDK" | |
echo "::set-env name=CACHE_DIR_DL::$CACHE_DIR_DL" | |
echo "::set-env name=CACHE_DIR_FEEDS::$CACHE_DIR_FEEDS" | |
echo "::set-env name=CCACHE_DIR_HOST::$CCACHE_DIR_HOST" | |
echo "::set-env name=CCACHE_DIR_TARGET::$CCACHE_DIR_TARGET" | |
echo "::set-env name=CCACHE_DIR_TOOLCHAIN::$CCACHE_DIR_TOOLCHAIN" | |
echo "::set-env name=SDK_HOME::$(mktemp -d)" | |
- name: Download and Unzip SDK | |
run: | | |
cd "$CACHE_DIR_SDK" | |
if ! ( wget -q -O - "$SDK_URL_PATH/sha256sums" | \ | |
grep -- "$SDK_NAME" > sha256sums.small 2>/dev/null ) ; then | |
echo "::error::Can not find ${SDK_NAME} file in sha256sums." | |
exit 1 | |
fi | |
SDK_FILE="$(cat sha256sums.small | cut -d' ' -f2 | 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 "::error::SDK can not be verified!" | |
exit 1 | |
fi | |
fi | |
cd - | |
file "$CACHE_DIR_SDK/$SDK_FILE" | |
tar -Jxf "$CACHE_DIR_SDK/$SDK_FILE" -C "$SDK_HOME" --strip=1 | |
cd "$SDK_HOME" | |
cp feeds.conf.default feeds.conf | |
sed -i 's#git.openwrt.org/openwrt/openwrt#github.com/openwrt/openwrt#' feeds.conf | |
sed -i 's#git.openwrt.org/feed/packages#github.com/openwrt/packages#' feeds.conf | |
sed -i 's#git.openwrt.org/project/luci#github.com/openwrt/luci#' feeds.conf | |
sed -i 's#git.openwrt.org/feed/telephony#github.com/openwrt/telephony#' feeds.conf | |
cd - | |
- name: Restore OpenWrt Cache | |
run: | | |
cd "$SDK_HOME" | |
test -d "dl" && rm -rf "dl" || true | |
test -d "feeds" && rm -rf "feeds" || true | |
ln -s "$CACHE_DIR_DL" "dl" | |
ln -s "$CACHE_DIR_FEEDS" "feeds" | |
staging_dir_host="staging_dir/host" | |
staging_dir_target="staging_dir/target-x86_64_musl" | |
staging_dir_toolchain="$(eval echo "staging_dir/toolchain-*")" | |
test -d "$staging_dir_host" || mkdir -p "$staging_dir_host" | |
test -d "$staging_dir_target" || mkdir -p "$staging_dir_target" | |
test -d "$staging_dir_toolchain" || mkdir -p "$staging_dir_toolchain" | |
ln -s "$CCACHE_DIR_HOST" "$staging_dir_host/ccache" | |
ln -s "$CCACHE_DIR_TARGET" "$staging_dir_target/ccache" | |
ln -s "$CCACHE_DIR_TOOLCHAIN" "$staging_dir_toolchain/ccache" | |
CCACHE_DIR="$staging_dir_host/ccache" staging_dir/host/bin/ccache -s | |
CCACHE_DIR="$staging_dir_target/ccache" staging_dir/host/bin/ccache -s | |
CCACHE_DIR="$staging_dir_toolchain/ccache" staging_dir/host/bin/ccache -s | |
cd - | |
- name: Update and Install Packages | |
run: | | |
cd "$SDK_HOME" | |
cp -rf "${{ github.workspace }}/package" "package/$PACKAGE_NAME" | |
./scripts/feeds update -a | |
./scripts/feeds install -a | |
cd - | |
- name: Build Package | |
run: | | |
cd "$SDK_HOME" | |
make defconfig | |
make package/${PACKAGE_NAME}/compile V=s | |
find "$SDK_HOME/bin/" -type f -name "*.ipk" -exec ls -lh {} \; | |
cd - | |
- name: Copy Build Results | |
run: | | |
# Copy bin files | |
find "$SDK_HOME/bin/" -type f -name "${PACKAGE_NAME}*.ipk" -exec cp {} "${{ github.workspace }}" \; | |
# Copy translations | |
find "$SDK_HOME/bin/" -type f -name "luci-i18n*.ipk" -exec cp {} "${{ github.workspace }}" \; | |
find "${{ github.workspace }}" -type f -name "*.ipk" -exec ls -lh {} \; | |
- name: Release and Upload Assets | |
uses: softprops/action-gh-release@v1 | |
with: | |
files: '*.ipk' | |
env: | |
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} |