Skip to content

Commit

Permalink
Merge pull request #18 from learningequality/an_image_by_any_other_na…
Browse files Browse the repository at this point in the history
…me_would_be_just_as_big

Update file naming to include version information
  • Loading branch information
rtibbles authored Apr 4, 2024
2 parents dd68525 + dbfe813 commit aadf3ca
Show file tree
Hide file tree
Showing 4 changed files with 84 additions and 5 deletions.
19 changes: 15 additions & 4 deletions .github/workflows/build_zip.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/pi-gen
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 @@ -46,6 +55,8 @@ jobs:
path: dist
- name: Build the pi image
run: ./build-docker.sh
- name: Rename the pi image and zip file
run: make rename-zip
- name: Get ZIP filename
id: get-zip-filename
run: echo "::set-output name=zip-file-name::$(ls deploy | grep .zip | cat)"
Expand Down
53 changes: 53 additions & 0 deletions .github/workflows/pr_build.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,53 @@
name: Build Pi image for PRs

on:
pull_request:
branches:
- master

jobs:
pre_job:
name: Path match check
runs-on: ubuntu-latest
# Map a step output to a job output
outputs:
should_skip: ${{ steps.skip_check.outputs.should_skip }}
steps:
- id: skip_check
uses: fkirc/skip-duplicate-actions@master
with:
github_token: ${{ github.token }}
paths_ignore: '["**.po", "**.json"]'
latest_kolibri_release:
needs: pre_job
if: ${{ needs.pre_job.outputs.should_skip != 'true' }}
runs-on: ubuntu-latest
outputs:
deb-url: ${{ steps.get_latest_kolibri_release.outputs.result }}
steps:
- name: Get latest Kolibri release
id: get_latest_kolibri_release
uses: actions/github-script@v7
with:
result-encoding: string
script: |
const { data: releases } = await github.rest.repos.listReleases({
owner: 'learningequality',
repo: 'kolibri',
per_page: 1,
page: 1,
});
const latestRelease = releases[0];
const debAsset = latestRelease.assets.find(asset => asset.name.endsWith('.deb'));
const debUrl = debAsset.browser_download_url;
return debUrl;
build_zip:
name: Build Image
needs: [pre_job, latest_kolibri_release]
if: ${{ needs.pre_job.outputs.should_skip != 'true' }}
uses: ./.github/workflows/build_zip.yml
with:
deb-url: ${{ needs.latest_kolibri_release.outputs.deb-url }}
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
deploy/*
work/*
dist/*
postrun.sh
.pc
*-pc
Expand Down
16 changes: 15 additions & 1 deletion Makefile
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
.PHONY: get-deb clean-deb
.PHONY: get-deb clean-deb rename-zip

DIST_DIR := dist

Expand All @@ -21,3 +21,17 @@ get-deb: clean-deb
unzip -d $(DIST_DIR)/ $(DIST_DIR)/$(DLFILE); \
rm $(DIST_DIR)/$(DLFILE); \
fi

rename-zip:
# Unzip the file so we can rename the image file
unzip -o deploy/image_Kolibri-lite.zip -d deploy
# Clean up the original zip file
rm deploy/image_Kolibri-lite.zip
# Get the version based on the debian file name kolibri_<version>-0ubuntu1_all.deb
$(eval VERSION=$(shell ls ${DIST_DIR} | grep kolibri | sed 's/kolibri_\(.*\)-0ubuntu1_all.deb/\1/'))
# Rename the image file to include the version
mv deploy/Kolibri-lite.img deploy/kolibri-pi-image-$(VERSION).img
# Zip the image file back up
zip -j deploy/kolibri-pi-image-$(VERSION).zip deploy/kolibri-pi-image-$(VERSION).img
# Clean up the extracted image file
rm deploy/kolibri-pi-image-$(VERSION).img

0 comments on commit aadf3ca

Please sign in to comment.