summarylogtreecommitdiffstats
path: root/generate-pkgbuild.sh
blob: 0458d56dbe7b0fff74e264e7ec76009d8475f0d0 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
#!/usr/bin/env bash

set -euo pipefail

BASE_NAME=myks
BASE_DIR="$(mktemp -d --suffix=-${BASE_NAME})"
RELEASE_FILE="${BASE_DIR}/latest-release.json"

CONFLICTS=(
    "${BASE_NAME}"
    "${BASE_NAME}-bin"
    "${BASE_NAME}-git"
)

curl -fsSL https://api.github.com/repos/mykso/myks/releases/latest \
    --header "Authorization: Bearer $GITHUB_TOKEN" \
    -o "${RELEASE_FILE}"

VERSION="$(jq -r '.tag_name' "${RELEASE_FILE}" | sed 's/^v//')"

cat <<EOF
# Maintainer: German Lashevich <german.lashevich@gmail.com>

pkgver=${VERSION:?}
pkgname=${BASE_NAME}-bin
pkgrel=1
pkgdesc='Configuration framework for managing Kubernetes clusters'
provides=(${BASE_NAME})
conflicts=(${CONFLICTS[@]})
arch=(x86_64 aarch64)
url="https://github.com/mykso/${BASE_NAME}"
license=('MIT')

EOF

curl -fsSL \
    "$(jq -r '.assets[] | select(.name == "checksums.txt") | .browser_download_url' "${RELEASE_FILE}")" \
    --header "Authorization: Bearer $GITHUB_TOKEN" \
    -o "${BASE_DIR}/checksums.txt"

cat <<EOF
source_x86_64=("$(jq -r '.assets[] | select(.name | contains("linux_amd64")) | .name + "::" + .browser_download_url' "${RELEASE_FILE}")")
sha256sums_x86_64=("$(grep linux_amd64 "${BASE_DIR}/checksums.txt" | awk '{print $1}')")

source_aarch64=("$(jq -r '.assets[] | select(.name | contains("linux_arm64")) | .name + "::" + .browser_download_url' "${RELEASE_FILE}")")
sha256sums_aarch64=("$(grep linux_arm64 "${BASE_DIR}/checksums.txt" | awk '{print $1}')")

package() {
  install -Dm755 "\${srcdir}/${BASE_NAME}" "\${pkgdir}/usr/bin/${BASE_NAME}"
}
EOF