-
Notifications
You must be signed in to change notification settings - Fork 33
133 lines (119 loc) · 5.91 KB
/
Copy pathbuild-openwrt.yaml
File metadata and controls
133 lines (119 loc) · 5.91 KB
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
name: Build OpenWrt for GL-MT6000
permissions:
contents: write
actions: write
on:
workflow_dispatch:
push:
branches:
- main
schedule:
- cron: "38 1 */3 * *"
env:
REMOTE_REPOSITORY: pesa1234/openwrt
CONFIG_FILE: mt6000.config
GH_TOKEN: ${{ github.token }}
jobs:
check_commits:
name: Check for new commits
runs-on: ubuntu-24.04-arm
outputs:
remote_branch: ${{ steps.check_commits.outputs.remote_branch }}
release_prefix: ${{ steps.check_commits.outputs.release_prefix }}
new_commits: ${{ steps.check_commits.outputs.new_commits }}
latest_commit_sha: ${{ steps.check_commits.outputs.latest_commit_sha }}
steps:
- name: Check for new commits in pesa1234 repo
id: check_commits
run: |
remote_branch=$(git ls-remote https://github.com/${{ env.REMOTE_REPOSITORY }}.git "refs/heads/next-*" | sed -e 's|\(.*heads/\)||' | grep -viE 'test|beta' | sort -V | tail -n1)
[ -n "$remote_branch" ] && latest_commit_sha=$(gh api "repos/${{ env.REMOTE_REPOSITORY }}/commits/${remote_branch}" --jq .sha)
[ -z "$latest_commit_sha" ] && { echo "*** COULD NOT GET latest_commit_sha FROM remote_branch=$remote_branch ***" ; exit 1; }
gh api "repos/${{ github.repository }}/releases/latest" --jq .body 2>/dev/null | grep -q "${latest_commit_sha}" && echo "new_commits=false" >> $GITHUB_OUTPUT || echo "new_commits=true" >> $GITHUB_OUTPUT
echo "remote_branch=${remote_branch}"
echo "release_prefix=${remote_branch%.rss*}"
echo "latest_commit_sha=$latest_commit_sha"
echo "remote_branch=${remote_branch}" >> $GITHUB_OUTPUT
echo "release_prefix=${remote_branch%.rss*}" >> $GITHUB_OUTPUT
echo "latest_commit_sha=$latest_commit_sha" >> $GITHUB_OUTPUT
build:
name: Build OpenWrt
needs: check_commits
if: github.event_name == 'workflow_dispatch' || needs.check_commits.outputs.new_commits == 'true'
runs-on: ubuntu-24.04-arm
steps:
- name: Install dependencies
run: |
sudo apt remove -y '*cloud*' '*firefox*' '*chrome*' '*dotnet*' '*php*'
sudo apt update -y && sudo apt upgrade -y
sudo apt install -y build-essential clang flex bison g++ gawk gettext libncurses-dev libssl-dev python3-setuptools rsync swig unzip zlib1g-dev file wget llvm
sudo apt autoremove -y && sudo apt clean -y
- name: Checkout remote repository
uses: actions/checkout@v6
with:
repository: ${{ env.REMOTE_REPOSITORY }}
ref: ${{ needs.check_commits.outputs.remote_branch }}
- name: Checkout current repository
uses: actions/checkout@v6
with:
path: "builder_repo"
- name: Update and install feeds
run: |
./scripts/feeds update -a
./scripts/feeds install -a
# run again because sometimes it misses some dependencies
./scripts/feeds install -a
- name: Setup configuration and custom files
run: |
# delete unneeded folders and patch files with repository info
rm -frv builder_repo/.git builder_repo/.github
for file in $(grep -rl XXXXXX builder_repo/); do echo "Patching: $file"; sed -i 's|XXXXXX/YYYYYY|${{ github.repository }}|g' "$file" || exit 1; done
patch -p1 < builder_repo/attendedsysupgrade-with-GitHub.patch
mv -v builder_repo/files ./
chmod -v 755 files/usr/bin/upgrade_custom_openwrt files/www/cgi-bin/github_*
mv -v builder_repo/${{ env.CONFIG_FILE }} .config
rm -rfv builder_repo
make defconfig
- name: Build firmware
run: |
make download -j$(nproc) || {
echo "Retrying..."
sleep 60
make download -j1 V=s
}
make -j$(nproc) || {
echo "Retrying..."
sleep 60
make -j1 V=s
}
mkdir -p firmware
find ./bin -type f \( -iname 'openwrt-*-sysupgrade.bin' -or -iname 'config.buildinfo' -or -iname 'version.buildinfo' \) -exec mv -v {} ./firmware/ \; ||:
mv .config firmware/full.config ||:
cd firmware && sha256sum openwrt-*-sysupgrade.bin >sha256sums ||:
- name: Upload artifacts
uses: actions/upload-artifact@v6.0.0
with:
name: gl-mt6000-firmware
path: firmware/*
- name: Create release
run: |
RELEASE_DATE=$(date +%F)
gh release delete "${{ needs.check_commits.outputs.release_prefix }}-${RELEASE_DATE}" --cleanup-tag -y --repo "${{ github.repository }}" ||:
gh release create "${{ needs.check_commits.outputs.release_prefix }}-${RELEASE_DATE}" --repo "${{ github.repository }}" --latest --notes "### 🔄 Main Repository
- **Repository:** [${{ env.REMOTE_REPOSITORY }}](https://github.com/${{ env.REMOTE_REPOSITORY }})
- **Branch:** ${{ needs.check_commits.outputs.remote_branch }}
- **Commit:** ${{ needs.check_commits.outputs.latest_commit_sha }}
### 📝 Build Information
- **Target:** [Flint 2 (GL-MT6000)](https://openwrt.org/toh/gl.inet/gl-mt6000)
- **Configuration:** [${{ env.CONFIG_FILE }}](${{ env.CONFIG_FILE }})
- **WiFi UCODE scripts**
- **Wireguard VPN**
- **Policy Based Routing**
- **Ad Block Fast**
- **REMOVED:** odhcp, upnp, iptables, avahi, samba, usb storage..." --title "OpenWrt Custom Release for Flint 2 (${{ needs.check_commits.outputs.release_prefix }}-${RELEASE_DATE})" firmware/*
- name: Clean up old releases
run: |
# '.[0:10][]' limits to the 10 most recent releases
gh api repos/${{ github.repository }}/releases | jq -r '.[10:][] | "\(.id) \(.tag_name)"' | while read id tag; do
gh api -X DELETE "repos/${{ github.repository }}/releases/$id" && gh api -X DELETE "repos/${{ github.repository }}/git/refs/tags/$tag" 2>/dev/null ||:
done