Files

49 lines
1.9 KiB
Bash
Executable File

#!/usr/bin/env bash
# One ordered pipeline: JVM tests -> native build -> native smoke -> release artifact.
set -euo pipefail
root=$(cd -- "$(dirname -- "${BASH_SOURCE[0]}")/.." && pwd)
cd "$root"
: "${JAVA_HOME:?JAVA_HOME must name the pinned GraalVM Community installation}"
# Capture the source revision before the build, not after a potentially long compile.
export WERKJOURNAL_BUILD_COMMIT
WERKJOURNAL_BUILD_COMMIT=$(git rev-parse HEAD)
rm -rf -- build/release
./gradlew --no-daemon --console=plain test nativeCompile -Pproduction=true -Pnative=true "$@"
mkdir -p build/reports/native build/release
./tools/smoke-native build/native/nativeCompile/werkjournal > build/reports/native/smoke.json
python3 - <<'PY'
import hashlib
import json
import os
from pathlib import Path
import shutil
import subprocess
source = Path('build/native/nativeCompile/werkjournal')
smoke = json.loads(Path('build/reports/native/smoke.json').read_text())
if smoke.get('result') != 'PASS':
raise SystemExit('Native smoke check did not pass')
commit = os.environ['WERKJOURNAL_BUILD_COMMIT']
target = Path('build/release/werkjournal')
shutil.copy2(source, target)
# GraalVM emits companion libraries (AWT etc.); ship them with the executable.
files = [target]
for library in sorted(source.parent.glob('*.so')):
destination = target.parent / library.name
shutil.copy2(library, destination)
files.append(destination)
def checksum(path):
with path.open('rb') as stream:
return hashlib.file_digest(stream, 'sha256').hexdigest()
manifest = {
'schemaVersion': 1,
'commit': commit,
'version': smoke['info']['version'],
'sha256': checksum(target),
'files': {path.name: checksum(path) for path in files},
'platform': 'linux-x86_64',
'libc': subprocess.check_output(['getconf', 'GNU_LIBC_VERSION'], text=True).strip(),
}
Path('build/release/manifest.json').write_text(json.dumps(manifest, indent=2) + '\n')
PY