Goblin — Build 98
This commit is contained in:
Executable
+135
@@ -0,0 +1,135 @@
|
||||
#!/bin/bash
|
||||
|
||||
usage="Usage: android.sh [type] [platform|version] [flavor]\n - type: 'build' to run locally, 'lib' - .so for all platforms, 'release' - .apk for all platforms\n - platform, for 'build' type: 'v7', 'v8', 'x86'\n - version for 'lib' and 'release', example: '0.2.2'\n - optional flavor, for non-'lib' type: 'ci' for local maven, default - 'local' for external"
|
||||
case $1 in
|
||||
build|lib|release)
|
||||
;;
|
||||
*)
|
||||
printf "$usage"
|
||||
exit 1
|
||||
esac
|
||||
|
||||
if [[ $1 == "build" ]]; then
|
||||
case $2 in
|
||||
v7|v8|x86)
|
||||
;;
|
||||
*)
|
||||
printf "$usage"
|
||||
exit 1
|
||||
esac
|
||||
fi
|
||||
|
||||
# Setup build directory
|
||||
BASEDIR=$(cd "$(dirname "$0")" && pwd)
|
||||
cd "${BASEDIR}" || exit 1
|
||||
cd ..
|
||||
|
||||
# Prefer the GRIM-canonical toolchain: the custom NDK r29 (rebuilt LLVM, 16 KB
|
||||
# page-aligned) + Android SDK from code.gri.mw/DEV. scripts/toolchain.sh fetches
|
||||
# them and writes this env; falls back to whatever NDK/SDK is on the system.
|
||||
[ -f .toolchains/env.sh ] && source .toolchains/env.sh
|
||||
|
||||
# Install platforms and tools
|
||||
rustup target add armv7-linux-androideabi
|
||||
rustup target add aarch64-linux-android
|
||||
rustup target add x86_64-linux-android
|
||||
cargo install cargo-ndk
|
||||
|
||||
success=1
|
||||
|
||||
### Build native code
|
||||
function build_lib() {
|
||||
[[ $1 == "v7" ]] && arch=armeabi-v7a
|
||||
[[ $1 == "v8" ]] && arch=arm64-v8a
|
||||
[[ $1 == "x86" ]] && arch=x86_64
|
||||
|
||||
sed -i -e 's/"cdylib","rlib"]/"rlib"]/g' Cargo.toml
|
||||
sed -i -e 's/"rlib"]/"cdylib","rlib"]/g' Cargo.toml
|
||||
|
||||
cargo ndk -t "${arch}" -o android/app/src/main/jniLibs build --profile release-apk
|
||||
if [ $? -ne 0 ]; then
|
||||
success=0
|
||||
fi
|
||||
|
||||
sed -i -e 's/"cdylib","rlib"]/"rlib"]/g' Cargo.toml
|
||||
rm -f Cargo.toml-e
|
||||
|
||||
# The Nym mixnet is linked INTO libgrim.so (nym-sdk is a regular dependency),
|
||||
# so there is no separate sidecar binary to cross-build or bundle into jniLibs.
|
||||
}
|
||||
|
||||
### Build application
|
||||
function build_apk() {
|
||||
flavor=$3
|
||||
[[ -z "$flavor" ]] && flavor="local"
|
||||
cd android || exit 1
|
||||
./gradlew clean
|
||||
# Build signed apk if keystore exists
|
||||
if [ ! -f keystore.properties ]; then
|
||||
./gradlew assemble${flavor}Debug
|
||||
if [ $? -ne 0 ]; then
|
||||
success=0
|
||||
fi
|
||||
apk_path=app/build/outputs/apk/${flavor}/debug/app-${flavor}-debug.apk
|
||||
else
|
||||
./gradlew assemble${flavor}SignedRelease
|
||||
if [ $? -ne 0 ]; then
|
||||
success=0
|
||||
fi
|
||||
apk_path=app/build/outputs/apk/${flavor}/signedRelease/app-${flavor}-signedRelease.apk
|
||||
fi
|
||||
|
||||
if [[ $1 == "" ]] && [ $success -eq 1 ]; then
|
||||
# Launch application at all connected devices.
|
||||
for SERIAL in $(adb devices | grep -v List | cut -f 1);
|
||||
do
|
||||
adb -s "$SERIAL" install ${apk_path}
|
||||
sleep 1s
|
||||
adb -s "$SERIAL" shell am start -n mw.gri.android/.MainActivity;
|
||||
done
|
||||
elif [ $success -eq 1 ]; then
|
||||
# Get version
|
||||
version=$2
|
||||
if [[ -z "$version" ]]; then
|
||||
version=v$(grep -m 1 -Po 'version = "\K[^"]*' ../Cargo.toml)
|
||||
fi
|
||||
# Setup release file name
|
||||
name=grim-${version}-android-$1.apk
|
||||
[[ $1 == "arm" ]] && name=grim-${version}-android.apk
|
||||
rm -f "${name}"
|
||||
mv ${apk_path} "${name}"
|
||||
# Calculate checksum
|
||||
checksum=grim-${version}-android-$1-sha256sum.txt
|
||||
[[ $1 == "arm" ]] && checksum=grim-${version}-android-sha256sum.txt
|
||||
rm -f "${checksum}"
|
||||
sha256sum "${name}" > "${checksum}"
|
||||
fi
|
||||
|
||||
cd ..
|
||||
}
|
||||
|
||||
rm -rf android/app/src/main/jniLibs/*
|
||||
if [[ $1 == "lib" ]]; then
|
||||
build_lib "v7"
|
||||
[ $success -eq 1 ] && build_lib "v8"
|
||||
[ $success -eq 1 ] && build_lib "x86"
|
||||
[ $success -eq 1 ] && exit 0
|
||||
elif [[ $1 == "build" ]]; then
|
||||
build_lib "$2"
|
||||
[ $success -eq 1 ] && build_apk "" "" "$3"
|
||||
[ $success -eq 1 ] && exit 0
|
||||
else
|
||||
rm -rf target/release-apk
|
||||
rm -rf target/aarch64-linux-android
|
||||
rm -rf target/x86_64-linux-android
|
||||
rm -rf target/armv7-linux-androideabi
|
||||
build_lib "v7"
|
||||
[ $success -eq 1 ] && build_lib "v8"
|
||||
[ $success -eq 1 ] && build_apk "arm" "$2" "$3"
|
||||
rm -rf android/app/src/main/jniLibs/*
|
||||
[ $success -eq 1 ] && build_lib "x86"
|
||||
[ $success -eq 1 ] && build_apk "x86_64" "$2" "$3"
|
||||
[ $success -eq 1 ] && exit 0
|
||||
fi
|
||||
|
||||
exit 1
|
||||
Executable
+27
@@ -0,0 +1,27 @@
|
||||
#!/bin/bash
|
||||
|
||||
case $1 in
|
||||
debug|build)
|
||||
;;
|
||||
*)
|
||||
echo "Usage: build_run.sh [type] where is type is 'debug' or 'build'" >&2
|
||||
exit 1
|
||||
esac
|
||||
|
||||
# Setup build directory
|
||||
BASEDIR=$(cd "$(dirname $0)" && pwd)
|
||||
cd "${BASEDIR}" || return
|
||||
cd ..
|
||||
|
||||
# Build application
|
||||
type=$1
|
||||
[[ ${type} == "build" ]] && release_param+=(--release)
|
||||
cargo --config profile.release.incremental=true build "${release_param[@]}"
|
||||
|
||||
# Start application
|
||||
if [ $? -eq 0 ]
|
||||
then
|
||||
path=${type}
|
||||
[[ ${type} == "build" ]] && path="release"
|
||||
./target/"${path}"/grim
|
||||
fi
|
||||
Executable
+45
@@ -0,0 +1,45 @@
|
||||
#!/usr/bin/env bash
|
||||
# Regenerate EVERY platform's app icon from two canonical sources:
|
||||
# img/goblin-icon.png the gradient app icon (yellow gradient + black mascot)
|
||||
# img/goblin-mark-black.svg the black mascot mark, vector, transparent bg
|
||||
# (mirror of site/assets/goblin-mark-black.svg)
|
||||
#
|
||||
# Square icons (desktop window, Linux AppImage, Android launcher, Windows .ico,
|
||||
# macOS .icns) come from the gradient PNG. The Android *adaptive* foreground is
|
||||
# the black mascot on transparency, composited by the OS over the yellow
|
||||
# background color (res/values/ic_launcher_background.xml = #FFD60A) — which
|
||||
# reproduces the gradient icon's look.
|
||||
#
|
||||
# Requires ImageMagick (magick) and python3 (for the .icns container).
|
||||
set -euo pipefail
|
||||
cd "$(dirname "$0")/.."
|
||||
|
||||
ICON=img/goblin-icon.png
|
||||
MARK=img/goblin-mark-black.svg
|
||||
RES=android/app/src/main/res
|
||||
|
||||
# --- Desktop window icon (egui, src/main.rs) + Linux AppImage AppDir icon ---
|
||||
magick "$ICON" -resize 256x256 PNG32:img/icon.png
|
||||
cp img/icon.png linux/Goblin.AppDir/goblin.png
|
||||
|
||||
# --- Android launcher icons (gradient square) + adaptive foreground (mascot) ---
|
||||
declare -A SIZES=( [mdpi]=48 [hdpi]=72 [xhdpi]=96 [xxhdpi]=144 [xxxhdpi]=192 )
|
||||
declare -A FG_SIZES=( [mdpi]=108 [hdpi]=162 [xhdpi]=216 [xxhdpi]=324 [xxxhdpi]=432 )
|
||||
for d in mdpi hdpi xhdpi xxhdpi xxxhdpi; do
|
||||
s=${SIZES[$d]}; fg=${FG_SIZES[$d]}
|
||||
# Mascot fills ~60% of the adaptive canvas — inside the ~61% safe zone, so no
|
||||
# launcher mask (circle/squircle) ever clips it.
|
||||
art=$(( fg * 60 / 100 ))
|
||||
magick "$ICON" -resize "${s}x${s}" PNG32:"$RES/mipmap-$d/ic_launcher.png"
|
||||
magick "$ICON" -resize "${s}x${s}" PNG32:"$RES/mipmap-$d/ic_launcher_round.png"
|
||||
magick -background none "$MARK" -resize "${art}x${art}" \
|
||||
-gravity center -extent "${fg}x${fg}" PNG32:"$RES/mipmap-$d/ic_launcher_foreground.png"
|
||||
done
|
||||
|
||||
# --- Windows installer + file-type icon (WiX wix/Product.ico) ---
|
||||
magick "$ICON" -define icon:auto-resize=256,128,64,48,32,24,16 wix/Product.ico
|
||||
|
||||
# --- macOS app bundle icon (Goblin.app) ---
|
||||
python3 scripts/make-icns.py "$ICON" macos/Goblin.app/Contents/Resources/AppIcon.icns
|
||||
|
||||
echo "icons generated from $ICON + $MARK"
|
||||
Executable
+60
@@ -0,0 +1,60 @@
|
||||
#!/usr/bin/env python3
|
||||
"""Build a macOS .icns from a square PNG, dependency-free.
|
||||
|
||||
macOS has `iconutil` and Linux distros have `png2icns`, but neither is reliably
|
||||
present, and ImageMagick's own .icns writer only emits a single size. So we
|
||||
assemble the multi-resolution PNG-payload .icns container by hand (the format
|
||||
macOS 10.7+ accepts): the `icns` magic + big-endian length, then one entry per
|
||||
OSType, each carrying an 8-bit PNG. ImageMagick (`magick`) does the resizing.
|
||||
|
||||
Usage: make-icns.py <source.png> <out.icns>
|
||||
"""
|
||||
|
||||
import struct
|
||||
import subprocess
|
||||
import sys
|
||||
|
||||
# OSType -> pixel size. PNG-payload entries. Sizes above the source are
|
||||
# Lanczos-upscaled (soft but acceptable for the few large Dock/Finder slots).
|
||||
SLOTS = [
|
||||
(b"icp4", 16),
|
||||
(b"icp5", 32),
|
||||
(b"icp6", 64),
|
||||
(b"ic07", 128),
|
||||
(b"ic08", 256),
|
||||
(b"ic11", 32), # 16@2x
|
||||
(b"ic12", 64), # 32@2x
|
||||
(b"ic13", 256), # 128@2x
|
||||
(b"ic09", 512), # 512
|
||||
(b"ic14", 512), # 256@2x
|
||||
]
|
||||
|
||||
|
||||
def render(src, size):
|
||||
out = "/tmp/_icns_%d.png" % size
|
||||
subprocess.run(
|
||||
["magick", src, "-resize", "%dx%d" % (size, size),
|
||||
"-filter", "Lanczos", "-depth", "8", "PNG32:%s" % out],
|
||||
check=True,
|
||||
)
|
||||
return open(out, "rb").read()
|
||||
|
||||
|
||||
def main():
|
||||
if len(sys.argv) != 3:
|
||||
sys.exit("usage: make-icns.py <source.png> <out.icns>")
|
||||
src, out = sys.argv[1], sys.argv[2]
|
||||
cache, entries = {}, []
|
||||
for ostype, size in SLOTS:
|
||||
if size not in cache:
|
||||
cache[size] = render(src, size)
|
||||
data = cache[size]
|
||||
entries.append(ostype + struct.pack(">I", 8 + len(data)) + data)
|
||||
body = b"".join(entries)
|
||||
with open(out, "wb") as f:
|
||||
f.write(b"icns" + struct.pack(">I", 8 + len(body)) + body)
|
||||
print("wrote %s (%d entries)" % (out, len(entries)))
|
||||
|
||||
|
||||
if __name__ == "__main__":
|
||||
main()
|
||||
Executable
+125
@@ -0,0 +1,125 @@
|
||||
#!/bin/bash
|
||||
#
|
||||
# Fetch the canonical GRIM build toolchains (code.gri.mw/DEV) into .toolchains/.
|
||||
#
|
||||
# These mirror exactly what upstream GRIM's CI uses, so Goblin cross-builds every
|
||||
# platform from one Linux box the same way GRIM does — instead of relying on
|
||||
# whatever NDK/zig/appimagetool happens to be installed on the machine.
|
||||
#
|
||||
# Idempotent: each tool is skipped if already present. Linux x86_64 host only
|
||||
# (the box we build releases on). Writes .toolchains/env.sh with the exports the
|
||||
# build scripts source; run nothing else by hand.
|
||||
#
|
||||
# Usage:
|
||||
# scripts/toolchain.sh # core: ndk zig appimage (what desktop+android need)
|
||||
# scripts/toolchain.sh sdk gradle # add the Android SDK + Gradle
|
||||
# scripts/toolchain.sh osxcross # build the macOS cross-toolchain (heavy)
|
||||
# scripts/toolchain.sh all # everything
|
||||
#
|
||||
set -euo pipefail
|
||||
|
||||
BASEDIR=$(cd "$(dirname "$0")/.." && pwd)
|
||||
TC="${BASEDIR}/.toolchains"
|
||||
DEV="https://code.gri.mw/DEV"
|
||||
mkdir -p "${TC}"
|
||||
|
||||
dl() { echo " ↓ $(basename "$2")"; curl -fSL --retry 3 -o "$2" "$1"; }
|
||||
|
||||
# Pinned versions — bump here to track GRIM's DEV releases.
|
||||
NDK_TAG="r29"; NDK_ARCHIVE="android-ndk-${NDK_TAG}-x86_64-linux-musl.tar.xz"; NDK_DIR="${TC}/android-ndk-${NDK_TAG}"
|
||||
ZIG_VER="0.12.1"; ZIG_DIR="${TC}/zig"
|
||||
AT_VER="1.9.1"; RT_TAG="20251108"
|
||||
SDK_TAG="r36"; SDK_DIR="${TC}/android-sdk"
|
||||
GRADLE_VER="8.13"; GRADLE_DIR="${TC}/gradle-${GRADLE_VER}"
|
||||
SDK_VER="12.3"; OSX_DIR="${TC}/osxcross"
|
||||
|
||||
fetch_ndk() {
|
||||
[ -e "${NDK_DIR}/source.properties" ] && { echo "ndk r29: present"; return; }
|
||||
echo "ndk: fetching custom NDK ${NDK_TAG} (rebuilt LLVM, 16 KB-aligned)…"
|
||||
dl "${DEV}/android-ndk-custom/releases/download/${NDK_TAG}/${NDK_ARCHIVE}" "${TC}/ndk.tar.xz"
|
||||
tar -xJf "${TC}/ndk.tar.xz" -C "${TC}"; rm -f "${TC}/ndk.tar.xz"
|
||||
}
|
||||
|
||||
fetch_zig() {
|
||||
[ -x "${ZIG_DIR}/zig" ] && { echo "zig ${ZIG_VER}: present"; return; }
|
||||
echo "zig: fetching ${ZIG_VER} (linker for cargo-zigbuild)…"
|
||||
dl "${DEV}/zig/releases/download/${ZIG_VER}/zig-linux-x86_64-${ZIG_VER}.tar.xz" "${TC}/zig.tar.xz"
|
||||
tar -xJf "${TC}/zig.tar.xz" -C "${TC}"; rm -f "${TC}/zig.tar.xz"
|
||||
rm -rf "${ZIG_DIR}"; mv "${TC}/zig-linux-x86_64-${ZIG_VER}" "${ZIG_DIR}"
|
||||
}
|
||||
|
||||
fetch_appimage() {
|
||||
[ -x "${TC}/appimagetool" ] && [ -e "${TC}/runtime-x86_64" ] && { echo "appimagetool ${AT_VER}: present"; return; }
|
||||
echo "appimage: fetching appimagetool ${AT_VER} + type2 runtime…"
|
||||
dl "${DEV}/appimagetool/releases/download/${AT_VER}/appimagetool-x86_64.AppImage" "${TC}/appimagetool"
|
||||
dl "${DEV}/appimage-type2-runtime/releases/download/${RT_TAG}/runtime-x86_64" "${TC}/runtime-x86_64"
|
||||
chmod +x "${TC}/appimagetool" "${TC}/runtime-x86_64"
|
||||
}
|
||||
|
||||
# Assemble a minimal Android SDK (build-tools + platform + platform-tools) from
|
||||
# the DEV mirror so gradle has an SDK without a system install.
|
||||
fetch_sdk() {
|
||||
[ -d "${SDK_DIR}/platform-tools" ] && { echo "android-sdk ${SDK_TAG}: present"; return; }
|
||||
echo "android-sdk: fetching build-tools + platform-36 + platform-tools (${SDK_TAG})…"
|
||||
local base="${DEV}/android-platform-tools/releases/download/${SDK_TAG}"
|
||||
mkdir -p "${SDK_DIR}/build-tools" "${SDK_DIR}/platforms"
|
||||
dl "${base}/build-tools_r36.1_linux.zip" "${TC}/bt.zip"
|
||||
dl "${base}/platform-36_r02.zip" "${TC}/pf.zip"
|
||||
dl "${base}/platform-tools_r36.0.0-linux.zip" "${TC}/pt.zip"
|
||||
# build-tools zip unzips to android-NN/ → rename to the version dir gradle wants.
|
||||
local tmp; tmp=$(mktemp -d)
|
||||
unzip -q "${TC}/bt.zip" -d "${tmp}"; mv "${tmp}"/*/ "${SDK_DIR}/build-tools/36.1.0"
|
||||
unzip -q "${TC}/pf.zip" -d "${tmp}"; mv "${tmp}"/*/ "${SDK_DIR}/platforms/android-36"
|
||||
unzip -q "${TC}/pt.zip" -d "${SDK_DIR}"
|
||||
rm -rf "${tmp}" "${TC}/bt.zip" "${TC}/pf.zip" "${TC}/pt.zip"
|
||||
}
|
||||
|
||||
fetch_gradle() {
|
||||
[ -x "${GRADLE_DIR}/bin/gradle" ] && { echo "gradle ${GRADLE_VER}: present"; return; }
|
||||
echo "gradle: fetching ${GRADLE_VER}…"
|
||||
dl "${DEV}/gradle/releases/download/v${GRADLE_VER}/gradle-${GRADLE_VER}-bin.zip" "${TC}/gradle.zip"
|
||||
unzip -q "${TC}/gradle.zip" -d "${TC}"; rm -f "${TC}/gradle.zip"
|
||||
}
|
||||
|
||||
# osxcross: build the macOS cross-toolchain from source + the DEV macOS SDK.
|
||||
# Heavy (compiles cctools/ld64); enables building macOS binaries off-Mac. CI also
|
||||
# builds macOS natively, so this is the local/offline path — experimental.
|
||||
fetch_osxcross() {
|
||||
[ -x "${OSX_DIR}/target/bin/o64-clang" ] && { echo "osxcross: present"; return; }
|
||||
command -v clang >/dev/null || { echo "osxcross: needs system clang/cmake — skipping"; return; }
|
||||
echo "osxcross: cloning + building with macOS SDK ${SDK_VER} (slow)…"
|
||||
[ -d "${OSX_DIR}/.git" ] || git clone --depth 1 "${DEV}/osxcross" "${OSX_DIR}"
|
||||
dl "${DEV}/macosx-sdks/releases/download/${SDK_VER}/MacOSX${SDK_VER}.sdk.tar.xz" "${OSX_DIR}/tarballs/MacOSX${SDK_VER}.sdk.tar.xz"
|
||||
( cd "${OSX_DIR}" && UNATTENDED=1 ./build.sh )
|
||||
}
|
||||
|
||||
write_env() {
|
||||
{
|
||||
echo "# Auto-generated by scripts/toolchain.sh — source me for GRIM-canonical builds."
|
||||
[ -e "${NDK_DIR}/source.properties" ] && { echo "export ANDROID_NDK_HOME=\"${NDK_DIR}\""; echo "export ANDROID_NDK_ROOT=\"${NDK_DIR}\""; }
|
||||
[ -d "${SDK_DIR}/platform-tools" ] && echo "export ANDROID_HOME=\"${SDK_DIR}\""
|
||||
local p="${TC}"
|
||||
[ -x "${ZIG_DIR}/zig" ] && p="${ZIG_DIR}:${p}"
|
||||
[ -x "${GRADLE_DIR}/bin/gradle" ] && p="${GRADLE_DIR}/bin:${p}"
|
||||
[ -x "${OSX_DIR}/target/bin/o64-clang" ] && p="${OSX_DIR}/target/bin:${p}"
|
||||
echo "export PATH=\"${p}:\$PATH\""
|
||||
echo "export GOBLIN_APPIMAGETOOL=\"${TC}/appimagetool\""
|
||||
echo "export GOBLIN_APPIMAGE_RUNTIME=\"${TC}/runtime-x86_64\""
|
||||
} > "${TC}/env.sh"
|
||||
}
|
||||
|
||||
tools=("$@"); [ ${#tools[@]} -eq 0 ] && tools=(ndk zig appimage)
|
||||
[ "${tools[0]:-}" = "all" ] && tools=(ndk zig appimage sdk gradle osxcross)
|
||||
for t in "${tools[@]}"; do
|
||||
case "$t" in
|
||||
ndk) fetch_ndk ;;
|
||||
zig) fetch_zig ;;
|
||||
appimage) fetch_appimage ;;
|
||||
sdk) fetch_sdk ;;
|
||||
gradle) fetch_gradle ;;
|
||||
osxcross) fetch_osxcross ;;
|
||||
*) echo "unknown tool: $t (ndk|zig|appimage|sdk|gradle|osxcross|all)" >&2; exit 1 ;;
|
||||
esac
|
||||
done
|
||||
write_env
|
||||
echo "toolchain ready → ${TC}/env.sh"
|
||||
Executable
+102
@@ -0,0 +1,102 @@
|
||||
#!/bin/bash
|
||||
|
||||
# Usage to bump version
|
||||
# ./version.sh patch
|
||||
# ./version.sh minor
|
||||
# ./version.sh major
|
||||
|
||||
# Setup base directory
|
||||
BASEDIR=$(cd $(dirname $0) && pwd)
|
||||
cd ${BASEDIR}
|
||||
cd ..
|
||||
|
||||
# Exit script if command fails or uninitialized variables used
|
||||
set -euo pipefail
|
||||
|
||||
# ==================================
|
||||
# Verify repo is clean
|
||||
# ==================================
|
||||
|
||||
# List uncommitted changes and
|
||||
# check if the output is not empty
|
||||
if [ -n "$(git status --porcelain)" ]; then
|
||||
# Print error message
|
||||
printf "\nError: repo has uncommitted changes\n\n"
|
||||
# Exit with error code
|
||||
exit 1
|
||||
fi
|
||||
|
||||
# ==================================
|
||||
# Get latest version from git tags
|
||||
# ==================================
|
||||
|
||||
# List git tags sorted lexicographically
|
||||
# so version numbers sorted correctly
|
||||
GIT_TAGS=$(git tag --sort=version:refname)
|
||||
|
||||
# Get last line of output which returns the
|
||||
# last tag (most recent version)
|
||||
GIT_TAG_LATEST=$(echo "$GIT_TAGS" | tail -n 1)
|
||||
|
||||
# If no tag found, default to v0.1.0
|
||||
if [ -z "$GIT_TAG_LATEST" ]; then
|
||||
GIT_TAG_LATEST="v0.1.0"
|
||||
fi
|
||||
|
||||
# Strip prefix 'v' from the tag to easily increment
|
||||
GIT_TAG_LATEST=$(echo "$GIT_TAG_LATEST" | sed 's/^v//')
|
||||
|
||||
# ==================================
|
||||
# Increment version number
|
||||
# ==================================
|
||||
|
||||
# Get version type from first argument passed to script
|
||||
VERSION_TYPE="${1-}"
|
||||
VERSION_NEXT=""
|
||||
|
||||
if [ "$VERSION_TYPE" = "patch" ]; then
|
||||
# Increment patch version
|
||||
VERSION_NEXT="$(echo "$GIT_TAG_LATEST" | awk -F. '{$NF++; print $1"."$2"."$NF}')"
|
||||
elif [ "$VERSION_TYPE" = "minor" ]; then
|
||||
# Increment minor version
|
||||
VERSION_NEXT="$(echo "$GIT_TAG_LATEST" | awk -F. '{$2++; $3=0; print $1"."$2"."$3}')"
|
||||
elif [ "$VERSION_TYPE" = "major" ]; then
|
||||
# Increment major version
|
||||
VERSION_NEXT="$(echo "$GIT_TAG_LATEST" | awk -F. '{$1++; $2=0; $3=0; print $1"."$2"."$3}')"
|
||||
else
|
||||
# Print error for unknown versioning type
|
||||
printf "\nError: invalid VERSION_TYPE arg passed, must be 'patch', 'minor' or 'major'\n\n"
|
||||
# Exit with error code
|
||||
exit 1
|
||||
fi
|
||||
|
||||
# Update MacOS version.
|
||||
sed -i '' -e 's/'"$GIT_TAG_LATEST"'/'"$VERSION_NEXT"'/' macos/Grim.app/Contents/Info.plist
|
||||
|
||||
# Update version for Windows installer.
|
||||
sed -i '' -e 's/" Version="[^\"]*"/" Version="'"$VERSION_NEXT"'"/g' wix/main.wxs
|
||||
sed -i '' -e 's/<Package Id="[^\"]*"/<Package Id="'"$(uuidgen)"'"/g' wix/main.wxs
|
||||
|
||||
# Update Android version in build.gradle
|
||||
sed -i'.bak' -e 's/versionName [0-9a-zA-Z -_]*/versionName "'"$VERSION_NEXT"'"/' android/app/build.gradle
|
||||
rm -f android/app/build.gradle.bak
|
||||
|
||||
# Update version in Cargo.toml
|
||||
sed -i'.bak' -e "s/^version = .*/version = \"$VERSION_NEXT\"/" Cargo.toml
|
||||
rm -f Cargo.toml.bak
|
||||
|
||||
# Update Cargo.lock as this changes when
|
||||
# updating the version in your manifest
|
||||
cargo update -p grim
|
||||
|
||||
# Commit the changes
|
||||
git add .
|
||||
git commit -m "build: version $VERSION_NEXT"
|
||||
|
||||
# ==================================
|
||||
# Create git tag for new version
|
||||
# ==================================
|
||||
|
||||
# Create a tag and push to master branch
|
||||
#git tag "v$VERSION_NEXT" master
|
||||
#git push origin master --follow-tags
|
||||
Reference in New Issue
Block a user