-
Notifications
You must be signed in to change notification settings - Fork 11
/
Copy pathrun.sh
70 lines (55 loc) · 2.1 KB
/
run.sh
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
#!/usr/bin/env bash
# Based on https://github.com/ejuarezg/containers/blob/master/iosevka_font/run.sh
set -e
# Create temporary build directory
mkdir -p /tmp/build
cd /tmp/build
BUILD_FILE="private-build-plans.toml"
BUILD_PARAM="contents::iosevka"
CUSTOM_BUILD_FILE=false
# Check the input
if [[ -f "/build/$BUILD_FILE" ]]; then
echo "Found custom build-plans file: $BUILD_FILE"
CUSTOM_BUILD_FILE=true
if [[ -z $1 ]]; then
# Get the name of the first build plan when the user does not provide
# custom build arguments (automatic mode)
PLAN_NAME=$(grep -Po -m 1 '(?<=buildPlans.)[^\]]*' /build/$BUILD_FILE)
BUILD_PARAM="contents::$PLAN_NAME"
else
# User knows what they are doing and provided custom build arguments
# (manual mode)
BUILD_PARAM="$1"
fi
else
echo "Custom build-plans file not found, using the default one"
fi
echo "Using build plan: $BUILD_PARAM"
# Find the latest font version if the font version environment variable is not
# set. The `-n` operator checks if the length of the string is nonzero.
if [[ -z "$FONT_VERSION" ]]; then
FONT_VERSION=$(curl 'https://api.github.com/repos/be5invis/Iosevka/releases?per_page=1' \
| jq -r '.[0].tag_name' \
| grep -oP '(?<=^v)([0-9]+\.)*[0-9]+$' )
fi
echo "Using font version: ${FONT_VERSION}"
echo "Downloading and checking the validity of the source code..."
# Download source code
if [ "$FONT_VERSION" == "dev" ]; then
curl -sSLo vdev.tar.gz --proto '=https' --tlsv1.2 https://github.com/be5invis/Iosevka/tarball/dev
else
curl -sSLO --proto '=https' --tlsv1.2 https://github.com/be5invis/Iosevka/archive/v${FONT_VERSION}.tar.gz
fi
# Check for valid downloaded file (build can fail here with exit code 1)
file "v${FONT_VERSION}.tar.gz" | grep 'gzip compressed data' > /dev/null
# Extract downloaded source code
tar -xf "v${FONT_VERSION}.tar.gz"
cd ./*Iosevka-*
if [ "$CUSTOM_BUILD_FILE" = true ]; then
cp "/build/$BUILD_FILE" .
fi
echo "Building version ${FONT_VERSION}"
npm install
npm run build -- "$BUILD_PARAM"
# Copy the dist folder back to the mounted volume
cp -r dist /build/