Skip to content

Commit 290b1c6

Browse files
authored
Merge pull request #1 from heitbaum/initial
first release of action to build mesa host tools
2 parents 2bfcdd4 + 0859db5 commit 290b1c6

File tree

3 files changed

+352
-0
lines changed

3 files changed

+352
-0
lines changed

.github/workflows/build-mesa-host.yml

Lines changed: 164 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,164 @@
1+
name: build-mesa-host
2+
on:
3+
workflow_dispatch:
4+
inputs:
5+
gitref_to_build:
6+
description: "gitref tag or hash to build"
7+
default: master
8+
required: true
9+
type: string
10+
target:
11+
description: "targets to build"
12+
default: all
13+
required: true
14+
type: choice
15+
options:
16+
- all
17+
- aarch64
18+
- x86_64
19+
schedule:
20+
# The times are specified in UTC
21+
- cron: "15 13 * * *"
22+
23+
env:
24+
debug: debug
25+
ephemeral: ephemeral
26+
27+
jobs:
28+
check_build_tools:
29+
runs-on: ubuntu-latest
30+
permissions:
31+
contents: write
32+
name: Checkout LibreELEC/LibreELEC.tv and check latest commit
33+
outputs:
34+
should_run: ${{ steps.should_run.outputs.should_run }}
35+
hash: ${{ steps.latest_commit.outputs.hash }}
36+
mesa: ${{ steps.tool_version.outputs.mesa }}
37+
osver: ${{ steps.tool_version.outputs.osver }}
38+
release_exists: ${{ steps.check_release.outputs.release_exists }}
39+
release_doesnt_exists: ${{ steps.check_release.outputs.release_doesnt_exists }}
40+
upload_url: ${{ steps.create_release.outputs.upload_url }}
41+
steps:
42+
- uses: actions/checkout@v4
43+
with:
44+
fetch-depth: 0
45+
path: "mesa-reusable"
46+
- uses: actions/checkout@v4
47+
with:
48+
ref: ${{ github.event.inputs.gitref_to_build || 'master' }}
49+
fetch-depth: 2
50+
repository: "${{ github.repository_owner }}/LibreELEC.tv"
51+
path: "LibreELEC.tv"
52+
- id: latest_commit
53+
name: print latest_commit of checked out LibreELEC/LibreELEC.tv
54+
run: |
55+
cd LibreELEC.tv
56+
hash=$(git rev-parse HEAD)
57+
echo "hash=${hash}" >> $GITHUB_OUTPUT
58+
echo ${hash}
59+
echo "mesa:host tools build - ${hash}" > build-log.txt
60+
echo "=====================" >> build-log.txt
61+
- id: tool_version
62+
name: get versions of LibreELEC and mesa
63+
run: |
64+
cd LibreELEC.tv
65+
tools/viewplan mesa:host >> build-log.txt
66+
. config/options
67+
echo "mesa=$(get_pkg_version mesa)" >> $GITHUB_OUTPUT
68+
echo "osver=${OS_VERSION}" >> $GITHUB_OUTPUT
69+
- id: check_release
70+
name: Check for Release
71+
env:
72+
GH_TOKEN: ${{ github.token }}
73+
run: |
74+
cd mesa-reusable
75+
RELEASE_TAG=${{ steps.tool_version.outputs.osver }}-${{ steps.tool_version.outputs.mesa }}
76+
if [ $(git tag -l "${RELEASE_TAG}") ]; then
77+
echo "Tag ${RELEASE_TAG} exists"
78+
set +e
79+
gh release view $RELEASE_TAG
80+
if [[ "$(gh release view $RELEASE_TAG 2>&1)" == "release not found" ]]; then
81+
echo "Release ${RELEASE_TAG} not found."
82+
echo "release_exists=false" >> $GITHUB_OUTPUT
83+
echo "release_doesnt_exists=true" >> $GITHUB_OUTPUT
84+
else
85+
echo "Release ${RELEASE_TAG} found."
86+
echo "release_exists=true" >> $GITHUB_OUTPUT
87+
echo "release_doesnt_exists=false" >> $GITHUB_OUTPUT
88+
fi
89+
else
90+
echo "Tag ${RELEASE_TAG} does not exist"
91+
echo "release_exists=false" >> $GITHUB_OUTPUT
92+
echo "release_doesnt_exists=true" >> $GITHUB_OUTPUT
93+
fi
94+
- id: should_run
95+
name: check if the release doesnt exist so as to create the release
96+
run: |
97+
echo "should_run=${{ steps.check_release.outputs.release_doesnt_exists }}" >> $GITHUB_OUTPUT
98+
- id: create_release
99+
name: release
100+
if: ${{ steps.check_release.outputs.release_exists == 'false' }}
101+
uses: softprops/action-gh-release@v2
102+
with:
103+
draft: false
104+
prerelease: true
105+
name: "reusable mesa:host tools for LibreELEC-${{ steps.tool_version.outputs.osver }} with mesa-${{ steps.tool_version.outputs.mesa }}"
106+
tag_name: ${{ steps.tool_version.outputs.osver }}-${{ steps.tool_version.outputs.mesa }}
107+
body_path: mesa-reusable/CHANGELOG.md
108+
fail_on_unmatched_files: true
109+
files: |
110+
LibreELEC.tv/build-log.txt
111+
112+
# aarch64 (use Amlogic to do the build of mesa)
113+
aarch64:
114+
permissions:
115+
contents: write
116+
name: "aarch64"
117+
# Only run if there is not a release
118+
needs: check_build_tools
119+
if: |
120+
( needs.check_build_tools.outputs.should_run != 'false' )
121+
&& ( github.event.inputs.target == 'all' || github.event.inputs.target == 'aarch64' || github.event_name == 'schedule' )
122+
uses: ./.github/workflows/yml-build-mesa-host.yml
123+
with:
124+
runner: ubuntu-24.04-arm
125+
debug: debug
126+
ephemeral: ephemeral
127+
upload_url: ${{ needs.check_build_tools.outputs.upload_url }}
128+
buildcmd: "scripts/build_mt mesa:host"
129+
gitref: ${{ github.event.inputs.gitref_to_build || 'master' }}
130+
group: aarch64-mesa
131+
project: Amlogic
132+
arch: aarch64
133+
device: AMLGX
134+
targetbuilddir: build.LibreELEC-AMLGX.aarch64-13.0-devel
135+
version: ${{ needs.check_build_tools.outputs.osver }}
136+
mesa: ${{ needs.check_build_tools.outputs.mesa }}
137+
secrets: inherit
138+
139+
# x86_64 (use Amlogic to do the build of mesa)
140+
x86_64:
141+
permissions:
142+
contents: write
143+
name: "x86_64"
144+
# Only run if there has been a commit in the last 24 hours
145+
needs: check_build_tools
146+
if: |
147+
( needs.check_build_tools.outputs.should_run != 'false' )
148+
&& ( github.event.inputs.target == 'all' || github.event.inputs.target == 'x86_64' || github.event_name == 'schedule' )
149+
uses: ./.github/workflows/yml-build-mesa-host.yml
150+
with:
151+
runner: ubuntu-latest
152+
debug: debug
153+
ephemeral: ephemeral
154+
upload_url: ${{ needs.check_build_tools.outputs.upload_url }}
155+
buildcmd: "scripts/build_mt mesa:host"
156+
gitref: ${{ github.event.inputs.gitref_to_build || 'master' }}
157+
group: x86_64-mesa
158+
project: Generic
159+
arch: x86_64
160+
device: Generic
161+
targetbuilddir: build.LibreELEC-Generic.x86_64-13.0-devel
162+
version: ${{ needs.check_build_tools.outputs.osver }}
163+
mesa: ${{ needs.check_build_tools.outputs.mesa }}
164+
secrets: inherit
Lines changed: 187 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,187 @@
1+
name: yml-build-mesa-host
2+
on:
3+
workflow_call:
4+
inputs:
5+
runner:
6+
description: "set runs-on for host arch"
7+
required: true
8+
type: string
9+
debug:
10+
description: "Provide debug output from GHA run"
11+
#default: no_debug
12+
required: true
13+
type: string
14+
ephemeral:
15+
description: "Target and build-root are ephemeral"
16+
#default: ephemeral
17+
required: true
18+
type: string
19+
upload_url:
20+
description: "Release upload url"
21+
required: true
22+
type: string
23+
buildcmd:
24+
description: "build command to run"
25+
#default: "make image"
26+
required: true
27+
type: string
28+
gitref:
29+
description: "git branch or hash to build"
30+
#default: libreelec-13.0
31+
required: true
32+
type: string
33+
group:
34+
description: "concurrency group"
35+
#default: Generic_x86_64-10_0
36+
required: true
37+
type: string
38+
project:
39+
description: "target project"
40+
#default: Generic
41+
required: true
42+
type: string
43+
arch:
44+
description: "target arch"
45+
#default: x86_64
46+
required: true
47+
type: string
48+
device:
49+
description: "target device"
50+
default: ""
51+
required: false
52+
type: string
53+
targetbuilddir:
54+
description: "TARGETBUILDDIR"
55+
#default: ""
56+
required: true
57+
type: string
58+
version:
59+
description: "version code used in TARGETBUILDDIR"
60+
required: true
61+
type: string
62+
mesa:
63+
description: "mesa version we are building"
64+
required: true
65+
type: string
66+
67+
env:
68+
BASEDIR: /var/media/DATA/github-actions
69+
# Distro Target Variables
70+
PROJECT: ${{ inputs.project }}
71+
ARCH: ${{ inputs.arch }}
72+
DEVICE: ${{ inputs.device }}
73+
TARGETBUILDDIR: ${{ inputs.targetbuilddir }}
74+
LE_DISTRO_VERSION: ${{ inputs.version }}
75+
MESA_VERSION: ${{ inputs.mesa }}
76+
77+
concurrency:
78+
group: ${{ inputs.group }}
79+
cancel-in-progress: false
80+
81+
jobs:
82+
build_image:
83+
runs-on: ${{ inputs.runner }}
84+
permissions:
85+
contents: write
86+
87+
timeout-minutes: 360
88+
89+
steps:
90+
- uses: actions/checkout@v4
91+
with:
92+
ref: ${{ inputs.gitref }}
93+
fetch-depth: 2
94+
repository: "${{ github.repository_owner }}/LibreELEC.tv"
95+
path: "LibreELEC.tv"
96+
97+
- name: Customise the checked out git repository
98+
run: |
99+
cd LibreELEC.tv
100+
sed -i -e "s/RUN useradd docker/RUN useradd docker -o -u $(id -u)/" tools/docker/noble/Dockerfile
101+
sed -i -e 's/BUILD_REUSABLE=""/BUILD_REUSABLE="mesa:host"/' distributions/LibreELEC/options
102+
103+
- name: Create docker image for build - tools/docker/noble
104+
run: |
105+
cd LibreELEC.tv
106+
docker build --pull -t gh-${{ github.run_id }} tools/docker/noble
107+
108+
- name: Prepare the LibreELEC.tv directory - do not leave files behind
109+
if: inputs.ephemeral == 'ephemeral'
110+
run: |
111+
cd LibreELEC.tv
112+
# set the build_dir=/build
113+
echo "build_dir=/build" >> $GITHUB_ENV
114+
echo "CCACHE_DISABLE=1" >> $GITHUB_ENV
115+
116+
- name: Display environment
117+
if: inputs.debug == 'debug'
118+
run: |
119+
cd LibreELEC.tv
120+
echo "pwd: $(pwd)"
121+
echo "id: $(id)"
122+
echo "whoami: $(whoami)"
123+
echo "docker images: $(docker images)"
124+
echo ""
125+
echo "inputs.debug: ${{ inputs.debug }}"
126+
echo "inputs.ephemeral: ${{ inputs.ephemeral }}"
127+
128+
- name: Build LE in docker container
129+
run: |
130+
cd LibreELEC.tv
131+
docker run --rm -v `pwd`:/build \
132+
-w /build -i \
133+
-e PROJECT=${{ env.PROJECT }} \
134+
-e ARCH=${{ env.ARCH }} \
135+
-e DEVICE=${{ env.DEVICE }} \
136+
-e ONELOG=no -e LOGCOMBINE=fail \
137+
-e BUILD_DIR=${{ env.build_dir }} \
138+
-e BUILD_PERIODIC=nightly \
139+
-e CCACHE_DISABLE=${{ env.CCACHE_DISABLE }} \
140+
gh-${{ github.run_id }} ${{ inputs.buildcmd }} ${{ env.NOOBS }}
141+
continue-on-error: true
142+
143+
- name: Prepare artifacts - ephemeral
144+
if: inputs.ephemeral == 'ephemeral'
145+
run: |
146+
cd LibreELEC.tv
147+
mkdir -p ${{ env.TARGETBUILDDIR }}/artifact
148+
grep ^FAIL ${{ env.TARGETBUILDDIR }}/.threads/joblog | \
149+
awk '{ print $5, $12 }' | tr ':' '_' | \
150+
while read failedpkg failedlog; do
151+
mv $(echo ${failedlog} | sed 's#/build/##') \
152+
${{ env.TARGETBUILDDIR }}/artifact/${{ env.TARGETBUILDDIR }}-${failedpkg}-$(echo ${failedlog} | sed 's#.*/##')
153+
done
154+
155+
- name: Upload failed artifacts - ephemeral
156+
if: inputs.ephemeral == 'ephemeral'
157+
uses: actions/upload-artifact@v4
158+
with:
159+
name: ${{ inputs.group }}-failed
160+
path: LibreELEC.tv/${{ env.TARGETBUILDDIR }}/artifact/
161+
if-no-files-found: ignore
162+
163+
- name: Clean up - remove docker image tag
164+
run: |
165+
cd LibreELEC.tv
166+
docker image rm -f gh-${{ github.run_id }}
167+
168+
- name: List files in target
169+
run: |
170+
cd LibreELEC.tv
171+
ls -lah target/
172+
173+
- name: upload reusable mesa:host tools
174+
uses: shogo82148/actions-upload-release-asset@v1
175+
with:
176+
upload_url: ${{ inputs.upload_url }}
177+
asset_path: LibreELEC.tv/target/mesa-reusable-${{ inputs.version }}-${{ inputs.mesa }}-${{ inputs.arch }}.tar
178+
asset_content_type: application/tar
179+
github_token: ${{ github.token }}
180+
181+
- name: upload reusable mesa:host tools sha256
182+
uses: shogo82148/actions-upload-release-asset@v1
183+
with:
184+
upload_url: ${{ inputs.upload_url }}
185+
asset_path: LibreELEC.tv/target/mesa-reusable-${{ inputs.version }}-${{ inputs.mesa }}-${{ inputs.arch }}.tar.sha256
186+
asset_content_type: text/plain
187+
github_token: ${{ github.token }}

CHANGELOG.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
This release contains the reusable mesa:host tools for LibreELEC builds. This package is downloaded and unpacked by the mesa-reusable package in the LibreELEC build when building with USE_REUSABLE="yes".

0 commit comments

Comments
 (0)