-
Notifications
You must be signed in to change notification settings - Fork 17
137 lines (124 loc) · 4.82 KB
/
build.yaml
File metadata and controls
137 lines (124 loc) · 4.82 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
name: Build OpenMowerOS (pi-gen)
on:
workflow_dispatch:
push:
branches:
- main
tags:
- v*.*.*
paths:
- build_image.sh
- pi-gen.config
- stage-openmower/**
- .github/workflows/build.yaml
pull_request:
branches:
- main
- v2-rework
# Allow stopping obsolete workflows
concurrency:
group: ci-pigen-${{ github.ref }}
cancel-in-progress: true
permissions:
contents: write
jobs:
build:
runs-on: ubuntu-24.04-arm
steps:
- name: Checkout repository (with submodules)
uses: actions/checkout@v4
with:
submodules: true
- name: Install dependencies
run: |
sudo apt-get update
sudo apt-get install -y coreutils quilt parted qemu-user-static debootstrap zerofree zip \
dosfstools e2fsprogs libarchive-tools libcap2-bin grep rsync xz-utils file git curl bc \
gpg pigz xxd arch-test bmap-tools
- name: Docker info and loop device
run: |
docker --version
sudo modprobe loop || true
- name: Build image with pi-gen (clean)
env:
FRESH: "1"
# Provide GitHub token so stage-openmower/40-openmower/00-run-chroot.sh can authenticate
# the GitHub API call for fetching the latest openmower-cli release (avoids 403 rate limits)
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
run: |
sudo -E bash -x ./build_image.sh
- name: Prepare release context (tag vs latest)
id: rel
shell: bash
run: |
set -euo pipefail
if [[ "${GITHUB_REF}" == refs/tags/* ]]; then
TAG="${GITHUB_REF#refs/tags/}"
echo "base_url=https://github.com/${GITHUB_REPOSITORY}/releases/download/${TAG}/" >> "$GITHUB_OUTPUT"
echo "release_tag=${TAG}" >> "$GITHUB_OUTPUT"
echo "prerelease=false" >> "$GITHUB_OUTPUT"
else
echo "base_url=https://github.com/${GITHUB_REPOSITORY}/releases/latest/download/" >> "$GITHUB_OUTPUT"
echo "release_tag=latest" >> "$GITHUB_OUTPUT"
echo "prerelease=true" >> "$GITHUB_OUTPUT"
fi
- name: Upload build logs (on failure)
if: failure()
uses: actions/upload-artifact@v4
with:
name: pigen-build-logs
path: |
ext/pi-gen/deploy/build.log
ext/pi-gen/deploy/build-docker.log
- name: List deploy outputs
run: |
ls -l ext/pi-gen/deploy || true
- name: Collect artifacts to ./artifacts
id: collect
shell: bash
run: |
set -euo pipefail
mkdir -p artifacts
latest_zip=$(ls -t ext/pi-gen/deploy/*.zip 2>/dev/null | head -n1 || true)
if [[ -z "$latest_zip" ]]; then
echo "No ZIP found in ext/pi-gen/deploy" >&2
exit 1
fi
if [[ "$latest_zip" =~ image_([0-9]{4})-([0-9]{2})-([0-9]{2})-.*\.zip$ ]]; then
y=${BASH_REMATCH[1]}; m=${BASH_REMATCH[2]}; d=${BASH_REMATCH[3]}
date_compact="${y}${m}${d}"
else
date_compact=$(date -u +%Y%m%d)
fi
# Create two artifacts: raw .img for GH artifact (GH auto-zips), and a .zip for releases
img_in_zip=$(bsdtar -tf "${latest_zip}" | grep -E '\.img$' | head -n1)
if [[ -z "${img_in_zip}" ]]; then
echo "No .img found inside ${latest_zip}" >&2
echo "Archive content was:" >&2
bsdtar -tf "${latest_zip}" >&2
exit 1
fi
bsdtar -xf "${latest_zip}" -C artifacts "${img_in_zip}"
mv "artifacts/${img_in_zip}" "artifacts/OpenMowerOS_${date_compact}.img"
out_zip="artifacts/OpenMowerOS_${date_compact}.zip"
zip -9 -j "${out_zip}" "artifacts/OpenMowerOS_${date_compact}.img"
# Clean up temp to save space
ls -l artifacts
# Expose outputs for downstream steps
echo "artifact_name=OpenMowerOS_${date_compact}" >> "$GITHUB_OUTPUT"
echo "img_path=artifacts/OpenMowerOS_${date_compact}.img" >> "$GITHUB_OUTPUT"
- name: Upload build artifacts (raw .img)
uses: actions/upload-artifact@v4
with:
name: ${{ steps.collect.outputs.artifact_name }}
path: ${{ steps.collect.outputs.img_path }}
- name: Publish release/prerelease
if: github.event_name == 'workflow_dispatch' || startsWith(github.ref, 'refs/heads/main') || startsWith(github.ref, 'refs/tags/')
uses: marvinpinto/action-automatic-releases@latest
with:
repo_token: ${{ secrets.GITHUB_TOKEN }}
automatic_release_tag: ${{ steps.rel.outputs.release_tag }}
prerelease: ${{ steps.rel.outputs.prerelease }}
title: OpenMowerOS ${{ steps.rel.outputs.release_tag }}
files: |
artifacts/OpenMowerOS_*.zip