From 92449ab571592ee1496c1df011909f4873e21c19 Mon Sep 17 00:00:00 2001 From: robotrapta <79607467+robotrapta@users.noreply.github.com> Date: Mon, 11 Dec 2023 14:55:02 -0800 Subject: [PATCH] Release assets include tag name instead of datestamp (#7) * Renames release artifacts to include tag name instead of datestamp. * dobuild exits on error. * Fixing yaml indentation. --- .github/workflows/build-images.yaml | 11 ++----- dobuild.sh | 49 +++++++++++++++++++++++++++-- gl-config | 4 +-- 3 files changed, 51 insertions(+), 13 deletions(-) diff --git a/.github/workflows/build-images.yaml b/.github/workflows/build-images.yaml index dfc4b73..b353333 100644 --- a/.github/workflows/build-images.yaml +++ b/.github/workflows/build-images.yaml @@ -31,16 +31,9 @@ jobs: echo "IS_RELEASE=0" >> $GITHUB_ENV fi - # Build image with docker - name: Build the full images run: | - if [[ ${IS_RELEASE} == "1" ]]; then - # Do a release build. - ./build-docker.sh -c gl-config-release - else - # faster test build. - ./build-docker.sh -c gl-config - fi + ./dobuild.sh # Print output directory files - name: List output files @@ -51,7 +44,7 @@ jobs: uses: actions/upload-artifact@v3 with: name: rpios-image - path: ./deploy/image_*.img.xz + path: ./deploy/GroundlightPi-*.img.xz if-no-files-found: error - name: Upload debug artifacts diff --git a/dobuild.sh b/dobuild.sh index af7c12b..6949bd6 100755 --- a/dobuild.sh +++ b/dobuild.sh @@ -2,6 +2,51 @@ # local build - seems like maybe it's leaking system resources sometimes? # time sudo $@ ./build.sh -c gl-config - +# Instead we'll use docker build, which is slower but more reliable. # docker build - slower but more reliable. -time PRESERVE_CONTAINER=1 $@ ./build-docker.sh -c gl-config + +set -e # exit on error + +# check if the IS_RELEASE variable is set to "1" +if [ "$IS_RELEASE" = "1" ]; then + echo "Building release version" + CONFIG_FILE=gl-config-release + rm -rf ./deploy +else + echo "Building dev version" + CONFIG_FILE=gl-config +fi + +time PRESERVE_CONTAINER=1 $@ ./build-docker.sh -c $CONFIG_FILE + +# If it's a release, rename the image files to include the tag name +# and take out the date. +if [ "$IS_RELEASE" = "1" ]; then + TAG_NAME=${GITHUB_REF#refs/tags/} + # See if tag name is set + if [ -z "$TAG_NAME" ]; then + echo "No tag name set. Expecting TAG_NAME for release buid." + exit 1 + fi + + cd deploy + # Loop over every file named "image_*.img.xz" + for file in ./image_*.img.xz; do + # Get the filename without the path + filename=$(basename -- "$file") + + # Files are named like image_2023-12-10-GroundlightPi-sdk.img.xz + # Figure out the variant name by removing the image_date- prefix + variant=$(echo $filename | cut -d '-' -f5-) + # check that $variant is not empty, and does not include "Groundlight" + if [ -z "$variant" ] || [[ "$variant" == *"Groundlight"* ]]; then + echo "Failed to parse filename $filename - got $variant" + exit 1 + fi + new_file="GroundlightPi-$TAG_NAME-$variant.img.xz" + + # Rename the file + echo "Renaming $file to $new_file" + mv "$file" "$new_file" + done +fi diff --git a/gl-config b/gl-config index f0bae9f..7287682 100644 --- a/gl-config +++ b/gl-config @@ -1,6 +1,6 @@ # The config file defining the Groundlight MNS image. -IMG_NAME='GroundlightMNS' -TARGET_HOSTNAME=GroundlightMNS +IMG_NAME='GroundlightPi' +TARGET_HOSTNAME=GroundlightPi FIRST_USER_NAME=groundlight #