# Maintainer: James "Bruce" Osborne <you@example.com>
pkgname=relibre
pkgver=0.1.0
pkgrel=1
pkgdesc="Native webview app to generate single-file landing pages for music releases"
arch=('x86_64')
url="https://git.circlewithadot.net/incentive/relibre"
license=('MIT')
depends=('gtk3' 'webkit2gtk' 'libsoup3')
makedepends=('go' 'git')
provides=('relibre')
conflicts=('relibre-bin')

# Build from a specific tag; update tag and checksum for new releases
source=("${pkgname}::git+${url}.git#tag=v${pkgver}")
sha256sums=('SKIP')

# If you need a submodule, add: options=('!strip') and git submodule init/update lines in build()

prepare() {
  cd "${srcdir}/${pkgname}"
  # Ensure Go modules are present
  export GOPATH="${srcdir}/gopath"
  export GOMODCACHE="${GOPATH}/pkg/mod"
  go mod download
}

build() {
  cd "${srcdir}/${pkgname}"
  export CGO_ENABLED=1
  go build -trimpath -ldflags "-s -w" -o relibre
}

package() {
  cd "${srcdir}/${pkgname}"
  install -Dm755 relibre "${pkgdir}/usr/bin/relibre"

  # Desktop entry and icon (optional but nice)
  install -Dm644 dist/com.circlewithadot.Relibre.desktop \
    "${pkgdir}/usr/share/applications/com.circlewithadot.Relibre.desktop"
  install -Dm644 dist/com.circlewithadot.Relibre.png \
    "${pkgdir}/usr/share/icons/hicolor/512x512/apps/com.circlewithadot.Relibre.png"

  # License
  install -Dm644 LICENSE "${pkgdir}/usr/share/licenses/${pkgname}/LICENSE"
}
