-
Notifications
You must be signed in to change notification settings - Fork 1.8k
105 lines (87 loc) · 4.05 KB
/
build-rockchip-23.05.4.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
name: build-rockchip-imm-23.05.4-release
on:
workflow_dispatch:
inputs:
profile:
description: '手动输入的多个 profile,并按逗号分隔'
required: true
default: 'friendlyarm_nanopi-r3s'
rootfs_partsize:
description: '设置根文件系统分区大小 (MB)'
required: true
default: '1024'
jobs:
build:
runs-on: ubuntu-latest
steps:
- name: Checkout code
uses: actions/checkout@v3
- name: Set executable permissions
run: chmod +x ${{ github.workspace }}/rockchip/build.sh
- name: Setup Docker and Build
run: |
profiles="${{ github.event.inputs.profile }}"
rootfs_partsize="${{ github.event.inputs.rootfs_partsize }}"
IFS=',' read -r -a profile_array <<< "$profiles"
for profile in "${profile_array[@]}"; do
echo "Building for profile: $profile"
docker run --rm -i \
--user root \
-v "${{ github.workspace }}/bin:/home/build/immortalwrt/bin" \
-v "${{ github.workspace }}/files:/home/build/immortalwrt/files" \
-v "${{ github.workspace }}/rockchip/imm.config:/home/build/immortalwrt/.config" \
-v "${{ github.workspace }}/rockchip/build.sh:/home/build/immortalwrt/build.sh" \
-e PROFILE=$profile \
-e ROOTFS_PARTSIZE=$rootfs_partsize \
immortalwrt/imagebuilder:rockchip-armv8-openwrt-24.10.0-rc1 /bin/bash /home/build/immortalwrt/build.sh
done
- name: Locate squashfs firmware files
id: locate_files
run: |
# 查找符合条件的固件文件
firmware_files=$(find "${{ github.workspace }}/bin" -type f -name '*squashfs*.img.gz')
# 如果有多个固件文件,按空格分割路径并保存为环境变量
firmware_files_array=($firmware_files)
# 输出找到的固件文件路径
echo "Found firmware files: ${firmware_files}"
# 临时复制文件到一个平级目录(避免目录结构太复杂)
temp_dir="${{ github.workspace }}/firmware_temp"
mkdir -p $temp_dir
# 将固件文件复制到 temp_dir 目录
cp "${firmware_files_array[@]}" $temp_dir
# 将所有固件文件路径合并为一个tar包
tar_file="firmware_files.tar.gz"
tar -czf $tar_file -C $temp_dir . # 使用 -C 指定目录,打包该目录下的所有文件,而不包含目录结构
# 将tar包路径设置为环境变量
echo "TAR_FILE=$tar_file" >> $GITHUB_ENV
- name: Set release date and tag name
id: set_release_info
run: |
# 设置北京时间
TZ="Asia/Shanghai" date
release_date=$(TZ="Asia/Shanghai" date +'%Y-%m-%d %H:%M')
tag_name=$(TZ="Asia/Shanghai" date +'%Y%m%d%H%M')
echo "Release date: $release_date"
echo "Release tag name: $tag_name"
echo "RELEASE_DATE=$release_date" >> $GITHUB_ENV
echo "TAG_NAME=$tag_name" >> $GITHUB_ENV
- name: Create GitHub Release
id: create_release
uses: ncipollo/[email protected] # 使用 ncipollo/release-action 创建发布
with:
tag: ${{ env.TAG_NAME }} # 使用时间戳作为 tag 名称
name: "${{ env.RELEASE_DATE }} Build" # 使用时间戳作为 release 名称
draft: false
prerelease: false
generateReleaseNotes: false
makeLatest: true # 设置为 true
token: ${{ secrets.GITHUB_TOKEN }}
- name: Upload compressed firmware tarball to GitHub Release
uses: actions/upload-release-asset@v1
with:
upload_url: ${{ steps.create_release.outputs.upload_url }}
asset_path: ${{ env.TAR_FILE }} # 上传打包的tar.gz文件
asset_name: firmware_files.tar.gz # 固件压缩包的名称
asset_content_type: application/gzip
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}