Skip to content

Commit 1e93047

Browse files
committed
Add branch name to branch builds
1 parent 1147396 commit 1e93047

1 file changed

Lines changed: 9 additions & 1 deletion

File tree

.github/workflows/ci.yml

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -84,12 +84,20 @@ jobs:
8484
uses: actions/setup-dotnet@v5.2.0
8585
with:
8686
dotnet-version: 9.0.x
87+
- name: Compute version suffix for branch builds
88+
if: ${{ !startsWith(github.ref, 'refs/tags/') }}
89+
id: version
90+
run: |
91+
# Sanitize branch name: lowercase, replace non-alphanumeric with hyphen, trim to 20 chars
92+
BRANCH="${GITHUB_HEAD_REF:-${GITHUB_REF_NAME}}"
93+
SAFE_BRANCH=$(echo "$BRANCH" | tr '[:upper:]' '[:lower:]' | sed 's/[^a-z0-9]/-/g' | sed 's/--*/-/g' | sed 's/^-//' | sed 's/-$//' | cut -c1-20)
94+
echo "override=${SAFE_BRANCH}.${{ github.run_number }}" >> "$GITHUB_OUTPUT"
8795
- name: Download artifacts
8896
uses: actions/download-artifact@v8.0.1
8997
with:
9098
path: nuget.package/runtimes/
9199
- name: Create package
92-
run: dotnet pack nuget.package
100+
run: dotnet pack nuget.package ${{ steps.version.outputs.override && format('/p:MinVerDefaultPreReleaseIdentifiers="{0}"', steps.version.outputs.override) || '' }}
93101
- name: Upload NuGet package
94102
uses: actions/upload-artifact@v7.0.0
95103
with:

0 commit comments

Comments
 (0)