Repository navigation
185 lines (161 loc) · 6.13 KB
/
Copy pathbuild-openwrt.yml
File metadata and controls
185 lines (161 loc) · 6.13 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
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
name: Build OpenWrt
on:
workflow_call:
inputs:
repo:
required: true
type: string
branch:
required: true
type: string
device:
required: true
type: string
op_name:
required: true
type: string
flavor:
required: true
type: string
target_config:
required: true
type: string
app_config:
required: true
type: string
driver_config:
required: false
type: string
default: ""
cache_scope:
required: true
type: string
upload_release:
required: false
type: boolean
default: true
permissions:
contents: write
concurrency:
group: openwrt-${{ inputs.repo }}-${{ inputs.branch }}-${{ inputs.device }}-${{ inputs.flavor }}
cancel-in-progress: false
jobs:
build:
name: ${{ inputs.device }} - ${{ inputs.flavor }}
runs-on: ubuntu-22.04
env:
REPO: ${{ inputs.repo }}
REPO_BRANCH: ${{ inputs.branch }}
TZ: Asia/Shanghai
OPENWRT_DIR: /mnt/workdir/openwrt
CCACHE_DIR: /mnt/workdir/openwrt/.ccache
# Bump this value whenever the set of safe cache paths changes.
CACHE_SCHEMA: v2
steps:
- name: Checkout
uses: actions/checkout@v6
- name: Initialization environment
env:
DEBIAN_FRONTEND: noninteractive
run: |
sudo rm -rf /etc/apt/sources.list.d/*
sudo -E apt-get -qq update
bash "$GITHUB_WORKSPACE/scripts/prepare-env.sh"
sudo -E apt-get -qq autoremove --purge
sudo -E apt-get -qq clean
sudo timedatectl set-timezone "$TZ"
sudo mkdir -p /mnt/workdir
sudo chown "$USER:$(id -gn)" /mnt/workdir
- name: Clone source code
working-directory: /mnt/workdir
run: |
df -hT "$PWD"
bash "$GITHUB_WORKSPACE/scripts/clone-source.sh" openwrt
ln -sf /mnt/workdir/openwrt "$GITHUB_WORKSPACE/openwrt"
- name: Cache downloads and ccache
uses: actions/cache@v6
with:
path: |
/mnt/workdir/openwrt/dl
!/mnt/workdir/openwrt/dl/go-mod-cache
/mnt/workdir/openwrt/.ccache
# Go module trees are mutable and can be left incomplete by an interrupted
# download. Do not restore or persist them; Go will repopulate them safely.
key: openwrt-${{ env.CACHE_SCHEMA }}-${{ inputs.repo }}-${{ inputs.branch }}-${{ inputs.cache_scope }}-${{ hashFiles('feeds/**', 'packages/**', 'scripts/**', 'configs/**', 'manifests/**') }}
restore-keys: |
openwrt-${{ env.CACHE_SCHEMA }}-${{ inputs.repo }}-${{ inputs.branch }}-${{ inputs.cache_scope }}-
- name: Apply system settings and feeds
run: |
bash "$GITHUB_WORKSPACE/scripts/apply-openwrt.sh" system feeds
- name: Update feeds
run: cd "$OPENWRT_DIR" && ./scripts/feeds update -a
- name: Install feeds
run: cd "$OPENWRT_DIR" && ./scripts/feeds install -a
- name: Apply repo packages
run: bash "$GITHUB_WORKSPACE/scripts/apply-openwrt.sh" packages
- name: Compose configuration
env:
TARGET_CONFIG: ${{ inputs.target_config }}
APP_CONFIG: ${{ inputs.app_config }}
DRIVER_CONFIG: ${{ inputs.driver_config }}
run: bash "$GITHUB_WORKSPACE/scripts/compose-config.sh"
- name: Download package sources
run: bash "$GITHUB_WORKSPACE/scripts/build.sh" download
- name: Build tools
run: bash "$GITHUB_WORKSPACE/scripts/build.sh" tools
- name: Build toolchain
run: bash "$GITHUB_WORKSPACE/scripts/build.sh" toolchain
- name: Build target kernel
run: bash "$GITHUB_WORKSPACE/scripts/build.sh" target
- name: Build packages
run: bash "$GITHUB_WORKSPACE/scripts/build.sh" packages
- name: Build firmware images
run: bash "$GITHUB_WORKSPACE/scripts/build.sh" images
- name: Check space usage
if: always()
run: df -hT
- name: Organize files
id: organize
run: |
firmware_dir="$(find "$OPENWRT_DIR/bin/targets" -mindepth 2 -maxdepth 2 -type d | head -n 1)"
if [ -z "$firmware_dir" ]; then
echo "Firmware directory not found."
exit 1
fi
rm -rf "$firmware_dir/packages"
echo "FIRMWARE=$firmware_dir" >> "$GITHUB_ENV"
echo "file_date=$(date +"%Y%m%d%H%M")" >> "$GITHUB_OUTPUT"
- name: Upload firmware directory
uses: actions/upload-artifact@v4
with:
name: OpenWrt_${{ inputs.repo }}_${{ inputs.device }}_${{ inputs.flavor }}_${{ steps.organize.outputs.file_date }}
path: ${{ env.FIRMWARE }}
- name: Generate release body
if: ${{ inputs.upload_release }}
run: |
release_tag="${{ inputs.repo }}-${{ inputs.device }}-${{ inputs.flavor }}-${{ github.run_id }}-${{ github.run_attempt }}"
release_name="${{ inputs.repo }}-${{ inputs.op_name }} - ${{ inputs.flavor }}"
if [ "${#release_tag}" -gt 240 ] || ! git check-ref-format "refs/tags/$release_tag"; then
echo "Invalid or overly long release tag (${#release_tag} characters): $release_tag" >&2
exit 1
fi
echo "RELEASE_TAG=$release_tag" >> "$GITHUB_ENV"
echo "RELEASE_NAME=$release_name" >> "$GITHUB_ENV"
{
echo ""
echo ""
echo "Repository: ${{ inputs.repo }}"
echo "Branch: ${{ inputs.branch }}"
echo "Device: ${{ inputs.op_name }}"
echo "Flavor: ${{ inputs.flavor }}"
} > release.txt
- name: Upload firmware to release
uses: softprops/action-gh-release@v1
if: ${{ inputs.upload_release }}
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
with:
name: ${{ env.RELEASE_NAME }}
tag_name: ${{ env.RELEASE_TAG }}
body_path: release.txt
files: ${{ env.FIRMWARE }}/*