-
Notifications
You must be signed in to change notification settings - Fork 18
205 lines (195 loc) · 6.33 KB
/
AutoBuild.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
name: AutoBuild
on:
workflow_dispatch:
inputs:
build_mode:
description: 'Build mode'
required: true
default: 'build_pkgs_and_imgs'
type: choice
options:
- build_pkgs_and_imgs
- build_imgs
- build_pkgs
compile_packages:
description: 'Compile packages'
required: false
default: 'A B C etc.'
type: string
no_pages:
description: 'Donot deploy pages'
required: true
default: false
type: boolean
export_dl:
description: 'Export DL'
required: true
default: false
type: boolean
push:
branches: [ master ]
paths:
- 'Makefile'
watch:
types: [started]
env:
# Release path
release_path: 'releases'
# 删除早期版本的 packages
DELETE_OLD_PACKAGES: true
# 删除早期的 workflow 任务
DELETE_OLD_WORKFLOW: true
WORKFLOW_RETAIN_DAYS: 14
KEEP_RUNS_RECORD: 100
### End
# Allow only one concurrent deployment, skipping runs queued between the run in-progress and latest queued.
# However, do NOT cancel in-progress runs as we want to allow these production deployments to complete.
concurrency:
group: "${{ github.workflow }}-${{ github.ref }}"
cancel-in-progress: false
jobs:
compile:
permissions:
contents: write # To push a branch
strategy:
matrix:
version: [23.05.4]
arch: [
x86_64,
aarch64_cortex-a53,
aarch64_generic,
arm_cortex-a15_neon-vfpv4,
mips_24kc,
mipsel_24kc
]
include:
- usign_id: ${{ vars.USIGN_ID }}
- gpg_id: ${{ vars.GPG_ID }}
- release_path: 'releases'
- no_img: true
- arch: x86_64
target: ['x86', '64'] # for imagebuilder
profile: generic # for imagebuilder
no_img: false
- arch: aarch64_cortex-a53
target: ['mvebu', 'cortexa53']
- arch: aarch64_generic
target: ['armsr', 'armv8']
- arch: arm_cortex-a15_neon-vfpv4
target: ['armsr', 'armv7']
- arch: mips_24kc
target: ['ath79', 'generic']
- arch: mipsel_24kc
target: ['ramips', 'mt7621']
uses: ./.github/workflows/compile.yml
with:
build_mode: ${{ inputs.build_mode }}
compiles: ${{ inputs.compile_packages }}
no_img: ${{ matrix.no_img }}
TPATH: ${{ matrix.release_path }}
VERSION: ${{ matrix.version }}
TARGET: ${{ matrix.target[0] }}
SUBTARGET: ${{ matrix.target[1] }}
PROFILE: ${{ matrix.profile }}
ARCH: ${{ matrix.arch }}
USIGN_ID: ${{ matrix.usign_id }}
GPG_ID: ${{ matrix.gpg_id }}
secrets: inherit
push_packages:
needs: compile
if: (inputs.build_mode == 0 || inputs.build_mode == 'build_pkgs_and_imgs' || inputs.build_mode == 'build_pkgs') && !cancelled()
permissions:
contents: write # To push a branch
runs-on: ubuntu-latest
steps:
- name: Checkout
uses: actions/checkout@v4
with:
ref: 'gh-pages'
lfs: false
submodules: false
- name: Download artifact
uses: actions/download-artifact@v4
- name: Move artifact
shell: bash
env:
keepdir: '19.07|21.02|22.03'
run: |
if [ "$DELETE_OLD_PACKAGES" == "true" ]; then
find $release_path/* -maxdepth 0 -type d 2>/dev/null | grep -Ev "\b($keepdir)$" | xargs -I{} rm -rf "{}"
fi
mkdir -p $release_path 2>/dev/null
cp -rf OpenWRT-Build-*/*/ $release_path/
rm -rf OpenWRT-Build-*/ 2>/dev/null
- name: Display structure of downloaded files
working-directory: ${{ env.release_path }}
run: ls -R
- name: Commit and push Packages
env:
Branch: gh-pages
run: |
git config --local user.name "GitHub Action"
git config --local user.email "[email protected]"
#git remote update # include submodules
#git fetch --no-tags --prune --no-recurse-submodules --depth=1 origin $Branch
#git checkout -B $Branch refs/remotes/origin/$Branch
git add $release_path/**/
git reset HEAD $release_path/**/targets/
git diff-index --cached --quiet HEAD $release_path/**/packages/**/*.ipk \
&& git diff-index --cached --quiet HEAD $release_path/**/packages/**/Packages.manifest \
&& git diff-index --cached --quiet HEAD $release_path/**/*.pub \
|| (git commit -m "Update packages" && git push)
export_dl:
needs: compile
if: inputs.export_dl == 1 && (inputs.build_mode == 0 || inputs.build_mode == 'build_pkgs_and_imgs' || inputs.build_mode == 'build_pkgs') && !cancelled()
runs-on: ubuntu-latest
steps:
- name: Initialize Environment
run: |
sudo mkdir -p /workdir
sudo chown $USER:$GROUPS /workdir
mkdir -p /workdir/DL
- name: Cache DL dependencies
uses: actions/cache@v4
with:
path: /workdir/DL
key: ${{ runner.os }}-OpenWRT-SDK-DL-Cache-Makefile-${{ hashFiles('**/Makefile') }}
restore-keys: |
${{ runner.os }}-OpenWRT-SDK-DL-Cache-Makefile-
- name: Compress DL Cache
run: |
pushd /workdir/DL
tar -cJvf /workdir/DL.txz * --owner=0 --group=0 --no-same-owner --no-same-permissions
popd
- name: Upload DL Cache artifact
uses: actions/upload-artifact@v4
with:
name: DL.txz
path: /workdir/DL.txz
retention-days: 1
deploy_pages:
needs: [compile, push_packages]
if: inputs.no_pages == 0 && !cancelled()
permissions:
contents: read
pages: write
id-token: write
strategy:
matrix:
release_path: ['releases']
uses: ./.github/workflows/jekyll.yml
with:
destination_path: ${{ matrix.release_path }}
clean-up-old-workflow:
needs: push_packages
permissions:
contents: read
actions: write
runs-on: ubuntu-latest
steps:
- name: Delete old Workflow Runs
uses: Mattraks/[email protected]
if: env.DELETE_OLD_WORKFLOW == 'true' && !cancelled()
with:
retain_days: ${{ env.WORKFLOW_RETAIN_DAYS }}
keep_minimum_runs: ${{ env.KEEP_RUNS_RECORD }}