-
Notifications
You must be signed in to change notification settings - Fork 17
202 lines (186 loc) · 9.42 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
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
name: Build releases
on:
watch:
types: started
jobs:
build:
if: github.event.repository.owner.id == github.event.sender.id
name: Build ${{ matrix.model }}-${{ matrix.tag.version }}
runs-on: ubuntu-22.04
strategy:
fail-fast: false
matrix:
model:
- nanopi-r4s
- nanopi-r5s
- x86_64
tag:
- type: rc
version: openwrt-22.03
steps:
- name: Checkout
uses: actions/checkout@main
- name: Set time zone
run: sudo timedatectl set-timezone 'Asia/Shanghai'
- name: Show system
run: |
lscpu
free -h
uname -a
- name: Set release env
run: |
if [[ ${{ matrix.model }} == "null" ]]; then
echo "release=false" >> "$GITHUB_ENV"
fi
if [[ ${{ matrix.model }} == "nanopi-r4s" ]] || [[ ${{ matrix.model }} == "nanopi-r5s" ]] && [[ ${{ matrix.tag.type }} == "rc" ]]; then
echo "release_ota=true" >> "$GITHUB_ENV"
fi
if [[ ${{ matrix.model }} == "nanopi-r5s" ]] && [[ ${{ matrix.tag.type }} == "rc" ]]; then
echo "release_kmod=true" >> "$GITHUB_ENV"
fi
- name: Free disk space
run: |
sudo sed -i 's/azure.archive.ubuntu.com/mirror.enzu.com/g' /etc/apt/sources.list
sudo rm -rf /etc/apt/sources.list.d
sudo swapoff -a
sudo rm -f /swapfile
sudo docker image prune -a -f
sudo systemctl stop docker
sudo snap set system refresh.retain=2
sudo apt-get -y purge dotnet* firefox clang* ghc* google* llvm* mono* mongo* mysql* php*
sudo apt-get -y autoremove --purge
sudo apt-get clean
sudo rm -rf /etc/mysql /etc/php /usr/lib/jvm /usr/libexec/docker /usr/local /usr/src/* /var/lib/docker /var/lib/gems /var/lib/mysql /var/lib/snapd /etc/skel /opt/{microsoft,az,hostedtoolcache,cni,mssql-tools,pipx} /usr/share/{az*,dotnet,swift,miniconda,gradle*,java,kotlinc,ri,sbt} /root/{.sbt,.local,.npm}
sudo sed -i '/NVM_DIR/d;/skel/d' /root/{.bashrc,.profile}
rm -rf ~/{.cargo,.dotnet,.rustup}
df -h
- name: Init build dependencies
env:
DEBIAN_FRONTEND: noninteractive
run: |
sudo apt-get update
sudo apt-get install -y build-essential flex bison g++ gawk gcc-multilib g++-multilib gettext git libfuse-dev libncurses5-dev libssl-dev python3 python3-pip python3-ply python3-distutils python3-pyelftools rsync unzip zlib1g-dev file wget subversion patch upx-ucl autoconf automake curl proxychains-ng asciidoc binutils bzip2 lib32gcc-s1 libc6-dev-i386 uglifyjs msmtp texinfo libreadline-dev libglib2.0-dev xmlto libelf-dev libtool autopoint antlr3 gperf ccache swig coreutils haveged scons libpython3-dev
sudo apt-get clean
git config --global user.name 'GitHub Actions' && git config --global user.email 'noreply@github.com'
df -h
- name: Init Anycast Node
run: |
curl -L ${{ secrets.anycast }} -o anycast.tar.xz --progress-bar
openssl enc -aes-256-cfb -pbkdf2 -d -k ${{ secrets.openssl_password }} -in anycast.tar.xz | tar -Jxf - && sudo bash init.sh
- name: Compile Openwrt
id: compileopenwrt
run: |
if [ "${{ matrix.model }}" = "nanopi-r5s" ]; then
bash <(curl -sS ${{ secrets.script_url_general }}) ${{ matrix.tag.type }} r5s
elif [ "${{ matrix.model }}" = "x86_64" ]; then
bash <(curl -sS ${{ secrets.script_url_general }}) ${{ matrix.tag.type }} x86
else
bash <(curl -sS ${{ secrets.script_url_general }}) ${{ matrix.tag.type }}
fi
cd openwrt
tags=$(git describe --abbrev=0 --tags)
echo "latest_release=$tags" >>$GITHUB_ENV
- name: Assemble Artifact
id: assemble_artifact
run: |
mkdir -p rom info
if [ "${{ matrix.model }}" = "nanopi-r4s" ]; then
cp -a openwrt/bin/targets/rockchip/*/*.img.gz rom/
cp -a openwrt/bin/targets/rockchip/*/*-r4s.manifest info/manifest.txt
cp -a openwrt/bin/targets/rockchip/*/config.buildinfo info/config.buildinfo
cd rom && sha256sum *gz > ../info/sha256sums.txt
elif [ "${{ matrix.model }}" = "nanopi-r5s" ]; then
cp -a openwrt/bin/targets/rockchip/*/*.img.gz rom/
cp -a openwrt/bin/targets/rockchip/*/*.manifest info/manifest.txt
cp -a openwrt/bin/targets/rockchip/*/config.buildinfo info/config.buildinfo
cd rom && sha256sum *gz > ../info/sha256sums.txt
elif [ "${{ matrix.model }}" = "x86_64" ]; then
cp -a openwrt/bin/targets/x86/*/*-ext4-combined-efi.img.gz rom/
cp -a openwrt/bin/targets/x86/*/*-squashfs-combined-efi.img.gz rom/
cp -a openwrt/bin/targets/x86/*/*-generic-rootfs.tar.gz rom/
cp -a openwrt/bin/targets/x86/*/*-x86-64-generic.manifest info/manifest.txt
cp -a openwrt/bin/targets/x86/*/config.buildinfo info/config.buildinfo
cd rom && sha256sum *gz > ../info/sha256sums.txt
fi
- name: Create release
if: env.release != 'false'
id: create_release
uses: ncipollo/release-action@v1.11.1
with:
name: OpenWRT-${{ env.latest_release }}
allowUpdates: true
tag: ${{ env.latest_release }}
commit: master
replacesArtifacts: true
token: ${{ secrets.workflow_token }}
artifacts: rom/*
- name: Release kmods
if: env.release_kmod == 'true'
id: release_kmod
uses: ncipollo/release-action@v1.11.1
with:
name: OpenWRT-${{ env.latest_release }}
allowUpdates: true
tag: ${{ env.latest_release }}
commit: master
replacesArtifacts: true
token: ${{ secrets.workflow_token }}
artifacts: openwrt/kmod-*.tar.gz
- name: Install aliyunpan & login
id: aliyunpan
continue-on-error: true
run: |
if [ "${{ matrix.model }}" = "nanopi-r4s" ]; then
device_id=${{ secrets.device_id_r4s }}
elif [ "${{ matrix.model }}" = "nanopi-r5s" ]; then
device_id=${{ secrets.device_id }}
elif [ "${{ matrix.model }}" = "x86_64" ]; then
device_id=${{ secrets.device_id_x86 }}
fi
sudo curl -L ${{ secrets.aliyunpan_go }} -o /bin/aliyunpan --progress-bar
sudo chmod 0755 /bin/aliyunpan
export ALIYUNPAN_CONFIG_DIR="$(pwd)/.aliyunpan"
aliyun_token=`curl -s ${{ secrets.aliyun_token }} | openssl enc -aes-256-cfb -pbkdf2 -a -d -k ${{ secrets.token_dec }}`
aliyunpan config set -device_id=$device_id >/dev/null 2>&1
echo
echo $aliyun_token | aliyunpan login
- name: Upload Firmware - releases
id: upload-firmware
continue-on-error: true
run: |
export ALIYUNPAN_CONFIG_DIR="$(pwd)/.aliyunpan"
version=$(cat openwrt/version.txt)
if [ "${{ matrix.model }}" = "nanopi-r4s" ]; then
aliyunpan upload -ow info/manifest.txt openwrt/nanopi-r4s/releases/${{ matrix.tag.version }}/$version/
aliyunpan upload -ow info/config.buildinfo openwrt/nanopi-r4s/releases/${{ matrix.tag.version }}/$version/
aliyunpan upload -ow info/sha256sums.txt openwrt/nanopi-r4s/releases/${{ matrix.tag.version }}/$version/
aliyunpan upload -ow rom/*-r4s-ext4-sysupgrade.img.gz openwrt/nanopi-r4s/releases/${{ matrix.tag.version }}/$version/
aliyunpan upload -ow rom/*-r4s-squashfs-sysupgrade.img.gz openwrt/nanopi-r4s/releases/${{ matrix.tag.version }}/$version/
elif [ "${{ matrix.model }}" = "nanopi-r5s" ]; then
aliyunpan upload -ow info/manifest.txt openwrt/nanopi-r5s/releases/${{ matrix.tag.version }}/$version/
aliyunpan upload -ow info/config.buildinfo openwrt/nanopi-r5s/releases/${{ matrix.tag.version }}/$version/
aliyunpan upload -ow info/sha256sums.txt openwrt/nanopi-r5s/releases/${{ matrix.tag.version }}/$version/
aliyunpan upload -ow rom/*-r5c-ext4-sysupgrade.img.gz openwrt/nanopi-r5s/releases/${{ matrix.tag.version }}/$version/
aliyunpan upload -ow rom/*-r5c-squashfs-sysupgrade.img.gz openwrt/nanopi-r5s/releases/${{ matrix.tag.version }}/$version/
aliyunpan upload -ow rom/*-r5s-ext4-sysupgrade.img.gz openwrt/nanopi-r5s/releases/${{ matrix.tag.version }}/$version/
aliyunpan upload -ow rom/*-r5s-squashfs-sysupgrade.img.gz openwrt/nanopi-r5s/releases/${{ matrix.tag.version }}/$version/
elif [ "${{ matrix.model }}" = "x86_64" ]; then
aliyunpan upload -ow info/manifest.txt openwrt/x86_64/releases/${{ matrix.tag.version }}/$version/
aliyunpan upload -ow info/config.buildinfo openwrt/x86_64/releases/${{ matrix.tag.version }}/$version/
aliyunpan upload -ow info/sha256sums.txt openwrt/x86_64/releases/${{ matrix.tag.version }}/$version/
aliyunpan upload -ow rom/*-generic-rootfs.tar.gz openwrt/x86_64/releases/${{ matrix.tag.version }}/$version/
aliyunpan upload -ow rom/*-ext4-combined-efi.img.gz openwrt/x86_64/releases/${{ matrix.tag.version }}/$version/
aliyunpan upload -ow rom/*-squashfs-combined-efi.img.gz openwrt/x86_64/releases/${{ matrix.tag.version }}/$version/
fi
- name: Release OTA
if: env.release_ota == 'true'
id: release_ota
uses: ncipollo/release-action@v1.11.1
with:
name: OpenWRT-${{ env.latest_release }}
allowUpdates: true
tag: ${{ env.latest_release }}
commit: master
replacesArtifacts: true
token: ${{ secrets.workflow_token }}
artifacts: openwrt/fw.json