Skip to content

Commit 56101cf

Browse files
committed
fix: fail CD in case of no releases
1 parent 5973c97 commit 56101cf

File tree

1 file changed

+9
-4
lines changed

1 file changed

+9
-4
lines changed

.github/workflows/release.yml

Lines changed: 9 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -27,9 +27,14 @@ jobs:
2727
"${{ github.api_url }}/repos/${{ github.repository }}/releases/latest")
2828
2929
TAG_NAME=$(echo "$LATEST_RELEASE_JSON" | jq -r .tag_name)
30-
# remove the leading 'v' from the tag name
31-
echo "latest_version=${TAG_NAME:1}" >> "$GITHUB_OUTPUT"
32-
echo "🕰️ Latest released version: $TAG_NAME" >> "$GITHUB_STEP_SUMMARY"
30+
if [ "$TAG_NAME" = "null" ]; then
31+
echo "ERROR: no released versions exist" 1>&2
32+
exit 1
33+
else
34+
# remove the leading 'v' from the tag name
35+
echo "latest_version=${TAG_NAME:1}" >> "$GITHUB_OUTPUT"
36+
echo "🕰️ Latest released version: $TAG_NAME" >> "$GITHUB_STEP_SUMMARY"
37+
fi
3338
3439
- name: Get current version from Cargo.toml
3540
id: main_branch
@@ -41,8 +46,8 @@ jobs:
4146
- name: Compare versions
4247
id: compare_versions
4348
run: |
44-
MAIN_BRANCH_VERSION="${{ steps.main_branch.outputs.version }}"
4549
LATEST_VERSION="${{ steps.releases.outputs.latest_version }}"
50+
MAIN_BRANCH_VERSION="${{ steps.main_branch.outputs.version }}"
4651
4752
# Use sort -V to compare the versions numerically.
4853
# If MAIN_BRANCH_VERSION is truly greater, it will be the second item

0 commit comments

Comments
 (0)