Skip to content

Commit

Permalink
fix: get ISO filename from build output
Browse files Browse the repository at this point in the history
  • Loading branch information
John Rinehart committed Jan 9, 2022
1 parent 2cd0f03 commit 171003e
Showing 1 changed file with 17 additions and 11 deletions.
28 changes: 17 additions & 11 deletions .github/build_and_split.sh
Original file line number Diff line number Diff line change
Expand Up @@ -7,8 +7,6 @@ GITHUB_WORKSPACE=${GITHUB_WORKSPACE:-$(pwd)}

REPO_DIR=${REPO_DIR:-${GITHUB_WORKSPACE}/repo}
NIX_BUILD_RESULT_ISO_DIR="${REPO_DIR}/result/iso"
NIX_BUILD_RESULT_ISO_NAME="JohnOS-${GITHUB_SHA}.iso"
NIX_BUILD_RESULT_ISO="${NIX_BUILD_RESULT_ISO_DIR}/${NIX_BUILD_RESULT_ISO_NAME}"

SPLIT_DIR=${1:-${GITHUB_WORKSPACE}/split}

Expand All @@ -27,24 +25,32 @@ echo "checking dirty working tree"
git --no-pager diff # see why it's dirty
git --no-pager status # see why it's dirty

tree -l -L 8 ${GITHUB_WORKSPACE}

echo "building the ISO"
nix build .#flash-drive-iso

tree -l -L 8 ${GITHUB_WORKSPACE}

echo "splitting the ISO into pieces"
cd "${NIX_BUILD_RESULT_ISO_DIR}"
NIX_BUILD_RESULT_ISO_NAME="" # default empty
for iso in $(ls -1 *.iso); do
if [[ NIX_BUILD_RESULT_ISO_NAME != "" ]]; then
tree -l L 8 "${GITHUB_WORKSPACE}"
echo "we have more than one built ISO. we shouldn't..."
fi
NIX_BUILD_RESULT_ISO_NAME="${iso}"
done

NIX_BUILD_RESULT_ISO="${NIX_BUILD_RESULT_ISO_DIR}/${NIX_BUILD_RESULT_ISO_NAME}"
split -d -b 128MiB \
"${NIX_BUILD_RESULT_ISO}" \
"${SPLIT_DIR}/JohnOS-${GITHUB_REF_NAME}-${SHORT_SHA}.iso."
"${NIX_BUILD_RESULT_ISO}" \
"${SPLIT_DIR}/JohnOS-*.iso."

echo "generating checksum file"
# generate SHA256 checksums of all relevant files
# generate SHA256 checksums of all pieces
cd "${SPLIT_DIR}"
for i in $(ls *.iso.*); do sha256sum $i >> "${CHECKSUM_FILE}"; done
for i in $(ls -1 JohnOS-*.iso.*); do sha256sum $i >> "${CHECKSUM_FILE}"; done

cd "${NIX_BUILD_RESULT_ISO_DIR}"
# generate SHA256 checksums of original file
cd "${NIX_BUILD_RESULT_ISO_DIR}" # keep only basename in checksum file
sha256sum "${NIX_BUILD_RESULT_ISO_NAME}" >> "${CHECKSUM_FILE}"

tree -l -L 8 ${GITHUB_WORKSPACE}

0 comments on commit 171003e

Please sign in to comment.