generated from P3TERX/Actions-OpenWrt
-
-
Notifications
You must be signed in to change notification settings - Fork 0
212 lines (181 loc) · 7.08 KB
/
immortalwrt-builder-selfhost.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
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
#
# https://github.com/P3TERX/Actions-OpenWrt
#
# File: .github/workflows/immortalwrt-builder-selfhost.yml
# Description: Build ImmortalWRT (Self Hosted) using GitHub Actions
#
# Copyright (c) 2019-2024 P3TERX <https://p3terx.com>
# Copyright (c) 2024-2025 SuperKali <[email protected]>
#
# This is free software, licensed under the MIT License.
# See /LICENSE for more information.
name: BananaWRT Builder (Self Hosted)
on:
repository_dispatch:
workflow_dispatch:
inputs:
release_type:
description: 'Select the release type'
required: true
type: choice
options:
- stable
- nightly
default: stable
architecture:
description: 'Select the host architecture'
required: true
type: choice
options:
- x64
- arm64
default: x64
version_system:
description: 'Write the version of ImmortalWRT to use'
type: string
required: true
default: '24.10.0-rc4'
env:
REPO_URL: https://github.com/immortalwrt/immortalwrt
REPO_BRANCH: ${{ github.event.inputs.version_system }}
FEEDS_CONF: feeds.conf.default
CONFIG_FILE: config/${{ github.event.inputs.release_type }}/.config
DIY_P1_SH: diy-part1.sh
DIY_P2_SH: diy-part2.sh
UPLOAD_BIN_DIR: false
UPLOAD_PACKAGE_DIR: true
UPLOAD_FIRMWARE: true
UPLOAD_RELEASE: true
TZ: Europe/Rome
jobs:
build:
runs-on: [self-hosted, "${{ github.event.inputs.architecture }}"]
steps:
- name: Checkout Source Code
uses: actions/[email protected]
- name: Set Up Build Environment
env:
DEBIAN_FRONTEND: noninteractive
run: |
/bin/bash .github/scripts/setup-env.sh setup
- name: Set timezone on the host
run: sudo timedatectl set-timezone "$TZ" || echo "Failed to set timezone, proceeding anyway."
- name: Authenticate GitHub
env:
GITHUB_TOKEN: ${{ secrets.PERSONAL_ACCESS_TOKEN }}
run: |
git config --global user.name "GitHub Actions"
git config --global user.email "[email protected]"
echo "machine github.com login ${{ secrets.PERSONAL_ACCESS_TOKEN }}" > ~/.netrc
chmod 600 ~/.netrc
- name: Clone ImmortalWRT Repository
working-directory: ${{ runner.workspace }}
run: |
git clone $REPO_URL -b v"$REPO_BRANCH" immortalwrt
- name: Apply Custom Feeds Configuration
run: |
[ -e ${{ env.FEEDS_CONF }} ] && mv ${{ env.FEEDS_CONF }} ${{ runner.workspace }}/immortalwrt/feeds.conf.default
chmod +x ${{ env.DIY_P1_SH }}
cd ${{ runner.workspace }}/immortalwrt
$GITHUB_WORKSPACE/${{ env.DIY_P1_SH }}
- name: Add Custom DTS Files
run: |
cp -r dts/${{ github.event.inputs.release_type }}/* ${{ runner.workspace }}/immortalwrt/target/linux/mediatek/dts/
- name: Update and Install Package Feeds
working-directory: ${{ runner.workspace }}/immortalwrt
run: |
./scripts/feeds update -a
./scripts/feeds install -a
- name: Apply Custom Configuration
run: |
[ -e files ] && mv files ${{ runner.workspace }}/immortalwrt/files
[ -e ${{ env.CONFIG_FILE }} ] && mv ${{ env.CONFIG_FILE }} ${{ runner.workspace }}/immortalwrt/.config
chmod +x ${{ env.DIY_P2_SH }}
cd ${{ runner.workspace }}/immortalwrt
$GITHUB_WORKSPACE/${{ env.DIY_P2_SH }}
./scripts/feeds install -p additional_pack -a
- name: Diffconfig with current configuration
working-directory: ${{ runner.workspace }}/immortalwrt
run: |
./scripts/diffconfig.sh > diffconfig
curl https://downloads.immortalwrt.org/releases/$REPO_BRANCH/targets/mediatek/filogic/config.buildinfo
cat diffconfig >> config.buildinfo
mv config.buildinfo .config
[ -n "$REPO_BRANCH" ] && sed -i \
-e 's|^CONFIG_VERSION_REPO=.*|CONFIG_VERSION_REPO="https://downloads.immortalwrt.org/releases/'"$REPO_BRANCH"'"|g' \
.config
make defconfig
- name: Build Firmware
working-directory: ${{ runner.workspace }}/immortalwrt
run: |
make -j$(nproc) || make -j1 V=s
grep '^CONFIG_TARGET.*DEVICE.*=y' .config | sed -r 's/.*DEVICE_(.*)=y/\1/' > DEVICE_NAME
echo "FILE_DATE=$(date +'%Y%m%d%H%M')" >> $GITHUB_ENV
- name: Check Disk Usage
run: df -hT
- name: Upload Binary Files
if: env.UPLOAD_BIN_DIR == 'true'
uses: actions/[email protected]
with:
name: BananaWRT_bin${{ env.FILE_DATE }}
path: ${{ runner.workspace }}/immortalwrt/bin
- name: Upload Custom Packages
if: env.UPLOAD_PACKAGE_DIR == 'true'
uses: actions/[email protected]
with:
name: BananaWRT_packages${{ env.FILE_DATE }}
path: ${{ runner.workspace }}/immortalwrt/bin/packages/*/additional_pack/*.ipk
- name: Prepare Firmware for Upload
run: |
cd ${{ runner.workspace }}/immortalwrt/bin/targets/*/*
rm -rf packages
echo "FIRMWARE=$PWD" >> $GITHUB_ENV
- name: Upload Firmware Files
if: env.UPLOAD_FIRMWARE == 'true'
uses: actions/[email protected]
with:
name: BananaWRT_firmware${{ env.FILE_DATE }}
path: ${{ env.FIRMWARE }}
- name: Create Release Tag
if: env.UPLOAD_RELEASE == 'true'
run: |
release_date=$(date +'%Y.%m.%d-%H%M')
kernel_version=$(find ${{ runner.workspace }}/immortalwrt/build_dir/target-*/linux-*/ -type d -regex '.*/linux-[0-9]+\.[0-9]+.*' | head -n 1 | sed -E 's|.*/linux-||')
target_devices=$(grep '^CONFIG_TARGET.*DEVICE.*=y' ${{ runner.workspace }}/immortalwrt/.config | sed -r 's/.*DEVICE_(.*)=y/\1/')
if [ "${{ github.event.inputs.release_type }}" = "stable" ]; then
release_type='Stable'
elif [ "${{ github.event.inputs.release_type }}" = "nightly" ]; then
release_type='Nightly'
fi
sed -e "s|{{BANANAWRT_KERNEL}}|${kernel_version}|g" \
-e "s|{{RELEASE_TYPE}}|${release_type}|g" \
-e "s|{{BANANAWRT_VERSION}}|${REPO_BRANCH}|g" \
-e "s|{{RELEASE_DATE}}|$(date '+%Y-%m-%d %H:%M:%S')|g" \
-e "s|{{TARGET_DEVICES}}|${target_devices}|g" \
templates/release-notes-template.md > release.txt
echo "release_tag=${release_date}" >> $GITHUB_ENV
- name: Publish Firmware Release
if: env.UPLOAD_RELEASE == 'true'
uses: softprops/[email protected]
with:
tag_name: ${{ env.release_tag }}
body_path: release.txt
files: ${{ env.FIRMWARE }}/*
- name: Remove old Releases
uses: dev-drprasad/[email protected]
if: env.UPLOAD_RELEASE == 'true' && !cancelled()
with:
keep_latest: 7
delete_tags: true
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
- name: Delete workflow runs
uses: Mattraks/[email protected]
with:
retain_days: 0
keep_minimum_runs: 7
- name: Cleanup Workspace
if: always()
run: |
sudo rm -rf ~/.netrc
sudo rm -rf "${{ runner.workspace }}/immortalwrt"