-
Notifications
You must be signed in to change notification settings - Fork 2
172 lines (154 loc) · 6.99 KB
/
build-ci.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
# Credits:
# https://github.com/Waujito
# https://github.com/Waujito/youtubeUnblock/blob/main/.github/workflows/build-ci.yml
name: CI
on:
push:
branches:
- main
paths-ignore:
- '.editorconfig'
- '.gitignore'
- 'LICENSE'
- 'README.md'
workflow_dispatch:
jobs:
prepare:
runs-on: ubuntu-latest
outputs:
version: ${{ steps.gh.outputs.version }}
release: ${{ steps.gh.outputs.release }}
sha: ${{ steps.gh.outputs.sha }}
steps:
- name: Checkout
uses: actions/checkout@v4
- name: GH
id: gh
env:
REPO: ${{ github.repository }}
GH_TOKEN: ${{ secrets.GITHUB_TOKEN }}
shell: bash
run: |
echo "version=$(cat Makefile | grep "PKG_VERSION :=" | sed 's/PKG_VERSION := //')" >> $GITHUB_OUTPUT
echo "release=$(cat Makefile | grep "PKG_RELEASE :=" | sed 's/PKG_RELEASE := //')" >> $GITHUB_OUTPUT
if [[ "${{ github.event_name }}" != "pull_request" ]]; then
echo "sha=$(echo ${GITHUB_SHA::7})" >> $GITHUB_OUTPUT
else
echo "sha=$(gh api repos/$REPO/commits/main --jq '.sha[:7]')" >> $GITHUB_OUTPUT
fi
build-entware:
needs: prepare
runs-on: ubuntu-latest
strategy:
matrix:
arch:
- aarch64-3.10
- armv7-3.2
- mips-3.4
- mipsel-3.4
- x64-3.2
include:
- arch: armv7-2.6
k26: true
- arch: x86-2.6
k26: true
steps:
- name: Set up Entware docker container
run: |
git clone --depth 1 https://github.com/Entware/docker.git
docker build docker --pull --tag builder
docker volume create entware-home
- name: Restore Entware from cache
id: cache-restore
uses: actions/cache/restore@v4
with:
path: ~/entware
key: entware-${{ matrix.arch }}
- name: Load Entware from cache
if: steps.cache-restore.outputs.cache-hit == 'true'
run: |
docker run --rm --mount source=entware-home,target=/backup_vol -v ~/entware:/backup ubuntu tar -xf /backup/entware.tar -C /backup_vol
docker run --rm --mount source=entware-home,target=/home/me -w /home/me ubuntu bash -c 'cp -r ./backup_vol/* ./'
docker run --rm --mount source=entware-home,target=/home/me -w /home/me ubuntu bash -c 'chown -R 1000:1000 ./* ./'
- name: Obtain Entware
if: ${{ steps.cache-restore.outputs.cache-hit != 'true' && ! matrix.k26 }}
run: |
docker run --rm -i --mount source=entware-home,target=/home/me -w /home/me --name builder builder git clone --depth 1 https://github.com/Entware/Entware.git
- name: Obtain Entware k2.6
if: ${{ steps.cache-restore.outputs.cache-hit != 'true' && matrix.k26 }}
run: |
docker run --rm -i --mount source=entware-home,target=/home/me -w /home/me --name builder builder git clone --depth 1 https://github.com/Entware/Entware.git -b k2.6
- name: Build Entware
if: steps.cache-restore.outputs.cache-hit != 'true'
run: |
docker run --rm -i --mount source=entware-home,target=/home/me -w /home/me/Entware --name builder builder make package/symlinks
docker run --rm -i --mount source=entware-home,target=/home/me -w /home/me/Entware --name builder builder cp -v configs/${{ matrix.arch }}.config .config
docker run --rm -i --mount source=entware-home,target=/home/me -w /home/me/Entware --name builder builder make -j$(nproc) toolchain/install
docker run --rm --mount source=entware-home,target=/backup_vol -v ~/entware:/backup ubuntu tar -cf /backup/entware.tar /backup_vol
- name: Save Entware to cache
if: steps.cache-restore.outputs.cache-hit != 'true'
id: cache-save
uses: actions/cache/save@v4
with:
path: ~/entware
key: entware-${{ matrix.arch }}
- name: Checkout
uses: actions/checkout@v4
with:
ref: 'entware'
- name: Prepare build
env:
VERSION: ${{ needs.prepare.outputs.version }}
RELEASE: ${{ needs.prepare.outputs.release }}
SHA: ${{ needs.prepare.outputs.sha }}
run: |
sed -i "s/PKG_REV:=.*$/PKG_REV:=$SHA/;s/PKG_VERSION:=.*$/PKG_VERSION:=$VERSION-$RELEASE-$SHA/" keenetic-pbr/Makefile
- name: Build packages
id: build
run: |
echo "src-link keeneticPbr /keenetic-pbr" | docker run --rm -i --mount source=entware-home,target=/home/me -v $GITHUB_WORKSPACE:/keenetic-pbr -w /home/me/Entware --name builder builder tee -a feeds.conf
docker run --rm -i --mount source=entware-home,target=/home/me -v $GITHUB_WORKSPACE:/keenetic-pbr -w /home/me/Entware --name builder builder ./scripts/feeds update keeneticPbr
docker run --rm -i --mount source=entware-home,target=/home/me -v $GITHUB_WORKSPACE:/keenetic-pbr -w /home/me/Entware --name builder builder ./scripts/feeds install -a -p keeneticPbr
echo "CONFIG_PACKAGE_keenetic-pbr=m" | docker run --rm -i --mount source=entware-home,target=/home/me -v $GITHUB_WORKSPACE:/keenetic-pbr -w /home/me/Entware --name builder builder tee -a .config
docker run --rm -i --mount source=entware-home,target=/home/me -v $GITHUB_WORKSPACE:/keenetic-pbr -w /home/me/Entware --name builder builder make package/keenetic-pbr/compile V=s
- name: Extract packages
if: steps.build.outcome == 'success'
shell: bash
env:
VERSION: ${{ needs.prepare.outputs.version }}
RELEASE: ${{ needs.prepare.outputs.release }}
SHA: ${{ needs.prepare.outputs.sha }}
run: |
mkdir output
docker run --rm --user root -i --mount source=entware-home,target=/home/me -v $(pwd):/target -w /home/me/Entware --name builder builder find ./bin -type f -name 'keenetic-pbr*.ipk' -exec cp -v {} /target/output \;
rm -rf keenetic-pbr || true
mkdir keenetic-pbr
bash -c "cp -r ./output/* keenetic-pbr"
tar -czvf keenetic-pbr-$VERSION-$RELEASE-$SHA-${{ matrix.arch }}-entware.tar.gz keenetic-pbr
- name: Upload packages
if: steps.build.outcome == 'success'
uses: actions/upload-artifact@v4
with:
name: keenetic-pbr-entware-${{ matrix.arch }}
path: ./**/keenetic-pbr*-entware.tar.gz
if-no-files-found: error
pre-release:
if: github.event_name != 'pull_request' && github.ref_name == 'main'
needs: [build-entware]
permissions:
contents: write
runs-on: ubuntu-latest
steps:
- name: Download artifacts
uses: actions/download-artifact@v4
- name: Upload assets
uses: slord399/action-automatic-releases@v1.0.1
with:
repo_token: ${{ secrets.GITHUB_TOKEN }}
automatic_release_tag: 'continuous'
prerelease: true
draft: true
title: 'Development build'
files: |
./**/keenetic-pbr*.ipk
./**/keenetic-pbr*.tar.gz