generated from P3TERX/Actions-OpenWrt
-
Notifications
You must be signed in to change notification settings - Fork 0
105 lines (92 loc) · 3.77 KB
/
image-builder-official.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
name: Build with Image Builder
on:
repository_dispatch:
workflow_dispatch:
schedule:
# Runs on every 15th of the month
- cron: 0 0 */16 * *
env:
TZ: Pacific/Auckland
IMAGE_BUILDER_SH: image-builder_build.sh
jobs:
build:
runs-on: ubuntu-latest
steps:
- name: Checkout
uses: actions/checkout@v4
with:
submodules: true
- name: Initialization environment
env:
DEBIAN_FRONTEND: noninteractive
run: |
set +e
sudo rm -rf /etc/apt/sources.list.d/* /usr/share/dotnet /usr/local/lib/android /opt/ghc
docker rmi `docker images -q`
echo "Deleting files, please wait ..."
sudo -E apt-get -y purge \
azure-cli \
ghc* \
zulu* \
hhvm \
llvm* \
firefox \
google* \
dotnet* \
powershell \
openjdk* \
mysql* \
php*
sudo -E apt-get update
sudo -E apt-get -y install build-essential asciidoc binutils bzip2 gawk gettext git libncurses5-dev patch unzip zlib1g-dev libc6-dev-i386 subversion flex node-uglify git p7zip p7zip-full msmtp libssl-dev texinfo libglib2.0-dev xmlto qemu-utils upx-ucl libelf-dev autoconf automake libtool autopoint device-tree-compiler gcc-multilib antlr3 gperf wget curl swig rsync coreutils clang-12 g++ libreadline-dev ccache curl wget vim nano python3 python3-distutils python-pip python3-pip python-ply python3-ply haveged lrzsz scons ecj fastjar re2c xz-utils tar libbpf-dev llvm-12
sudo -E apt-get -y autoremove --purge
sudo -E apt-get clean
sudo timedatectl set-timezone "$TZ"
sudo mkdir -p /workdir
sudo chown $USER:$GROUPS /workdir
- name: Get latest official version
working-directory: /workdir
run: |
echo "LATEST=$(curl -s "https://downloads.openwrt.org/releases/" | grep href | grep -v '(root)' | grep -v "Fastly CDN" | grep -v faillogs | grep -v 'packages-' | sed s/'<\/a>.*'/''/ | sed s/'<tr><td class="n">'/''/ | cut -d'>' -f2 | grep -v '\-rc' | sort | tail -n1)" >> $GITHUB_ENV
- name: Download and extract image builder
working-directory: /workdir
run: |
wget -O - "https://downloads.openwrt.org/releases/$LATEST/targets/mvebu/cortexa9/openwrt-imagebuilder-$LATEST-mvebu-cortexa9.Linux-x86_64.tar.xz" | tar -Jxf -
- name: Build image
id: build
working-directory: /workdir
run: |
chmod +x $GITHUB_WORKSPACE/$IMAGE_BUILDER_SH
cd openwrt-imagebuilder-$LATEST-mvebu-cortexa9.Linux-x86_64
$GITHUB_WORKSPACE/$IMAGE_BUILDER_SH
echo "status=success">>$GITHUB_OUTPUT
- name: Organize files
working-directory: /workdir
id: organize
run: |
cd openwrt-imagebuilder-$LATEST-mvebu-cortexa9.Linux-x86_64/bin/targets/*/*
rm -rf packages
echo "FIRMWARE=$PWD" >> $GITHUB_ENV
echo "status=success" >> $GITHUB_OUTPUT
- name: Upload firmware directory
uses: actions/upload-artifact@main
if: steps.organize.outputs.status == 'success' && !cancelled()
with:
name: OpenWrt_firmware${{ env.DEVICE_NAME }}${{ env.FILE_DATE }}
path: ${{ env.FIRMWARE }}
- name: Generate release tag
id: tag
if: steps.build.outputs.status == 'success' && !cancelled()
run: |
echo "release_tag=$(date +"%Y.%m.%d-%H%M")-official">>$GITHUB_OUTPUT
touch release.txt
echo "status=success">>$GITHUB_OUTPUT
- name: Upload firmware to release
uses: softprops/action-gh-release@v1
if: steps.tag.outputs.status == 'success' && !cancelled()
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
with:
tag_name: ${{ steps.tag.outputs.release_tag }}
body_path: release.txt
files: ${{ env.FIRMWARE }}/*