forked from yichya/luci-app-xray
-
Notifications
You must be signed in to change notification settings - Fork 0
137 lines (130 loc) · 4.99 KB
/
build-release.yml
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
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/snapshots/targets/x86/64
sdk_name: -sdk-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