Skip to content

Commit 2d9d126

Browse files
committed
quick: Attempting to lookup release id from tag name for cirrus
Adding more script work to figure out the release id to use for asset upload if only a tag is pushed and no release is generated through the github UI. The ID I got through testing seemed to work, so hopefully this helps correct the issue. Signed-off-by: Tyler Erickson <[email protected]>
1 parent 8b39dd3 commit 2d9d126

File tree

1 file changed

+20
-1
lines changed

1 file changed

+20
-1
lines changed

cirrus_ci_post_freebsd_release.sh

Lines changed: 20 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,11 @@
55
#openSeaChest. This script should be run after the tar.xz file is created by a successful build
66
#The other major change is that this script is posix shell compliant instead of requiring bash
77

8+
echo "Important script vars:"
9+
echo " CIRRUS_RELEASE=$CIRRUS_RELEASE"
10+
echo " CIRRUS_TAG=$CIRRUS_TAG"
11+
echo " CIRRUS_BRANCH=$CIRRUS_BRANCH"
12+
813
if [ "$CIRRUS_RELEASE" = "" ] && [ "$CIRRUS_TAG" = "" ]; then
914
echo "Not a release. No need to deploy!"
1015
exit 0
@@ -31,7 +36,21 @@ if [ -f "$file_to_upload" ]; then
3136
if [ "$CIRRUS_RELEASE" != "" ]; then
3237
url_to_upload="https://uploads.github.com/repos/$CIRRUS_REPO_FULL_NAME/releases/$CIRRUS_RELEASE/assets?name=$name"
3338
else
34-
url_to_upload="https://uploads.github.com/repos/$CIRRUS_REPO_FULL_NAME/releases/tag/$CIRRUS_TAG/assets?name=$name"
39+
#need to look up the release id to use for the upload since we do not have that right now-TJE
40+
response=$(curl \
41+
-H "Accept: application/vnd.github+json" \
42+
-H "Authorization: token $GITHUB_TOKEN"\
43+
-H "X-GitHub-Api-Version: 2022-11-28" \
44+
"https://api.github.com/repos/$CIRRUS_REPO_FULL_NAME/releases/tags/$CIRRUS_TAG")
45+
46+
#get the ID from the response...this nasty command that follows seems to get it
47+
id=$(echo "$response" | grep -m 1 "id.:" | grep -w id | tr : = | tr -cd '[[:alnum:]]=' | cut -d= -f2)
48+
49+
if [ "$id" != "" ]; then
50+
url_to_upload="https://uploads.github.com/repos/$CIRRUS_REPO_FULL_NAME/releases/tag/$id/assets?name=$name"
51+
else
52+
echo "Failed to get ID for uploading cirrus tag assets"
53+
fi
3554
fi
3655
curl -X POST \
3756
--data-binary @"$file_to_upload" \

0 commit comments

Comments
 (0)