summaryrefslogtreecommitdiffstats
path: root/.github/workflows/build.yml
blob: bd906b1443f81f3a955da47b1f6148a4131b6324 (plain)
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
name: Build OpenWrt staging

on: [push]

jobs:
  determine_targets:
    name: Find available targets
    runs-on: ubuntu-20.04
    outputs:
      targets: ${{ steps.find_targets.outputs.targets }}

    steps:
    - name: Checkout
      uses: actions/checkout@v2

    - name: Find targets
      id: find_targets
      run: |
        TARGETS="$(perl ./scripts/dump-target-info.pl targets 2>/dev/null | awk '{ print $1 }')"
        JSON='{"config": ["selinux","gcc10"], "targets":['
        FIRST=1
        for TARGET in $TARGETS; do
          [[ $FIRST -ne 1 ]] && JSON="$JSON"','
          JSON="$JSON"'"'"${TARGET}"'"'
          FIRST=0
        done
        JSON="$JSON"']}'

        echo -e "\n---- targets ----\n"
        echo "$JSON"
        echo -e "\n---- targets ----\n"

        echo "targets=$JSON" >> "$GITHUB_ENV"
        echo "::set-output name=targets::$JSON"

  build:
    name: Build ${{ matrix.config }}/${{ matrix.targets }}
    needs: determine_targets
    runs-on: ubuntu-latest
    strategy:
      fail-fast: False
      matrix: ${{fromJson(needs.determine_targets.outputs.targets)}}

    steps:
    - name: Checkout
      uses: actions/checkout@v2
      with:
        fetch-depth: 0

    - name: Cache sources
      uses: actions/cache@v2
      with:
        path: dl/
        key: ${{ matrix.targets }}

    - name: Initialization environment
      env:
        DEBIAN_FRONTEND: noninteractive
      run: |
        sudo apt-get -y install libncurses-dev
        TARGET=$(echo ${{ matrix.targets }} | cut -d "/" -f 1)
        SUBTARGET=$(echo ${{ matrix.targets }} | cut -d "/" -f 2)
        echo "TARGET=$TARGET" >> "$GITHUB_ENV"
        echo "SUBTARGET=$SUBTARGET" >> "$GITHUB_ENV"

    - name: Update & Install feeds
      run: |
        ./scripts/feeds update -a
        ./scripts/feeds install -a

    - name: Set configuration
      run: |
        curl "https://downloads.openwrt.org/snapshots/targets/${{ matrix.targets }}/config.buildinfo" > .config
        cat ".ci/${{ matrix.config }}.config" >> .config

        echo -e "\n---- config input ----\n"
        cat .config
        echo -e "\n---- config input ----\n"

        make defconfig

        echo -e "\n---- config post-defconfig ----\n"
        cat .config
        echo -e "\n---- config post-defconfig ----\n"

    - name: Download package
      run: |
        make download -j$(nproc)

    - name: Build tools
      run: |
        make tools/install -j$(nproc) || \
          make tools/install V=s

    - name: Build toolchain
      run: |
        make toolchain/install -j$(nproc) || \
          make toolchain/install V=s

    - name: Build target
      run: |
        make target/compile -j$(nproc) IGNORE_ERRORS='n m' || \
          make target/compile IGNORE_ERRORS='n m' V=s

    - name: Build packages
      run: |
        make package/compile -j$(nproc) IGNORE_ERRORS='n m' || \
          make package/compile IGNORE_ERRORS='n m' V=s

        make package/install -j$(nproc) || \
          make package/install V=s

        make package/index CONFIG_SIGNED_PACKAGES= V=s

    - name: Build firmware
      run: |
        make target/install EXTRA_IMAGE_NAME=${{ matrix.config }} -j$(nproc) || \
          make target/install V=s

    - name: Buildinfo
      run: |
        make buildinfo V=s

    - name: JSON overview
      run: |
        make json_overview_image_info V=s

    - name: Checksum
      run: |
        make checksum V=s

    - name: Sanitize target
      run: echo "target_sani=$(echo ${{ matrix.targets }} | tr '/' '-')" >> "$GITHUB_ENV"

    - name: Upload images
      uses: actions/upload-artifact@v2
      with:
        name: ${{ env.target_sani }}-${{ matrix.config }}-images
        path: bin/targets/${{ matrix.targets }}/openwrt-${{ matrix.config }}-${{ env.TARGET }}-*

    - name: Upload packages
      uses: actions/upload-artifact@v2
      with:
        name: ${{ env.target_sani }}-${{ matrix.config }}-packages
        path: |
          bin/**/*.ipk
          !bin/targets/${{ matrix.targets }}/packages/kmod-*.ipk

    - name: Upload kmods
      uses: actions/upload-artifact@v2
      with:
        name: ${{ env.target_sani }}-${{ matrix.config }}-kmods
        path: bin/targets/${{ matrix.targets }}/packages/kmod-*.ipk

    - name: Upload supplementary
      uses: actions/upload-artifact@v2
      with:
        name: ${{ env.target_sani }}-${{ matrix.config }}-supplementary
        path: |
          bin/targets/${{ matrix.targets }}/*.buildinfo
          bin/targets/${{ matrix.targets }}/*.json
          bin/targets/${{ matrix.targets }}/*.manifest
          bin/targets/${{ matrix.targets }}/kernel-debug.tar.zst
          bin/targets/${{ matrix.targets }}/openwrt-imagebuilder*
          bin/targets/${{ matrix.targets }}/openwrt-sdk*
          bin/targets/${{ matrix.targets }}/sha256sums*

    - name: Upload logs
      uses: actions/upload-artifact@v2
      with:
        name: ${{ env.target_sani }}-${{ matrix.config }}-logs
        path: logs/

    - name: Test ImageBuilder
      run: |
        cd bin/targets/${{ matrix.targets }}/
        tar xf openwrt-imagebuilder-*
        cd openwrt-imagebuilder-*/
        mkdir packages
        cp "$GITHUB_WORKSPACE"/bin/targets/${{ matrix.targets }}/packages/kmod-*.ipk packages/
        echo "src imagebuilder file:packages" >> repositories.conf
        make image
        ls ./bin/targets/${{ matrix.targets }}/openwrt-* | grep squashfs

    - name: Test SDK
      run: |
        cd bin/targets/${{ matrix.targets }}/
        tar xf openwrt-sdk-*
        cd openwrt-sdk-*/
        touch .config
        make prepare-tmpinfo scripts/config/conf
        ./scripts/config/conf --defconfig=.config Config.in
        make prereq
        rm .config
        make defconfig
        ./scripts/feeds update base
        ./scripts/feeds install busybox
        sync
        sleep 1
        make package/busybox/compile V=s
        sync
        sleep 1
        ls ./bin/packages/*/base/busybox*