Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Bring build action up to date #5

Merged
merged 3 commits into from
Nov 20, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
27 changes: 17 additions & 10 deletions .github/workflows/build_img.yml
Original file line number Diff line number Diff line change
Expand Up @@ -10,11 +10,15 @@ on:
workflow_call:
inputs:
deb-file-name:
required: true
required: false
type: string
deb-url:
description: 'URL for Kolibri deb file'
required: false
type: string
ref:
description: 'A ref for this workflow to check out its own repo'
required: true
required: false
type: string
outputs:
zip-file-name:
Expand All @@ -28,6 +32,11 @@ jobs:
outputs:
zip-file-name: ${{ steps.get-zip-filename.outputs.zip-file-name }}
steps:
- name: Validate deb reference inputs
if: ${{ (inputs.deb-file-name && inputs.deb-url) || (!inputs.deb-file-name && !inputs.deb-url) }}
run: |
echo "Must specify only one reference for the deb file to build the image with."
exit 1
- uses: actions/checkout@v4
if: ${{ !inputs.ref }}
- uses: actions/checkout@v4
Expand All @@ -36,8 +45,8 @@ jobs:
repository: learningequality/kolibri-image-pi
ref: ${{ inputs.ref }}
- name: Download the debfile from URL and install
if: ${{ github.event.inputs.deb-url }}
run: make get-deb deb=${{ github.event.inputs.deb-url }}
if: ${{ inputs.deb-url }}
run: make get-deb deb=${{ inputs.deb-url }}
- name: Download the debfile from artifacts
if: ${{ inputs.deb-file-name }}
uses: actions/download-artifact@v4
Expand All @@ -55,7 +64,7 @@ jobs:
uses: actions/cache@v4
with:
path: 'images/base.img'
key: ${{ runner.OS }}-base-${{ hashFiles('base.Pifle', 'files/*') }}
key: ${{ runner.OS }}-base-${{ hashFiles('base.Pifile', 'files/*') }}
restore-keys: |
${{ runner.OS }}-base-
- name: Cache pimod
Expand All @@ -66,13 +75,11 @@ jobs:
restore-keys: |
${{ runner.OS }}-pimod-
- name: Build Pi image
run: |
make images
zip Kolibri.zip images/Kolibri.img
run: make zipfile
- name: Get ZIP filename
id: get-zip-filename
run: echo "zip-file-name=Kolibri.zip" >> $GITHUB_OUTPUT
run: echo "zip-file-name=$(ls dist | grep .zip | cat)" >> $GITHUB_OUTPUT
- uses: actions/upload-artifact@v4
with:
name: ${{ steps.get-zip-filename.outputs.zip-file-name }}
path: ${{ steps.get-zip-filename.outputs.zip-file-name }}
path: dist/${{ steps.get-zip-filename.outputs.zip-file-name }}
18 changes: 15 additions & 3 deletions Makefile
Original file line number Diff line number Diff line change
@@ -1,5 +1,7 @@
.PHONY: get-deb clean-deb clean-images clean-tools clean install-dependencies

DIST_DIR := dist

SOURCE_FILE = images/source.xz
SOURCE_URL = https://downloads.raspberrypi.com/raspios_lite_arm64/images/raspios_lite_arm64-2024-10-28/2024-10-22-raspios-bookworm-arm64-lite.img.xz

Expand All @@ -13,13 +15,13 @@ clean-tools:
rm -rf pimod

clean-deb:
rm -rf dist
mkdir dist
rm -rf $(DIST_DIR)
mkdir $(DIST_DIR)

get-deb: clean-deb
# The eval and shell commands here are evaluated when the recipe is parsed, so we put the cleanup
# into a prerequisite make step, in order to ensure they happen prior to the download.
$(eval DLFILE = $(shell wget --content-disposition -P dist/ "${deb}" 2>&1 | grep "Saving to: " | sed 's/Saving to: ‘//' | sed 's/’//'))
$(eval DLFILE = $(shell wget --content-disposition -P $(DIST_DIR)/ "${deb}" 2>&1 | grep "Saving to: " | sed 's/Saving to: ‘//' | sed 's/’//'))
$(eval DEBFILE = $(shell echo "${DLFILE}" | sed "s/\?.*//"))
[ "${DLFILE}" = "${DEBFILE}" ] || mv "${DLFILE}" "${DEBFILE}"

Expand Down Expand Up @@ -54,3 +56,13 @@ images: install-dependencies
$(MAKE) images/source.img
$(MAKE) images/base.img
$(MAKE) images/Kolibri.img

zipfile: images
# Get the version based on the debian file name kolibri_<version>-Xubuntu1_all.deb
$(eval VERSION=$(shell ls ${DIST_DIR} | grep kolibri | sed -r 's/kolibri_(.*)-[0-9]+ubuntu1_all.deb/\1/'))
# Rename the image file to include the version
mv images/Kolibri.img images/kolibri-pi-image-$(VERSION).img
# Zip the image file
zip -j $(DIST_DIR)/kolibri-pi-image-$(VERSION).zip images/kolibri-pi-image-$(VERSION).img
# Clean up the final image file
rm images/kolibri-pi-image-$(VERSION).img