2023-06-11 14:32:03 +00:00
|
|
|
#!/bin/bash
|
|
|
|
#
|
|
|
|
# packager.io before script
|
|
|
|
#
|
|
|
|
|
|
|
|
set -eu
|
|
|
|
|
|
|
|
# The sha is the second element in APP_PKG_ITERATION
|
2024-07-18 05:35:09 +00:00
|
|
|
VERSION="$APP_PKG_VERSION-$APP_PKG_ITERATION"
|
2023-06-11 14:32:03 +00:00
|
|
|
SHA=$(echo $APP_PKG_ITERATION | cut -d'.' -f2)
|
|
|
|
|
|
|
|
# Download info
|
2024-07-18 05:35:09 +00:00
|
|
|
echo "INFO collection | Getting info from github for commit $SHA"
|
|
|
|
curl -L -s -f \
|
2023-06-11 14:32:03 +00:00
|
|
|
-H "Accept: application/vnd.github+json" \
|
|
|
|
-H "X-GitHub-Api-Version: 2022-11-28" \
|
2024-07-18 22:49:51 +00:00
|
|
|
https://api.github.com/repos/$APP_REPO/commits/$SHA > commit.json
|
2024-07-18 05:35:09 +00:00
|
|
|
echo "INFO collection | Got commit.json with size $(wc -c commit.json)"
|
|
|
|
curl -L -s -f \
|
2023-06-11 14:32:03 +00:00
|
|
|
-H "Accept: application/vnd.github+json" \
|
|
|
|
-H "X-GitHub-Api-Version: 2022-11-28" \
|
2024-07-18 22:49:51 +00:00
|
|
|
https://api.github.com/repos/$APP_REPO/commits/$SHA/branches-where-head > branches.json
|
2024-07-18 05:35:09 +00:00
|
|
|
echo "INFO collection | Got branches.json with size $(wc -c branches.json)"
|
|
|
|
curl -L -s -f \
|
|
|
|
-H "Accept: application/vnd.github+json" \
|
|
|
|
-H "X-GitHub-Api-Version: 2022-11-28" \
|
2024-07-18 22:49:51 +00:00
|
|
|
https://api.github.com/repos/$APP_REPO/commits/$APP_PKG_VERSION > tag.json
|
2024-07-18 05:35:09 +00:00
|
|
|
echo "INFO collection | Got tag.json with size $(wc -c tag.json)"
|
2023-06-11 14:32:03 +00:00
|
|
|
|
|
|
|
# Extract info
|
2024-07-18 05:35:09 +00:00
|
|
|
echo "INFO extract | Extracting info from github"
|
2023-06-11 14:32:03 +00:00
|
|
|
DATE=$(jq -r '.commit.committer.date' commit.json)
|
|
|
|
BRANCH=$(jq -r '.[].name' branches.json)
|
|
|
|
NODE_ID=$(jq -r '.node_id' commit.json)
|
|
|
|
SIGNATURE=$(jq -r '.commit.verification.signature' commit.json)
|
2024-07-18 05:35:09 +00:00
|
|
|
FULL_SHA=$(jq -r '.sha' commit.json)
|
2023-06-11 14:32:03 +00:00
|
|
|
|
2024-07-18 05:35:09 +00:00
|
|
|
echo "INFO write | Write VERSION information"
|
|
|
|
echo "$VERSION" > VERSION
|
2023-06-11 14:32:03 +00:00
|
|
|
echo "INVENTREE_COMMIT_HASH='$SHA'" >> VERSION
|
2024-07-18 05:35:09 +00:00
|
|
|
echo "INVENTREE_COMMIT_SHA='$FULL_SHA'" >> VERSION
|
2023-06-11 14:32:03 +00:00
|
|
|
echo "INVENTREE_COMMIT_DATE='$DATE'" >> VERSION
|
|
|
|
echo "INVENTREE_PKG_INSTALLER='PKG'" >> VERSION
|
|
|
|
echo "INVENTREE_PKG_BRANCH='$BRANCH'" >> VERSION
|
|
|
|
echo "INVENTREE_PKG_TARGET='$TARGET'" >> VERSION
|
|
|
|
echo "NODE_ID='$NODE_ID'" >> VERSION
|
|
|
|
echo "SIGNATURE='$SIGNATURE'" >> VERSION
|
|
|
|
|
2024-07-18 05:35:09 +00:00
|
|
|
echo "INFO write | Written VERSION information"
|
|
|
|
echo "### VERSION ###"
|
2023-06-11 14:32:03 +00:00
|
|
|
cat VERSION
|
2024-07-18 05:35:09 +00:00
|
|
|
echo "### VERSION ###"
|
|
|
|
|
|
|
|
# Try to get frontend
|
|
|
|
echo "INFO frontend | Trying to get frontend"
|
|
|
|
# Check if tag sha is the same as the commit sha
|
|
|
|
TAG_SHA=$(jq -r '.sha' tag.json)
|
|
|
|
if [ "$TAG_SHA" != "$FULL_SHA" ]; then
|
|
|
|
echo "INFO frontend | Tag sha '$TAG_SHA' is not the same as commit sha $FULL_SHA, can not download frontend"
|
|
|
|
else
|
|
|
|
echo "INFO frontend | Getting frontend from github via tag"
|
2024-07-18 22:49:51 +00:00
|
|
|
curl https://github.com/$APP_REPO/releases/download/$APP_PKG_VERSION/frontend-build.zip -L -O -f
|
2024-07-18 05:35:09 +00:00
|
|
|
mkdir -p src/backend/InvenTree/web/static
|
|
|
|
echo "INFO frontend | Unzipping frontend"
|
|
|
|
unzip -qq frontend-build.zip -d src/backend/InvenTree/web/static/web
|
|
|
|
echo "INFO frontend | Unzipped frontend"
|
|
|
|
fi
|