Tests / Go and GTK tests (push) Failing after 1m8s
Add `/dist/` to `.gitignore` to exclude locally built distribution artifacts. Document the Gitea Actions workflow, release tagging, and branch protection setup in the README.
52 lines
1.9 KiB
Bash
Executable File
52 lines
1.9 KiB
Bash
Executable File
#!/usr/bin/env bash
|
|
set -Eeuo pipefail
|
|
|
|
repo_root="$(cd -- "$(dirname -- "${BASH_SOURCE[0]}")/../.." && pwd -P)"
|
|
cd -- "$repo_root"
|
|
|
|
tag=${1:-}
|
|
if [[ ! "$tag" =~ ^v[0-9]+\.[0-9]+\.[0-9]+$ ]]; then
|
|
printf 'captioneer: release tag must match vMAJOR.MINOR.BUG, got %q\n' "$tag" >&2
|
|
exit 1
|
|
fi
|
|
|
|
platform=linux-amd64
|
|
archive_name="captioneer-${tag}-${platform}.tar.gz"
|
|
package_name="captioneer-${tag}-${platform}"
|
|
package_dir="dist/$package_name"
|
|
|
|
rm -rf -- "$package_dir"
|
|
rm -f -- "dist/$archive_name" "dist/$archive_name.sha256"
|
|
mkdir -p -- "$package_dir/lib" "$package_dir/scripts"
|
|
|
|
# The Sherpa Go module embeds an absolute build-machine RPATH. Add a portable
|
|
# fallback so the bundled native libraries resolve beside the extracted tools.
|
|
# shellcheck disable=SC2016 # $ORIGIN must remain literal for the ELF loader.
|
|
export CGO_LDFLAGS='-Wl,-rpath,$ORIGIN/lib'
|
|
go build -trimpath -o "$package_dir/captioneer" ./src/cmd/captioneer
|
|
go build -trimpath -tags gtk -o "$package_dir/captioneer-desktop" ./src/cmd/captioneer-desktop
|
|
|
|
sherpa_dir="$(go list -m -f '{{.Dir}}' github.com/k2-fsa/sherpa-onnx-go-linux)"
|
|
sherpa_lib_dir="$sherpa_dir/lib/x86_64-unknown-linux-gnu"
|
|
cp -- "$sherpa_lib_dir/libsherpa-onnx-c-api.so" "$package_dir/lib/"
|
|
cp -- "$sherpa_lib_dir/libonnxruntime.so" "$package_dir/lib/"
|
|
cp -- README.md LICENSE "$package_dir/"
|
|
cp -- scripts/download-models.sh "$package_dir/scripts/"
|
|
|
|
for executable in captioneer captioneer-desktop; do
|
|
# shellcheck disable=SC2016 # Verify the literal ELF-loader token.
|
|
if ! readelf -d "$package_dir/$executable" | grep -Fq '$ORIGIN/lib'; then
|
|
printf 'captioneer: %s is missing the portable native-library RPATH\n' "$executable" >&2
|
|
exit 1
|
|
fi
|
|
done
|
|
|
|
tar -C dist -czf "dist/$archive_name" "$package_name"
|
|
(
|
|
cd -- dist
|
|
sha256sum "$archive_name" > "$archive_name.sha256"
|
|
)
|
|
|
|
printf '%s\n' "$repo_root/dist/$archive_name"
|
|
printf '%s\n' "$repo_root/dist/$archive_name.sha256"
|