Skip to content

Commit

Permalink
Respect GitHub Prerelease status
Browse files Browse the repository at this point in the history
  • Loading branch information
Rjvs committed Aug 8, 2023
1 parent 2f29b7e commit 86a7631
Showing 1 changed file with 29 additions and 1 deletion.
30 changes: 29 additions & 1 deletion .github/workflows/metadata.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,7 @@ on:
value: ${{ jobs.version.outputs.triple }}
preRelease:
description: Boolean, true if version is pre-release
value: ${{ jobs.version.outputs.preRelease }}
value: ${{ jobs.meta.outputs.preRelease }}
currentBranch:
description: Name of the current branch of the project
value: ${{ jobs.meta.outputs.currentBranch }}
Expand Down Expand Up @@ -122,6 +122,7 @@ jobs:
tagsUrl: ${{ steps.url.outputs.tagsUrl }}
releasesUrl: ${{ steps.url.outputs.releasesUrl }}
short_sha: ${{ steps.api.outputs.short_sha }}
preRelease: ${{ steps.status.outputs.preRelease }}

steps:
- name: Debug
Expand Down Expand Up @@ -208,3 +209,30 @@ jobs:
echo "tagsUrl=${tagsUrl}" >> "$GITHUB_OUTPUT"
echo "releasesUrl=${releasesUrl}" >> "$GITHUB_OUTPUT"
- name: Status
id: status
if: ${{ github.ref_type }} == "tag"
env:
preRelease: ${{ needs.version.outputs.preRelease }} # true or false
tag: ${{ github.ref }}
url: ${{ steps.api.outputs.url }}
run: |
# If the tag is a prerelease, set the preRelease flag true, regardless of the value from version
tag=${tag##refs/tag/}
# Fetch releases from GitHub API
releases=$(curl -s "$url/releases")
# Extract the 'prerelease' field for the given tag
prerelease=$(echo "$releases" | jq --raw-output ".[] | select(.tag_name == \"$tag\") | .prerelease")
# Check if the tag was found and if it's a prerelease
if [ -z "$prerelease" ]; then
echo "Tag $tag not found in releases."
exit 1
elif [ "$prerelease" == "true" ]; then
echo "Tag $tag is a prerelease."
preRelease="true"
else
echo "Tag $tag is NOT a prerelease."
fi
echo "preRelease=${preRelease}" >> "$GITHUB_OUTPUT"

0 comments on commit 86a7631

Please sign in to comment.