2022-05-19 23:59:13 +02:00
|
|
|
#!/usr/bin/env nix-shell
|
|
|
|
#!nix-shell -i bash -p curl gnugrep gnused jq
|
|
|
|
|
|
|
|
set -x -eu -o pipefail
|
|
|
|
|
|
|
|
WORKDIR=$(mktemp -d)
|
|
|
|
trap "rm -rf ${WORKDIR}" EXIT
|
|
|
|
|
|
|
|
NIXPKGS_CRC_FOLDER=$(
|
|
|
|
cd $(dirname ${BASH_SOURCE[0]})
|
|
|
|
pwd -P
|
|
|
|
)
|
|
|
|
cd ${NIXPKGS_CRC_FOLDER}
|
|
|
|
|
|
|
|
LATEST_TAG_RAWFILE=${WORKDIR}/latest_tag.json
|
2022-12-03 02:52:34 +01:00
|
|
|
curl --silent ${GITHUB_TOKEN:+-u ":$GITHUB_TOKEN"} \
|
2023-01-03 03:39:10 +01:00
|
|
|
https://api.github.com/repos/crc-org/crc/releases >${LATEST_TAG_RAWFILE}
|
2022-05-19 23:59:13 +02:00
|
|
|
|
|
|
|
LATEST_TAG_NAME=$(jq 'map(.tag_name)' ${LATEST_TAG_RAWFILE} |
|
|
|
|
grep -v -e rc -e engine | tail -n +2 | head -n -1 | sed 's|[", ]||g' | sort -rV | head -n1)
|
|
|
|
|
|
|
|
CRC_VERSION=$(echo ${LATEST_TAG_NAME} | sed 's/^v//')
|
|
|
|
|
2022-12-03 02:52:34 +01:00
|
|
|
CRC_COMMIT=$(curl --silent ${GITHUB_TOKEN:+-u ":$GITHUB_TOKEN"} \
|
2023-01-03 03:39:10 +01:00
|
|
|
https://api.github.com/repos/crc-org/crc/tags |
|
2022-05-19 23:59:13 +02:00
|
|
|
jq -r "map(select(.name == \"${LATEST_TAG_NAME}\")) | .[0] | .commit.sha")
|
|
|
|
|
2023-03-20 16:53:08 +01:00
|
|
|
CRC_GIT_PREFETCH=$(nix-prefetch-url --unpack https://github.com/crc-org/crc/archive/${CRC_COMMIT}.tar.gz)
|
|
|
|
CRC_GIT_HASH=$(nix hash to-sri --type sha256 ${CRC_GIT_PREFETCH})
|
|
|
|
|
2022-05-19 23:59:13 +02:00
|
|
|
FILE_MAKEFILE=${WORKDIR}/Makefile
|
2023-01-03 03:39:10 +01:00
|
|
|
curl --silent https://raw.githubusercontent.com/crc-org/crc/${CRC_COMMIT}/Makefile >$FILE_MAKEFILE
|
2022-05-19 23:59:13 +02:00
|
|
|
|
|
|
|
OPENSHIFT_VERSION=$(grep 'OPENSHIFT_VERSION' ${FILE_MAKEFILE} |
|
|
|
|
head -n1 | awk '{print $3}')
|
|
|
|
|
2023-01-03 03:39:10 +01:00
|
|
|
OKD_VERSION=$(grep 'OKD_VERSION' ${FILE_MAKEFILE} |
|
|
|
|
head -n1 | awk '{print $3}')
|
|
|
|
|
2022-05-19 23:59:13 +02:00
|
|
|
PODMAN_VERSION=$(grep 'PODMAN_VERSION' ${FILE_MAKEFILE} |
|
|
|
|
head -n1 | awk '{print $3}')
|
|
|
|
|
2023-12-30 10:08:46 +01:00
|
|
|
MICROSHIFT_VERSION=$(grep 'MICROSHIFT_VERSION' ${FILE_MAKEFILE} |
|
|
|
|
head -n1 | awk '{print $3}')
|
|
|
|
|
|
|
|
WRITE_KEY=$(grep 'pkg/crc/segment.WriteKey' ${FILE_MAKEFILE} |
|
2022-05-19 23:59:13 +02:00
|
|
|
head -n1 | awk '{print $4}' | sed -e 's/$(REPOPATH)\/pkg\/crc\/segment.WriteKey=//g')
|
|
|
|
|
|
|
|
sed -i "s|version = \".*\"|version = \"${CRC_VERSION:-}\"|" \
|
2023-12-30 11:14:54 +01:00
|
|
|
${NIXPKGS_CRC_FOLDER}/package.nix
|
2022-05-19 23:59:13 +02:00
|
|
|
|
|
|
|
sed -i "s|gitCommit = \".*\"|gitCommit = \"${CRC_COMMIT:-}\"|" \
|
2023-12-30 11:14:54 +01:00
|
|
|
${NIXPKGS_CRC_FOLDER}/package.nix
|
2022-05-19 23:59:13 +02:00
|
|
|
|
2023-03-20 16:53:08 +01:00
|
|
|
sed -i "s|gitHash = \".*\"|gitHash = \"${CRC_GIT_HASH}\"|" \
|
2023-12-30 11:14:54 +01:00
|
|
|
${NIXPKGS_CRC_FOLDER}/package.nix
|
2023-03-20 16:53:08 +01:00
|
|
|
|
2022-05-19 23:59:13 +02:00
|
|
|
sed -i "s|openShiftVersion = \".*\"|openShiftVersion = \"${OPENSHIFT_VERSION:-}\"|" \
|
2023-12-30 11:14:54 +01:00
|
|
|
${NIXPKGS_CRC_FOLDER}/package.nix
|
2022-05-19 23:59:13 +02:00
|
|
|
|
2023-01-03 03:39:10 +01:00
|
|
|
sed -i "s|okdVersion = \".*\"|okdVersion = \"${OKD_VERSION:-}\"|" \
|
2023-12-30 11:14:54 +01:00
|
|
|
${NIXPKGS_CRC_FOLDER}/package.nix
|
2023-01-03 03:39:10 +01:00
|
|
|
|
2022-05-19 23:59:13 +02:00
|
|
|
sed -i "s|podmanVersion = \".*\"|podmanVersion = \"${PODMAN_VERSION:-}\"|" \
|
2023-12-30 11:14:54 +01:00
|
|
|
${NIXPKGS_CRC_FOLDER}/package.nix
|
2022-05-19 23:59:13 +02:00
|
|
|
|
2023-12-30 10:08:46 +01:00
|
|
|
sed -i "s|microshiftVersion = \".*\"|microshiftVersion = \"${MICROSHIFT_VERSION:-}\"|" \
|
2023-12-30 11:14:54 +01:00
|
|
|
${NIXPKGS_CRC_FOLDER}/package.nix
|
2023-12-30 10:08:46 +01:00
|
|
|
|
2022-05-19 23:59:13 +02:00
|
|
|
sed -i "s|writeKey = \".*\"|writeKey = \"${WRITE_KEY:-}\"|" \
|
2023-12-30 11:14:54 +01:00
|
|
|
${NIXPKGS_CRC_FOLDER}/package.nix
|