Skip to content

Commit

Permalink
more logging
Browse files Browse the repository at this point in the history
  • Loading branch information
matmair committed Jul 15, 2024
1 parent 1bd7acd commit 1498b7f
Showing 1 changed file with 19 additions and 15 deletions.
34 changes: 19 additions & 15 deletions contrib/packager.io/before.sh
Original file line number Diff line number Diff line change
Expand Up @@ -5,38 +5,39 @@

set -eu

# The sha is the second element in APP_PKG_ITERATION
REPO="matmair/InvenTree"
VERSION="$APP_PKG_VERSION-$APP_PKG_ITERATION"
echo "Setting VERSION information to $VERSION"
echo "$VERSION" > VERSION

# The sha is the second element in APP_PKG_ITERATION
SHA=$(echo $APP_PKG_ITERATION | cut -d'.' -f2)

# Download info
echo "Getting info from github for commit $SHA"
curl -L \
echo "INFO collection | Getting info from github for commit $SHA"
curl -L -s -f \
-H "Accept: application/vnd.github+json" \
-H "X-GitHub-Api-Version: 2022-11-28" \
https://api.github.com/repos/$REPO/commits/$SHA > commit.json
curl -L \
echo "INFO collection | Got commit.json with size $(wc -c commit.json)"
curl -L -s -f \
-H "Accept: application/vnd.github+json" \
-H "X-GitHub-Api-Version: 2022-11-28" \
https://api.github.com/repos/$REPO/commits/$SHA/branches-where-head > branches.json
curl -L \
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" \
https://api.github.com/repos/$REPO/commits/$APP_PKG_VERSION > tag.json
echo "INFO collection | Got tag.json with size $(wc -c tag.json)"

# Extract info
echo "Extracting info from github"
echo "INFO extract | Extracting info from github"
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)
FULL_SHA=$(jq -r '.sha' commit.json)

echo "Write VERSION information"
echo "INFO write | Write VERSION information"
echo "$VERSION" > VERSION
echo "INVENTREE_COMMIT_HASH='$SHA'" >> VERSION
echo "INVENTREE_COMMIT_SHA='$FULL_SHA'" >> VERSION
echo "INVENTREE_COMMIT_DATE='$DATE'" >> VERSION
Expand All @@ -46,19 +47,22 @@ echo "INVENTREE_PKG_TARGET='$TARGET'" >> VERSION
echo "NODE_ID='$NODE_ID'" >> VERSION
echo "SIGNATURE='$SIGNATURE'" >> VERSION

echo "Written VERSION information"
echo "INFO write | Written VERSION information"
echo "### VERSION ###"
cat VERSION
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 "Tag sha '$TAG_SHA' is not the same as commit sha $FULL_SHA, can not download frontend"
echo "INFO frontend | Tag sha '$TAG_SHA' is not the same as commit sha $FULL_SHA, can not download frontend"
else
echo "Getting frontend from github via tag"
echo "INFO frontend | Getting frontend from github via tag"
curl https://github.com/$REPO/releases/download/$APP_PKG_VERSION/frontend-build.zip -L -O -f
mkdir -p src/backend/InvenTree/web/static
echo "Unzipping frontend"
echo "INFO frontend | Unzipping frontend"
unzip frontend-build.zip -d src/backend/InvenTree/web/static/web
echo "Unzipped frontend"
echo "INFO frontend | Unzipped frontend"
fi

0 comments on commit 1498b7f

Please sign in to comment.