Build and Release #1
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 and Release | |
on: | |
push: | |
tags: | |
- "*" | |
workflow_dispatch: | |
env: | |
PACKAGE_NAME: luci-app-xray | |
CACHE_DIR: ~/cache | |
jobs: | |
release: | |
name: Build for ${{ matrix.arch }} | |
runs-on: ubuntu-latest | |
strategy: | |
fail-fast: false | |
matrix: | |
include: | |
- arch: x86_64 | |
sdk_url_path: https://downloads.openwrt.org/releases/23.05.5/targets/x86/64 | |
sdk_name: -sdk-23.05.5-x86-64_ | |
env: | |
SDK_URL_PATH: ${{ matrix.sdk_url_path }} | |
SDK_NAME: ${{ matrix.sdk_name }} | |
CCACHE_DIR: ~/.ccache | |
CONFIG_CCACHE: y | |
steps: | |
- name: Checkout | |
uses: actions/checkout@v3 | |
- name: Prepare Cache Key | |
id: cache_key | |
run: echo "::set-output name=timestamp::$(date +"%s")" | |
- name: Setup Cache | |
uses: actions/cache@v2 | |
with: | |
path: | | |
${{ env.CACHE_DIR }} | |
${{ env.CCACHE_DIR }} | |
key: openwrt-${{ matrix.arch }}-${{ env.PACKAGE_NAME }}-${{ steps.cache_key.outputs.timestamp }} | |
restore-keys: | | |
openwrt-${{ matrix.arch }}-${{ env.PACKAGE_NAME }}- | |
- name: Install Dependencies | |
run: | | |
DEBIAN_FRONTEND=noninteractive sudo apt-get install -y ccache gettext libncurses5-dev xsltproc | |
- 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")" | |
echo "CACHE_DIR_SDK: $CACHE_DIR_SDK" | |
echo "CACHE_DIR_DL: $CACHE_DIR_DL" | |
echo "CACHE_DIR_FEEDS: $CACHE_DIR_FEEDS" | |
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" | |
echo "CACHE_DIR_SDK=$CACHE_DIR_SDK" >> $GITHUB_ENV | |
echo "CACHE_DIR_DL=$CACHE_DIR_DL" >> $GITHUB_ENV | |
echo "CACHE_DIR_FEEDS=$CACHE_DIR_FEEDS" >> $GITHUB_ENV | |
echo "SDK_HOME=$(mktemp -d)" >> $GITHUB_ENV | |
- 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 -I zstd -xvf "$CACHE_DIR_SDK/$SDK_FILE" -C "$SDK_HOME" --strip=1 | |
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" | |
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: Update and Install Packages | |
run: | | |
cd "$SDK_HOME" | |
./scripts/feeds update -a | |
ln -s "${{ github.workspace }}" "package/$PACKAGE_NAME" | |
./scripts/feeds install -a | |
cd - | |
- name: Build Packages | |
run: | | |
cd "$SDK_HOME" | |
make defconfig | |
make package/${PACKAGE_NAME}/status/{clean,compile} V=s | |
find "$SDK_HOME/bin/" -type f -name "*.ipk" -exec ls -lh {} \; | |
cd - | |
- name: Copy Bin Files | |
run: | | |
find "$SDK_HOME/bin/" -type f -name "${PACKAGE_NAME}*.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 }} | |
notify: | |
name: Notify Release Publish | |
runs-on: ubuntu-latest | |
env: | |
TRIGGER_URL: ${{ secrets.TRIGGER_URL }} | |
TRIGGER_TOKEN: ${{ secrets.TRIGGER_TOKEN }} | |
needs: release | |
steps: | |
- name: Notify Jenkins | |
run: | | |
if [ -z "$TRIGGER_URL" ] ; then | |
echo "::warning::No trigger url found, skip..." | |
exit 0 | |
fi | |
curl -X POST \ | |
-H "Content-Type: application/json; charset=utf-8" \ | |
-H "Authorization: Bearer $TRIGGER_TOKEN" \ | |
-d "{\"event\":\"release\",\"repository\":\"${{ github.repository }}\",\"ref\":\"${{ github.ref }}\"}" \ | |
"$TRIGGER_URL" || true |