forked from jellyfin/jellyfin
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Build scripts and build system consolidation.
Squashed commit.
- Loading branch information
Showing
66 changed files
with
605 additions
and
217 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -3,3 +3,6 @@ | |
Dockerfile | ||
CONTRIBUTORS.md | ||
README.md | ||
deployment/*/dist | ||
deployment/*/pkg-dist | ||
deployment/collect-dist/ |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file was deleted.
Oops, something went wrong.
This file was deleted.
Oops, something went wrong.
This file was deleted.
Oops, something went wrong.
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,8 @@ | ||
# Build scripts | ||
|
||
All `build.sh` and `package.sh` scripts are for *nix platforms (or WSL on Windows 10). | ||
|
||
After running both, check the `*/pkg-dist/` folders for the archives and packages. | ||
|
||
`build_all.sh` will invoke every build and package script. | ||
Use `collect_all.sh` to copy all artifact to one directory for easy uploading. |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,23 @@ | ||
#!/usr/bin/env bash | ||
|
||
# Execute all build.sh and package.sh and sign.sh scripts in every folder. In that order. Script should check for artifacts themselves. | ||
echo "Running for platforms '$@'." | ||
for directory in */ ; do | ||
platform=`basename "${directory}"` | ||
if [[ $@ == *"$platform"* || $@ = *"all"* ]]; then | ||
echo "Processing ${platform}" | ||
pushd "$platform" | ||
if [ -f build.sh ]; then | ||
echo ./build.sh | ||
fi | ||
if [ -f package.sh ]; then | ||
echo ./package.sh | ||
fi | ||
if [ -f sign.sh ]; then | ||
echo ./sign.sh | ||
fi | ||
popd | ||
else | ||
echo "Skipping $platform." | ||
fi | ||
done |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,21 @@ | ||
#!/usr/bin/env bash | ||
|
||
set -e | ||
|
||
# Execute every clean.sh scripts in every folder. | ||
echo "Running for platforms '$@'." | ||
for directory in */ ; do | ||
platform=`basename "${directory}"` | ||
if [[ $@ == *"$platform"* || $@ = *"all"* ]]; then | ||
echo "Processing ${platform}" | ||
pushd "$platform" | ||
if [ -f clean.sh ]; then | ||
echo ./clean.sh | ||
fi | ||
popd | ||
else | ||
echo "Skipping $platform." | ||
fi | ||
done | ||
|
||
rm -rf ./collect-dist |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,20 @@ | ||
#!/usr/bin/env bash | ||
|
||
source common.build.sh | ||
|
||
VERSION=`get_version ..` | ||
|
||
COLLECT_DIR="./collect-dist" | ||
|
||
mkdir -p ./collect-dist | ||
|
||
DIRS=`find . -type d -name "pkg-dist"` | ||
|
||
while read directory | ||
do | ||
echo "Collecting everything from '$directory'.." | ||
PLATFORM=$(basename "$(dirname "$directory")") | ||
# Copy all artifacts with extensions tar.gz, deb, exe, zip, rpm and add the platform name to resolve any duplicates. | ||
find $directory \( -name "jellyfin*.tar.gz" -o -name "jellyfin*.deb" -o -name "jellyfin*.rpm" -o -name "jellyfin*.zip" -o -name "jellyfin*.exe" \) -exec sh -c 'cp "$1" "'${COLLECT_DIR}'/jellyfin_'${PLATFORM}'_${1#*jellyfin_}"' _ {} \; | ||
|
||
done <<< "${DIRS}" |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,108 @@ | ||
#!/usr/bin/env bash | ||
|
||
set -o errexit | ||
set -o nounset | ||
|
||
RED='\033[0;31m' | ||
GREEN='\033[0;32m' | ||
CYAN='\033[0;36m' | ||
NC='\033[0m' # No Color | ||
|
||
DEFAULT_BUILD_CONTEXT="../.." | ||
DEFAULT_ROOT="." | ||
DEFAULT_DOTNETRUNTIME="framework" | ||
DEFAULT_CONFIG="Release" | ||
DEFAULT_OUTPUT_DIR="dist/jellyfin-git" | ||
DEFAULT_PKG_DIR="pkg-dist" | ||
DEFAULT_DOCKERFILE="Dockerfile" | ||
DEFAULT_IMAGE_TAG="jellyfin:"`git rev-parse --abbrev-ref HEAD` | ||
|
||
# Run a build | ||
build_jellyfin() | ||
( | ||
ROOT=${1-$DEFAULT_ROOT} | ||
CONFIG=${2-$DEFAULT_CONFIG} | ||
DOTNETRUNTIME=${3-$DEFAULT_DOTNETRUNTIME} | ||
OUTPUT_DIR=${4-$DEFAULT_OUTPUT_DIR} | ||
|
||
echo -e "${CYAN}Building jellyfin in '${ROOT}' for ${DOTNETRUNTIME} with configuration ${CONFIG} and output directory '${OUTPUT_DIR}'.${NC}" | ||
if [[ $DOTNETRUNTIME == 'framework' ]]; then | ||
dotnet publish "${ROOT}" --configuration "${CONFIG}" --output="${OUTPUT_DIR}" | ||
else | ||
dotnet publish "${ROOT}" --configuration "${CONFIG}" --output="${OUTPUT_DIR}" --self-contained --runtime ${DOTNETRUNTIME} | ||
fi | ||
EXIT_CODE=$? | ||
if [ $EXIT_CODE -eq 0 ]; then | ||
echo -e "${GREEN}[DONE] Build jellyfin in '${ROOT}' for ${DOTNETRUNTIME} with configuration ${CONFIG} and output directory '${OUTPUT_DIR}' complete.${NC}" | ||
else | ||
echo -e "${RED}[FAIL] Build jellyfin in '${ROOT}' for ${DOTNETRUNTIME} with configuration ${CONFIG} and output directory '${OUTPUT_DIR}' FAILED.${NC}" | ||
fi | ||
) | ||
|
||
# Run a docker | ||
build_jellyfin_docker() | ||
( | ||
BUILD_CONTEXT=${1-$DEFAULT_BUILD_CONTEXT} | ||
DOCKERFILE=${2-$DEFAULT_DOCKERFILE} | ||
IMAGE_TAG=${3-$DEFAULT_IMAGE_TAG} | ||
|
||
echo -e "${CYAN}Building jellyfin docker image in '${ROOT}' with Dockerfile ${CONFIG} and tag '${IMAGE_TAG}'.${NC}" | ||
docker build -t ${IMAGE_TAG} -f ${DOCKERFILE} ${ROOT} | ||
EXIT_CODE=$? | ||
if [ $EXIT_CODE -eq 0 ]; then | ||
echo -e "${GREEN}[DONE] Building jellyfin docker image in '${ROOT}' with Dockerfile ${CONFIG} and tag '${IMAGE_TAG}' complete.${NC}" | ||
else | ||
echo -e "${RED}[FAIL] Building jellyfin docker image in '${ROOT}' with Dockerfile ${CONFIG} and tag '${IMAGE_TAG}' FAILED.${NC}" | ||
fi | ||
) | ||
|
||
# Clean a build | ||
clean_jellyfin() | ||
( | ||
local ROOT=${1-$DEFAULT_ROOT} | ||
local CONFIG=${2-$DEFAULT_CONFIG} | ||
local OUTPUT_DIR=${3-$DEFAULT_OUTPUT_DIR} | ||
local PKG_DIR=${4-$DEFAULT_PKG_DIR} | ||
echo -e "${CYAN}Cleaning jellyfin in '${ROOT}'' with configuration ${CONFIG} and output directory '${OUTPUT_DIR}'.${NC}" | ||
echo -e "${CYAN}Deleting '${OUTPUT_DIR}'${NC}" | ||
rm -rf "$OUTPUT_DIR" | ||
echo -e "${CYAN}Deleting '${PKG_DIR}'${NC}" | ||
rm -rf "$PKG_DIR" | ||
dotnet clean "${ROOT}" -maxcpucount:1 --configuration ${CONFIG} | ||
local EXIT_CODE=$? | ||
if [ $EXIT_CODE -eq 0 ]; then | ||
echo -e "${GREEN}[DONE] Clean jellyfin in '${ROOT}' with configuration ${CONFIG} and output directory '${OUTPUT_DIR}' complete.${NC}" | ||
else | ||
echo -e "${RED}[FAIL] Clean jellyfin in '${ROOT}' with configuration ${CONFIG} and output directory '${OUTPUT_DIR}' failed.${NC}" | ||
fi | ||
) | ||
|
||
# Parse the version from the AssemblyVersion | ||
get_version() | ||
( | ||
local ROOT=${1-$DEFAULT_ROOT} | ||
grep "AssemblyVersion" ${ROOT}/SharedVersion.cs | sed -E 's/\[assembly: ?AssemblyVersion\("([0-9\.]+)"\)\]/\1/' | sed -E 's/.0$//' | ||
) | ||
|
||
# Packages the output folder into an archive. | ||
package_portable() | ||
( | ||
local ROOT=${1-$DEFAULT_ROOT} | ||
local OUTPUT_DIR=${2-$DEFAULT_OUTPUT_DIR} | ||
local PKG_DIR=${3-$DEFAULT_PKG_DIR} | ||
# Package portable build result | ||
if [ -d ${OUTPUT_DIR} ]; then | ||
echo -e "${CYAN}Packaging build in '${OUTPUT_DIR}' for `basename "${OUTPUT_DIR}"` to '${PKG_DIR}' with root '${ROOT}'.${NC}" | ||
mkdir -p ${PKG_DIR} | ||
tar -zcvf "${PKG_DIR}/`basename "${OUTPUT_DIR}"`.portable.tar.gz" -C "`dirname "${OUTPUT_DIR}"`" "`basename "${OUTPUT_DIR}"`" | ||
local EXIT_CODE=$? | ||
if [ $EXIT_CODE -eq 0 ]; then | ||
echo -e "${GREEN}[DONE] Packaging build in '${OUTPUT_DIR}' for `basename "${OUTPUT_DIR}"` to '${PKG_DIR}' with root '${ROOT}' complete.${NC}" | ||
else | ||
echo -e "${RED}[FAIL] Packaging build in '${OUTPUT_DIR}' for `basename "${OUTPUT_DIR}"` to '${PKG_DIR}' with root '${ROOT}' FAILED.${NC}" | ||
fi | ||
else | ||
echo -e "${RED}[FAIL] Build artifacts do not exist for ${OUTPUT_DIR}. Run build.sh first.${NC}" | ||
fi | ||
) | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,7 @@ | ||
#!/usr/bin/env bash | ||
|
||
source ../common.build.sh | ||
|
||
VERSION=`get_version ../..` | ||
|
||
clean_jellyfin ../.. Release `pwd`/dist/jellyfin_${VERSION} |
Oops, something went wrong.