Skip to content

Commit

Permalink
Release assets include tag name instead of datestamp (#7)
Browse files Browse the repository at this point in the history
* Renames release artifacts to include tag name instead of datestamp.

* dobuild exits on error.

* Fixing yaml indentation.
  • Loading branch information
robotrapta authored Dec 11, 2023
1 parent d87ad2a commit 92449ab
Show file tree
Hide file tree
Showing 3 changed files with 51 additions and 13 deletions.
11 changes: 2 additions & 9 deletions .github/workflows/build-images.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -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
Expand Down
49 changes: 47 additions & 2 deletions dobuild.sh
Original file line number Diff line number Diff line change
Expand Up @@ -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
4 changes: 2 additions & 2 deletions gl-config
Original file line number Diff line number Diff line change
@@ -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

#
Expand Down

0 comments on commit 92449ab

Please sign in to comment.