Skip to content

Commit 2fde1c7

Browse files
committed
Release 0.1.0 - MCP Gateway - Build Image
Signed-off-by: Mihai Criveti <[email protected]>
1 parent b632d80 commit 2fde1c7

File tree

1 file changed

+31
-5
lines changed

1 file changed

+31
-5
lines changed

.github/workflows/docker-release.yml

Lines changed: 31 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -49,11 +49,37 @@ jobs:
4949
TAG="${{ github.event.release.tag_name }}"
5050
echo "tag=$TAG" >> "$GITHUB_OUTPUT"
5151
52-
# Fetch the commit SHA for this tag
53-
git init -q
54-
git remote add origin "https://github.com/${{ github.repository }}"
55-
git fetch --depth=1 origin "refs/tags/$TAG"
56-
SHA=$(git rev-list -n 1 "$TAG")
52+
# Method 1: Use the target_commitish from the release event if available
53+
if [ -n "${{ github.event.release.target_commitish }}" ]; then
54+
SHA="${{ github.event.release.target_commitish }}"
55+
echo "Using release target_commitish: $SHA"
56+
else
57+
# Method 2: Use GitHub API to get the commit SHA for the tag
58+
SHA=$(curl -sSL \
59+
-H "Accept: application/vnd.github+json" \
60+
-H "Authorization: Bearer ${{ secrets.GITHUB_TOKEN }}" \
61+
"https://api.github.com/repos/${{ github.repository }}/git/refs/tags/$TAG" \
62+
| jq -r '.object.sha')
63+
64+
# If it's an annotated tag, we need to get the commit it points to
65+
if [ -z "$SHA" ] || [ "$SHA" = "null" ]; then
66+
# Try getting the tag object
67+
TAG_SHA=$(curl -sSL \
68+
-H "Accept: application/vnd.github+json" \
69+
-H "Authorization: Bearer ${{ secrets.GITHUB_TOKEN }}" \
70+
"https://api.github.com/repos/${{ github.repository }}/git/refs/tags/$TAG" \
71+
| jq -r '.object.sha')
72+
73+
# Get the commit SHA from the tag object
74+
SHA=$(curl -sSL \
75+
-H "Accept: application/vnd.github+json" \
76+
-H "Authorization: Bearer ${{ secrets.GITHUB_TOKEN }}" \
77+
"https://api.github.com/repos/${{ github.repository }}/git/tags/$TAG_SHA" \
78+
| jq -r '.object.sha')
79+
fi
80+
fi
81+
82+
echo "Resolved commit SHA: $SHA"
5783
echo "sha=$SHA" >> "$GITHUB_OUTPUT"
5884
5985
# ----------------------------------------------------------------------

0 commit comments

Comments
 (0)