Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Run CI workflow on tags and add -l flag to get script #1647

Merged
merged 1 commit into from
Aug 30, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 2 additions & 0 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,8 @@ name: ci
on:
pull_request: {}
push:
tags:
- "*"
branches:
- main
env:
Expand Down
18 changes: 14 additions & 4 deletions scripts/get
Original file line number Diff line number Diff line change
Expand Up @@ -3,21 +3,27 @@ set -euo pipefail

BASE_URL=https://storage.googleapis.com/cri-o/conmon-rs
COMMIT=
TAG=
OUTPUT=conmonrs

usage() {
printf "Usage: %s [ -t SHA ] [ -h ]\n\n" "$(basename "$0")"
echo "Possible arguments:"
printf " -o\tOutput path for the downloaded binary (defaults to './conmonrs')\n"
printf " -t\tFull length SHA to be used (defaults to the latest available main)\n"
printf " -l\tTag to be used\n"
printf " -h\tShow this help message\n"
}

parse_args() {
echo "Welcome to the conmon-rs install script!"

while getopts 'o:t:h' OPTION; do
while getopts 'l:o:t:h' OPTION; do
case "$OPTION" in
l)
TAG="$OPTARG"
echo "Using tag: $TAG"
;;
o)
OUTPUT="$OPTARG"
echo "Using output path: $OUTPUT"
Expand All @@ -39,7 +45,7 @@ parse_args() {
}

verify_requirements() {
CMDS=(curl)
CMDS=(curl jq)
echo "Checking if all commands are available: ${CMDS[*]}"
for CMD in "${CMDS[@]}"; do
if ! command -v "$CMD" >/dev/null; then
Expand All @@ -54,10 +60,14 @@ curl_retry() {
}

download_binary() {
if [[ $COMMIT == "" ]]; then
if [[ $TAG != "" ]]; then
echo "Getting commit from tag"
COMMIT=$(curl_retry "https://api.github.com/repos/containers/conmon-rs/git/refs/tags/$TAG" | jq -r .object.sha)
elif [[ $COMMIT == "" ]]; then
echo "Getting latest commit on main"
COMMIT=$(curl_retry $BASE_URL/latest-main.txt)
fi
echo "Using commit $COMMIT"
echo "Found commit: $COMMIT"

mkdir -p "$(dirname "$OUTPUT")"

Expand Down