Skip to content

Commit

Permalink
feat: add cosign (#308)
Browse files Browse the repository at this point in the history
  • Loading branch information
bsherman authored Aug 23, 2023
1 parent 735aeee commit 4ba7efd
Show file tree
Hide file tree
Showing 3 changed files with 47 additions and 0 deletions.
1 change: 1 addition & 0 deletions Containerfile
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@ FROM ${BASE_IMAGE}:${FEDORA_MAJOR_VERSION} AS builder
ARG IMAGE_NAME="${IMAGE_NAME}"
ARG FEDORA_MAJOR_VERSION="${FEDORA_MAJOR_VERSION}"

ADD github-release-install.sh /tmp/github-release-install.sh
ADD build.sh /tmp/build.sh
ADD post-install.sh /tmp/post-install.sh
ADD packages.json /tmp/packages.json
Expand Down
3 changes: 3 additions & 0 deletions build.sh
Original file line number Diff line number Diff line change
Expand Up @@ -56,3 +56,6 @@ else
echo "No packages to install."

fi

## install packages direct from github
/tmp/github-release-install.sh sigstore/cosign x86_64.rpm
43 changes: 43 additions & 0 deletions github-release-install.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,43 @@
#!/bin/bash
#
# A script to install an RPM from the latest Github release for a project.
#
# ORG_PROJ is the pair of URL components for organization/projectName in Github URL
# example: https://github.com/wez/wezterm/releases
# ORG_PROJ would be "wez/wezterm"
#
# FILTER is used if there are more than one RPMs which match our arch/noarch.rpm pattern
# example: wezterm builds a lot of rpms, but they are labeled by distro so we can filter
# FILTER would be "fedora36" to get the RPM build for fedora36 OR "fedora" should get
# the RPM build for fedora37 (or newest fedora build) due to a reverse sort

ORG_PROJ=${1}
SUFFIX=${2}
FILTER=${3}

usage() {
echo "$0 ORG_PROJ SUFFIX [FILTER]"
echo " ORG_PROJ - organization/projectname"
echo " SUFFIX - trailing part of rpm name: eg, x86_64rpm or noarch.rpm"
echo " FILTER - optional extra filter to further limit rpm selection"

}

if [ -z ${ORG_PROJ} ]; then
usage
exit 1
fi

if [ -z ${SUFFIX} ]; then
usage
exit 2
fi

API="https://api.github.com/repos/${ORG_PROJ}/releases/latest"
RPM_URLS=$(curl -sL ${API} | jq -r '.assets[].browser_download_url' | grep -E "${SUFFIX}$" | grep "${FILTER}" |sort -r)
for URL in ${RPM_URLS}; do
# WARNING: in case of multiple matches, this only installs the first (hopefully the newest, given the reverse sort)
echo "execute: rpm-ostree install \"${URL}\""
rpm-ostree install "${URL}"
break
done

0 comments on commit 4ba7efd

Please sign in to comment.