Skip to content

Commit a231a20

Browse files
committed
Merge branch 'feat/polymorphically-dispatch'
2 parents dd75f05 + 9b17399 commit a231a20

1 file changed

Lines changed: 13 additions & 3 deletions

File tree

‎.github/workflows/release.yml‎

Lines changed: 13 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -24,6 +24,8 @@ jobs:
2424
steps:
2525
- name: Checkout
2626
uses: actions/checkout@v4
27+
with:
28+
ref: ${{ github.event.release.tag_name || github.ref }}
2729

2830
- name: Setup .NET SDKs
2931
uses: actions/setup-dotnet@v4
@@ -45,10 +47,18 @@ jobs:
4547
id: version
4648
run: |
4749
if [ "${{ github.event_name }}" = "workflow_dispatch" ]; then
48-
VERSION="${{ inputs.version }}"
50+
TAG="${{ inputs.version }}"
4951
else
50-
# Strip 'v' prefix from tag: v1.2.3 -> 1.2.3
51-
VERSION="${GITHUB_REF_NAME#v}"
52+
# Read the tag from the release payload, NOT $GITHUB_REF_NAME: when a
53+
# release is published from a draft, the ref can resolve to the
54+
# default branch (main) instead of the tag, yielding an empty version.
55+
TAG="${{ github.event.release.tag_name }}"
56+
fi
57+
# Strip optional leading 'v': v1.2.3 -> 1.2.3
58+
VERSION="${TAG#v}"
59+
if [ -z "$VERSION" ]; then
60+
echo "::error::Could not determine a version to publish (event=${{ github.event_name }}, tag='${TAG}'). An empty VersionPrefix would override the default 1.0.0 and break 'dotnet pack'."
61+
exit 1
5262
fi
5363
echo "version=$VERSION" >> "$GITHUB_OUTPUT"
5464
echo "Publishing version: $VERSION"

0 commit comments

Comments
 (0)