-
Notifications
You must be signed in to change notification settings - Fork 1
133 lines (128 loc) · 4.87 KB
/
github-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
name: Create GitHub release
permissions:
contents: write
on:
push:
branches:
- "viptela-vedge1000"
schedule:
# Build every week (sunday midnight)
- cron: "0 0 * * 0"
workflow_dispatch:
jobs:
# NOTE: setup and release step runs on Github's ordinary runners while
# the build step runs on our own. This allows starting and finishing builds
# without being blocked on the self-hosted runners.
setup:
name: Setup
runs-on: ubuntu-24.04
outputs:
version_number: ${{ steps.vars.outputs.version_number }}
matrix: ${{ steps.toolchain.outputs.matrix }}
steps:
- name: Set outputs
id: vars
run: |
echo "version_number=$(date +%Y-%m-%d).${{github.run_number}}" >> $GITHUB_OUTPUT
- name: Prepare toolchains
id: toolchain
run: |
set -xeuo pipefail
ver_octeon=$(curl -s https://downloads.openwrt.org/snapshots/targets/octeon/generic/sha256sums | awk '/openwrt-toolchain/ {print $2}' | sed -s 's/*//')
ver_x86=$(curl -s https://downloads.openwrt.org/snapshots/targets/x86/64/sha256sums | awk '/openwrt-toolchain/ {print $2}' | sed -s 's/*//')
echo "Latest toolchain available for Octeon is ${ver_octeon}"
echo "Latest toolchain available for x86_64 is ${ver_x86}"
echo "matrix=[" \
"{\"target\": \"octeon\", \"variant\": \"generic\", \"toolchain\": \"${ver_octeon}\"}," \
"{\"target\": \"x86\", \"variant\": \"64\", \"toolchain\": \"${ver_x86}\"}" \
"]" >> "$GITHUB_OUTPUT"
build-matrix:
name: Build
needs: setup
runs-on: self-hosted
strategy:
matrix:
include: ${{ fromJSON(needs.setup.outputs.matrix) }}
steps:
- name: Checkout
uses: actions/checkout@v4
- name: Setup toolchain
id: toolchain
run: |
set -xeuo pipefail
curl "https://downloads.openwrt.org/snapshots/targets/${{ matrix.target }}/${{ matrix.variant }}/${{ matrix.toolchain }}" -o toolchain.tar.zst
mkdir -p toolchain/
tar -C toolchain/ -xf toolchain.tar.zst '*/toolchain-*/' --strip-components=2
rm -f toolchain_*.tar.zst
- name: Fetch feeds
id: feeds
run: |
set -xeuo pipefail
cp -v sonix/feeds.conf .
./scripts/feeds update -a
./scripts/feeds install -a
- name: Setup build
id: setup
run: |
set -xeuo pipefail
rm -fr logs/
cp -v sonix/diffconfig .config
cat sonix/overrides >> .config
sed -i "s/SONIX-GIT/SONIX-${{ needs.setup.outputs.version_number }}/g" .config
./scripts/ext-toolchain.sh --toolchain $PWD/toolchain --overwrite-config --config ${{ matrix.target }}/${{ matrix.variant }}
if grep CONFIG_BUILD_NLS=y .config ; then echo '!!! We should not build with NLS as it increases build-time for no gain, remove it'; exit 1; fi
make -j$(nproc) download
make clean
- name: Build the host tools
id: host
run: |
set -xeuo pipefail
make -j$(nproc) tools/compile
- name: Build the target image
id: build
run: |
set -xeuo pipefail
make -j$(nproc) world
cp -v .config bin/targets/${{ matrix.target }}/${{ matrix.variant }}/openwrt-${{ matrix.target }}-${{ matrix.variant }}.config
cat bin/targets/${{ matrix.target }}/${{ matrix.variant }}/profiles.json | jq \
> bin/targets/${{ matrix.target }}/${{ matrix.variant }}/openwrt-${{ matrix.target }}-${{ matrix.variant }}.json
- name: Upload build artifact
uses: actions/upload-artifact@v4
with:
name: bin-${{ matrix.target }}-${{ matrix.variant }}
path: bin/targets/${{ matrix.target }}/${{ matrix.variant }}/openwrt-*
if-no-files-found: error
retention-days: 90
- name: Print build times
id: buildtime
if: always()
run: |
grep -h '^time: ' -r logs/ | cut -c 7- | sort -t '#' -n -k 4 | column -t -s '#' --table-columns PACKAGE,USER,SYSTEM,WALL
- name: Upload logs
uses: actions/upload-artifact@v4
if: always()
with:
name: logs-${{ matrix.target }}-${{ matrix.variant }}
path: logs/**
if-no-files-found: error
retention-days: 90
release:
name: Upload release
runs-on: ubuntu-24.04
needs:
- setup
- build-matrix
steps:
- name: Retrieve Artifacts
uses: actions/download-artifact@v4
with:
pattern: bin-*
- name: Release
uses: softprops/action-gh-release@v2
with:
name: "v${{ needs.setup.outputs.version_number }}"
prerelease: true
tag_name: "v${{ needs.setup.outputs.version_number }}"
target_commitish: "${{ github.sha }}"
files: |
bin-*/openwrt-*