Repository navigation
Expand file tree
/
Copy pathbuild-armbian-x86-server-image.yml
More file actions
207 lines (185 loc) · 7.93 KB
/
Copy pathbuild-armbian-x86-server-image.yml
File metadata and controls
207 lines (185 loc) · 7.93 KB
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
206
207
#==========================================================================
# Description: Build Armbian x86 server image
# Copyright (C) 2021 https://github.com/ophub/amlogic-s9xxx-armbian
#==========================================================================
name: Build Armbian x86 server image
on:
repository_dispatch:
workflow_dispatch:
inputs:
set_release:
description: "Select OS Release."
required: false
default: "all"
type: choice
options:
- all
- trixie
- bookworm
- resolute
- noble
publish_docker:
description: "Publish Docker image"
required: false
default: "ophub/armbian"
type: choice
options:
- ophub/armbian
- none
env:
TZ: Etc/UTC
ROOTFS_SCRIPT: compile-kernel/tools/script/docker/build_armbian_rootfs_file.sh
MAKE_DOCKER_SH: compile-kernel/tools/script/docker/build_armbian_docker_image.sh
jobs:
setup:
runs-on: ubuntu-24.04
outputs:
matrix: ${{ steps.set-matrix.outputs.matrix }}
steps:
- name: Set build matrix based on set_release input
id: set-matrix
run: |
if [[ "${{ inputs.set_release }}" == "all" ]]; then
MATRIX='{"include":[{"release":"trixie"},{"release":"bookworm"},{"release":"resolute"},{"release":"noble"}]}'
else
MATRIX='{"include":[{"release":"${{ inputs.set_release }}"}]}'
fi
echo "matrix=${MATRIX}" >> "${GITHUB_OUTPUT}"
build:
needs: setup
runs-on: ubuntu-24.04
if: ${{ github.event.repository.owner.id == github.event.sender.id }}
permissions:
contents: write
strategy:
fail-fast: false
matrix: ${{ fromJSON(needs.setup.outputs.matrix) }}
name: build-armbian-x86-${{ matrix.release }}
steps:
- name: Checkout
uses: actions/checkout@v6
- name: Initialize the build environment
id: init
env:
DEBIAN_FRONTEND: noninteractive
run: |
docker rmi -f $(docker images -q) 2>/dev/null || true
[[ -n "${AGENT_TOOLSDIRECTORY}" ]] && sudo rm -rf "${AGENT_TOOLSDIRECTORY}"
sudo rm -rf /usr/share/dotnet /usr/local/lib/android 2>/dev/null
sudo swapoff -a
sudo rm -f /swapfile /mnt/swapfile
sudo apt-get -y update
sudo apt-get -y purge azure-cli ghc* zulu* llvm* firefox google* dotnet* powershell openjdk* mongodb* moby* || true
sudo apt-get -y install $(curl -fsSL https://ophub.org/ubuntu2404-build-armbian-depends)
sudo systemctl daemon-reload
#sudo apt-get -y full-upgrade
sudo apt-get -y autoremove --purge
sudo apt-get clean
sudo sed -i '/NVM_DIR/d;/skel/d' /root/{.bashrc,.profile}
sudo rm -rf ~/{.cargo,.dotnet,.rustup}
sudo timedatectl set-timezone "${TZ:-Etc/UTC}"
sudo ntpdate ntp.ubuntu.com 0.pool.ntp.org || true
sudo timedatectl set-ntp true
date -u
timedatectl status || true
echo "status=success" >> ${GITHUB_OUTPUT}
- name: Create virtual disk for extended storage
id: disk
run: |
# Get available space in exact GB
root_avail=$(df --block-size=1G / | tail -1 | awk '{print $4}')
root_size=$(( root_avail - 4 ))
[[ "${root_size}" -gt 0 ]] || { echo "Error: Insufficient space on /: ${root_avail}G available"; exit 1; }
sudo truncate -s "${root_size}"G /root.img
build_dev=$(sudo losetup --find --show /root.img)
echo "Using /: ${root_size}G"
sudo mkfs.xfs -f -i sparse=0 -b size=4096 "${build_dev}"
sudo mkdir -p /builder
sudo mount "${build_dev}" /builder
sudo chown -R runner:runner /builder
df -Th
echo "status=success" >> ${GITHUB_OUTPUT}
- name: Download source code
id: down
working-directory: /builder
if: ${{ steps.init.outputs.status == 'success' && !cancelled() }}
run: |
df -hT ${PWD}
git clone -q --single-branch --depth=1 --branch=main https://github.com/armbian/build.git build
ln -sf /builder/build ${{ github.workspace }}/build
echo "status=success" >> ${GITHUB_OUTPUT}
- name: Compile Armbian [ ${{ matrix.release }} ]
id: compile
working-directory: /builder
if: ${{ steps.down.outputs.status == 'success' && !cancelled() }}
run: |
# Enable QEMU emulation for ARM cross-compilation
docker run --rm --privileged multiarch/qemu-user-static --reset -p yes 2>/dev/null || true
# Compile options reference: https://docs.armbian.com/Developer-Guide_Build-Options
cd build/
./compile.sh RELEASE=${{ matrix.release }} BOARD=uefi-x86 BRANCH=current BUILD_MINIMAL=no \
BUILD_ONLY=default HOST=armbian BUILD_DESKTOP=no EXPERT=yes KERNEL_CONFIGURE=no \
COMPRESS_OUTPUTIMAGE="sha" SHARE_LOG=yes
echo "status=success" >> ${GITHUB_OUTPUT}
- name: Organize output files and reclaim disk space
id: clean
if: ${{ steps.compile.outputs.status == 'success' && !cancelled() }}
run: |
# Extract essential artifacts and remove build files
chmod +x ${ROOTFS_SCRIPT}
${ROOTFS_SCRIPT} -v ${{ matrix.release }} -s true -c true -k false -p amd64
# Remove build files while preserving output
[[ -d "armbian" ]] || mkdir armbian
cp -af build/output/images/* armbian/
rm -rf build
# Display disk usage after cleanup
df -hT ${PWD}
echo "build_tag=Armbian_amd64_server_$(date +"%Y.%m")" >> ${GITHUB_ENV}
echo "status=success" >> ${GITHUB_OUTPUT}
- name: Build the Docker image
id: makedocker
if: ${{ inputs.publish_docker != 'none' && !cancelled() }}
run: |
chmod +x ${MAKE_DOCKER_SH}
${MAKE_DOCKER_SH} ${{ matrix.release }} amd64
echo "status=success" >> ${GITHUB_OUTPUT}
- name: Upload Armbian image to Release
uses: ophub/upload-to-releases@main
if: ${{ steps.clean.outputs.status == 'success' && !cancelled() }}
with:
tag: ${{ env.build_tag }}
artifacts: "armbian/*,out/*"
allow_updates: true
remove_artifacts: false
replaces_artifacts: true
make_latest: false
gh_token: ${{ secrets.GITHUB_TOKEN }}
body: |
### Armbian Image Information
- Default username: `root`
- Default password: `1234`
### Applicable Platform
- 💻 `amd64(uefi-x86)`
- 🐋 Docker image: https://hub.docker.com/u/ophub
- name: Login to Docker Hub
id: login
if: ${{ steps.makedocker.outputs.status == 'success' && !cancelled() }}
uses: docker/login-action@v4
with:
username: ${{ secrets.DOCKERHUB_USERNAME }}
password: ${{ secrets.DOCKERHUB_PASSWORD }}
- name: Load and push image to Docker Hub
id: push
if: ${{ steps.makedocker.outputs.status == 'success' && !cancelled() }}
run: |
# Load the offline Docker image built by build_armbian_docker_image.sh
offline_image="$(ls out/*.tar.gz 2>/dev/null | head -n 1)"
[[ -z "${offline_image}" ]] && echo "Error: No offline image found." && exit 1
loaded_image="$(docker load -i "${offline_image}" | grep -oP 'Loaded image: \K.*')"
[[ -z "${loaded_image}" ]] && echo "Error: Failed to load Docker image." && exit 1
echo "Loaded image: ${loaded_image}"
# Tag for Docker Hub
docker tag "${loaded_image}" "${{ inputs.publish_docker }}-${{ matrix.release }}:amd64"
# Push to Docker Hub
docker push "${{ inputs.publish_docker }}-${{ matrix.release }}:amd64"
echo "status=success" >> ${GITHUB_OUTPUT}