#!/bin/bash

cd "${MESON_SOURCE_ROOT}"

VERSION=$(poetry version --short)

BODY="""See [NEWS file](https://github.com/orontee/argos/blob/v${VERSION}/NEWS.rst) for release content.

## Installation

Depending on the host OS:

* Install through Flatpak from [Argos page on Flathub](https://flathub.org/en/apps/io.github.orontee.Argos)
* On Debian distributions, use the official package repositories (🚧)
* On Arch Linux distributions, build from source using [the dedicated AUR package](https://aur.archlinux.org/packages/argos)
* On Windows, use WSL and above methods depending on the distribution

Detailed instructions are available in [README file](https://github.com/orontee/argos/tree/main/README.rst#install).
"""

TITLE="Release ${VERSION}"

urlencode() {
  python3 -c "import urllib.parse, sys; print(urllib.parse.quote(sys.argv[1], sys.argv[2]))" \
    "$1" "$urlencode_safe"
}
ENCODED_BODY=$(urlencode "${BODY}")
ENCODED_TITLE=$(urlencode "${TITLE}")

echo "Visit https://github.com/orontee/argos/releases/new?prerelease=1&tag=v${VERSION}&title=${ENCODED_TITLE}&body=${ENCODED_BODY}"
