# Contributor: Patrycja Rosa <alpine@ptrcnull.me>
# Maintainer: Patrycja Rosa <alpine@ptrcnull.me>
pkgname=forgejo-runner
pkgver=3.5.1
pkgrel=0
pkgdesc="CI/CD job runner for Forgejo"
url="https://code.forgejo.org/forgejo/runner"
arch="all"
license="MIT"
makedepends="go"
install="$pkgname.pre-install $pkgname.pre-upgrade"
subpackages="$pkgname-openrc"
source="$pkgname-$pkgver.tar.gz::https://code.forgejo.org/forgejo/runner/archive/v$pkgver.tar.gz

	forgejo-runner.logrotate
	forgejo-runner.initd
	forgejo-runner.confd
	"
builddir="$srcdir/runner"
# !check: tests require running forgejo
# net: downloading go packages
options="!check net"

build() {
	go build \
		-o forgejo-runner \
		-ldflags "-X gitea.com/gitea/act_runner/internal/pkg/ver.version=$pkgver"
	./forgejo-runner generate-config > config.example.yaml
}

check() {
	go test ./...
}

package() {
	install -Dm755 forgejo-runner -t "$pkgdir"/usr/bin/
	install -Dm644 config.example.yaml -t "$pkgdir"/etc/forgejo-runner/

	install -Dm755 "$srcdir"/forgejo-runner.initd "$pkgdir"/etc/init.d/forgejo-runner
	install -Dm644 "$srcdir"/forgejo-runner.confd "$pkgdir"/etc/conf.d/forgejo-runner
	install -Dm644 "$srcdir"/forgejo-runner.logrotate "$pkgdir"/etc/logrotate.d/forgejo-runner
}

sha512sums="
de40e20df8ad2c87c88cd9f1de6c9e170f4dbd6890ee1ba9b297a4bb53537399c25fe16b27d55c38db6b456c4e186ce9abed4a825b87708292ce8d8b273b6eaa  forgejo-runner-3.5.1.tar.gz
a3c7238b0c63053325d31e09277edd88690ef5260854517f82d9042d6173fb5d24ebfe36e1d7363673dd8801972638a6e69b6af8ad43debb6057515c73655236  forgejo-runner.logrotate
bb0c6fbe90109c77f9ef9cb0d35d20b8033be0e4b7a60839b596aa5528dfa24309ec894d8c04066bf8fb30143e63a5fd8cc6fc89aac364422b583e0f840e2da6  forgejo-runner.initd
e11eab27f88f1181112389befa7de3aa0bac7c26841861918707ede53335535425c805e6682e25704e9c8a6aecba3dc13e20900a99df1183762b012b62f26d5f  forgejo-runner.confd
"
