File bump-version.sh of Package piccolod

#!/usr/bin/env bash
set -euo pipefail

ver="${1:-}"
if [[ -z "$ver" || ! $ver =~ ^[0-9]+(\.[0-9]+)*$ ]]; then
  echo "Usage: $0 <version> (e.g., 0.1.4)" >&2
  exit 1
fi

osc up

# Update Version: tag in spec
# Use GNU sed to replace the Version line. Expand $ver in double quotes so
# the shell variable is substituted. This keeps a single command that's
# portable on Linux (GNU sed). It preserves the `Version:` prefix and
# replaces whatever follows with the new version.
sed -i -E "s/^(Version:[[:space:]]*).*/\1$ver/" piccolod.spec

# Recreate _service based on the requested version
cat > _service <<EOF2
<services>
  <service name="download_url">
    <param name="url">https://github.com/AtDexters-Lab/piccolod/releases/download/v$ver/piccolod-v$ver-linux-x86_64</param>
    <param name="filename">piccolod-v$ver-linux-x86_64</param>
  </service>
  <service name="download_url">
    <param name="url">https://github.com/AtDexters-Lab/piccolod/releases/download/v$ver/piccolod-v$ver-linux-aarch64</param>
    <param name="filename">piccolod-v$ver-linux-aarch64</param>
  </service>
</services>
EOF2

# Refresh file list (no-op if clean)
osc addremove >/dev/null || true

osc ci -m "Bump to $ver"
openSUSE Build Service is sponsored by