summaryrefslogtreecommitdiff
path: root/save_artifact.sh
blob: dd8dc45666ee70e09e53df5bffb9f88ad4b917b0 (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
#!/bin/bash
# Usage: ${{ github.workspace }}/save_artifact.sh libsodium "${SODIUM_VERSION}-${{ matrix.host_triplet }}-${SODIUM_HASH}" ${{ github.workspace }}/prefix/lib/libsodium.a

registry_user=mrcyjanek
cache_name="$1"
cache_key="$2"
path_to_file_="$3"

if [[ -f "/tmp/cache_hit_$(echo "$3" | md5sum | awk '{ print $1 }')" ]];
then
    echo "was cached $1 $2 $(basename $path_to_file_)"
    exit 0
fi

path_to_file="$3.xz"
basename="$(basename $path_to_file)"

if [[ ! -f "$path_to_file_" ]];
then
    echo "$(basename $path_to_file_) doesn't exist"
    exit 0;
fi

xz --extreme --keep $path_to_file_

curl --user $registry_user:$PAT_SECRET_PACKAGE \
     --upload-file "$path_to_file" \
     "https://git.mrcyjanek.net/api/packages/mrcyjanek/generic/monero_c/${cache_name}-${cache_key}/${basename}" &>/dev/null

echo "cached $1 $2 $(basename $path_to_file_)"

rm $path_to_file