|
| 1 | +name: Build Armbian Image |
| 2 | + |
| 3 | +on: |
| 4 | + schedule: |
| 5 | + # Run daily at 03:00 UTC |
| 6 | + - cron: '0 3 * * *' |
| 7 | + workflow_dispatch: |
| 8 | + inputs: |
| 9 | + force_build: |
| 10 | + description: 'Force build regardless of version change' |
| 11 | + type: boolean |
| 12 | + default: false |
| 13 | + |
| 14 | +permissions: |
| 15 | + contents: write |
| 16 | + |
| 17 | +jobs: |
| 18 | + check-version: |
| 19 | + name: Check Upstream Version |
| 20 | + runs-on: ubuntu-latest |
| 21 | + outputs: |
| 22 | + build_needed: ${{ steps.check.outputs.build_needed }} |
| 23 | + upstream_version: ${{ steps.check.outputs.upstream_version }} |
| 24 | + steps: |
| 25 | + - name: Checkout repository |
| 26 | + uses: actions/checkout@v4 |
| 27 | + |
| 28 | + - name: Check upstream VERSION |
| 29 | + id: check |
| 30 | + run: | |
| 31 | + # Fetch current upstream VERSION from armbian/build |
| 32 | + UPSTREAM_VERSION=$(curl -sL https://raw.githubusercontent.com/armbian/build/main/VERSION | tr -d '\n\r') |
| 33 | + echo "upstream_version=$UPSTREAM_VERSION" >> $GITHUB_OUTPUT |
| 34 | + echo "Upstream Armbian version: $UPSTREAM_VERSION" |
| 35 | +
|
| 36 | + # Get last built version from images.json |
| 37 | + LAST_BUILT="" |
| 38 | + if [ -f images.json ]; then |
| 39 | + LAST_BUILT=$(jq -r '.latest.armbian_version // ""' images.json) |
| 40 | + fi |
| 41 | + echo "Last built version: $LAST_BUILT" |
| 42 | +
|
| 43 | + # Determine if build is needed |
| 44 | + if [ "$UPSTREAM_VERSION" != "$LAST_BUILT" ] || [ "${{ inputs.force_build }}" == "true" ]; then |
| 45 | + echo "build_needed=true" >> $GITHUB_OUTPUT |
| 46 | + echo "Build needed: version changed or force build requested" |
| 47 | + else |
| 48 | + echo "build_needed=false" >> $GITHUB_OUTPUT |
| 49 | + echo "Build not needed: version unchanged" |
| 50 | + fi |
| 51 | +
|
| 52 | + build: |
| 53 | + name: Build Armbian |
| 54 | + needs: check-version |
| 55 | + if: needs.check-version.outputs.build_needed == 'true' |
| 56 | + runs-on: ubuntu-latest |
| 57 | + timeout-minutes: 180 |
| 58 | + |
| 59 | + steps: |
| 60 | + - name: Checkout repository |
| 61 | + uses: actions/checkout@v4 |
| 62 | + |
| 63 | + - name: Maximize build space |
| 64 | + uses: easimon/maximize-build-space@master |
| 65 | + with: |
| 66 | + root-reserve-mb: 4096 |
| 67 | + swap-size-mb: 1024 |
| 68 | + remove-dotnet: 'true' |
| 69 | + remove-android: 'true' |
| 70 | + remove-haskell: 'true' |
| 71 | + remove-codeql: 'true' |
| 72 | + |
| 73 | + - name: Install dependencies |
| 74 | + run: | |
| 75 | + sudo apt-get update |
| 76 | + sudo apt-get install -y jq |
| 77 | +
|
| 78 | + - name: Clone Armbian build framework |
| 79 | + run: | |
| 80 | + git clone --depth=1 https://github.com/armbian/build armbian-build |
| 81 | +
|
| 82 | + - name: Build Armbian image |
| 83 | + run: | |
| 84 | + cd armbian-build |
| 85 | + ./compile.sh build \ |
| 86 | + BOARD=turing-rk1 \ |
| 87 | + BRANCH=vendor \ |
| 88 | + RELEASE=bookworm \ |
| 89 | + BUILD_MINIMAL=no \ |
| 90 | + BUILD_DESKTOP=no \ |
| 91 | + KERNEL_CONFIGURE=no \ |
| 92 | + COMPRESS_OUTPUTIMAGE=xz,sha |
| 93 | +
|
| 94 | + - name: Extract image metadata |
| 95 | + id: metadata |
| 96 | + run: | |
| 97 | + # Find the built image |
| 98 | + IMAGE_FILE=$(ls armbian-build/output/images/*.img.xz 2>/dev/null | head -1) |
| 99 | + if [ -z "$IMAGE_FILE" ]; then |
| 100 | + echo "Error: No image file found" |
| 101 | + exit 1 |
| 102 | + fi |
| 103 | +
|
| 104 | + FILENAME=$(basename "$IMAGE_FILE") |
| 105 | + SIZE=$(stat -c%s "$IMAGE_FILE") |
| 106 | + SIZE_HUMAN=$(numfmt --to=iec-i --suffix=B "$SIZE") |
| 107 | + SHA256=$(sha256sum "$IMAGE_FILE" | cut -d' ' -f1) |
| 108 | +
|
| 109 | + # Extract kernel version from filename |
| 110 | + KERNEL=$(echo "$FILENAME" | grep -oP '\d+\.\d+\.\d+' | tail -1) |
| 111 | +
|
| 112 | + echo "filename=$FILENAME" >> $GITHUB_OUTPUT |
| 113 | + echo "size=$SIZE" >> $GITHUB_OUTPUT |
| 114 | + echo "size_human=$SIZE_HUMAN" >> $GITHUB_OUTPUT |
| 115 | + echo "sha256=$SHA256" >> $GITHUB_OUTPUT |
| 116 | + echo "kernel=$KERNEL" >> $GITHUB_OUTPUT |
| 117 | +
|
| 118 | + echo "Image: $FILENAME" |
| 119 | + echo "Size: $SIZE_HUMAN" |
| 120 | + echo "SHA256: $SHA256" |
| 121 | + echo "Kernel: $KERNEL" |
| 122 | +
|
| 123 | + - name: Create GitHub Release |
| 124 | + id: release |
| 125 | + uses: softprops/action-gh-release@v2 |
| 126 | + with: |
| 127 | + tag_name: armbian-${{ needs.check-version.outputs.upstream_version }} |
| 128 | + name: Armbian ${{ needs.check-version.outputs.upstream_version }} for Turing RK1 |
| 129 | + body: | |
| 130 | + ## Armbian Image for Turing RK1 |
| 131 | +
|
| 132 | + | Property | Value | |
| 133 | + |----------|-------| |
| 134 | + | Version | ${{ needs.check-version.outputs.upstream_version }} | |
| 135 | + | Kernel | ${{ steps.metadata.outputs.kernel }} (vendor branch) | |
| 136 | + | Release | Bookworm (Debian 12) | |
| 137 | + | Size | ${{ steps.metadata.outputs.size_human }} | |
| 138 | + | SHA256 | `${{ steps.metadata.outputs.sha256 }}` | |
| 139 | +
|
| 140 | + ### Features |
| 141 | + - Rockchip vendor kernel with NPU support |
| 142 | + - Pre-configured for Turing Pi cluster deployment |
| 143 | +
|
| 144 | + ### Download & Flash |
| 145 | +
|
| 146 | + ```bash |
| 147 | + # Download |
| 148 | + wget https://github.com/${{ github.repository }}/releases/download/armbian-${{ needs.check-version.outputs.upstream_version }}/${{ steps.metadata.outputs.filename }} |
| 149 | +
|
| 150 | + # Verify checksum |
| 151 | + echo "${{ steps.metadata.outputs.sha256 }} ${{ steps.metadata.outputs.filename }}" | sha256sum -c |
| 152 | +
|
| 153 | + # Decompress |
| 154 | + xz -d ${{ steps.metadata.outputs.filename }} |
| 155 | +
|
| 156 | + # Prepare for node (optional - injects SSH keys, static IP) |
| 157 | + ./scripts/prepare-armbian-image.sh ${IMAGE%.xz} 1 |
| 158 | +
|
| 159 | + # Flash to node |
| 160 | + tpi flash --node 1 --image-path ${IMAGE%.xz} |
| 161 | + ``` |
| 162 | +
|
| 163 | + ### Using the download script |
| 164 | +
|
| 165 | + ```bash |
| 166 | + ./scripts/download-armbian-image.sh --latest |
| 167 | + ``` |
| 168 | + files: | |
| 169 | + armbian-build/output/images/*.img.xz |
| 170 | + armbian-build/output/images/*.img.sha |
| 171 | + armbian-build/output/images/*.img.txt |
| 172 | +
|
| 173 | + - name: Update images.json |
| 174 | + run: | |
| 175 | + VERSION="${{ needs.check-version.outputs.upstream_version }}" |
| 176 | + DATE=$(date -u +%Y-%m-%d) |
| 177 | + RELEASE_URL="https://github.com/${{ github.repository }}/releases/tag/armbian-${VERSION}" |
| 178 | + DOWNLOAD_URL="https://github.com/${{ github.repository }}/releases/download/armbian-${VERSION}/${{ steps.metadata.outputs.filename }}" |
| 179 | + CHECKSUM_URL="https://github.com/${{ github.repository }}/releases/download/armbian-${VERSION}/${{ steps.metadata.outputs.filename }}.sha256" |
| 180 | +
|
| 181 | + # Initialize images.json if it doesn't exist |
| 182 | + if [ ! -f images.json ]; then |
| 183 | + echo '{"history":[],"build_config":{"board":"turing-rk1","branch":"vendor","release":"bookworm"}}' > images.json |
| 184 | + fi |
| 185 | +
|
| 186 | + # Update images.json with new metadata |
| 187 | + jq --arg version "$VERSION" \ |
| 188 | + --arg kernel "${{ steps.metadata.outputs.kernel }}" \ |
| 189 | + --arg date "$DATE" \ |
| 190 | + --arg filename "${{ steps.metadata.outputs.filename }}" \ |
| 191 | + --arg size "${{ steps.metadata.outputs.size }}" \ |
| 192 | + --arg sha256 "${{ steps.metadata.outputs.sha256 }}" \ |
| 193 | + --arg download_url "$DOWNLOAD_URL" \ |
| 194 | + --arg checksum_url "$CHECKSUM_URL" \ |
| 195 | + --arg release_url "$RELEASE_URL" \ |
| 196 | + '.latest = { |
| 197 | + armbian_version: $version, |
| 198 | + kernel_version: $kernel, |
| 199 | + release: "bookworm", |
| 200 | + branch: "vendor", |
| 201 | + build_date: $date, |
| 202 | + filename: $filename, |
| 203 | + size_bytes: ($size | tonumber), |
| 204 | + sha256: $sha256, |
| 205 | + download_url: $download_url, |
| 206 | + checksum_url: $checksum_url, |
| 207 | + release_url: $release_url |
| 208 | + } | .history = ([{ |
| 209 | + armbian_version: $version, |
| 210 | + build_date: $date, |
| 211 | + release_url: $release_url |
| 212 | + }] + .history[0:9])' images.json > images.json.tmp && mv images.json.tmp images.json |
| 213 | +
|
| 214 | + echo "Updated images.json:" |
| 215 | + cat images.json |
| 216 | +
|
| 217 | + - name: Commit and push changes |
| 218 | + run: | |
| 219 | + git config user.name "github-actions[bot]" |
| 220 | + git config user.email "github-actions[bot]@users.noreply.github.com" |
| 221 | + git add images.json |
| 222 | + git diff --cached --quiet || git commit -m "Update Armbian image metadata for version ${{ needs.check-version.outputs.upstream_version }}" |
| 223 | + git push |
0 commit comments