Skip to content

Commit 3bd1121

Browse files
committed
Separate version for branchess
1 parent 3a11a0a commit 3bd1121

File tree

1 file changed

+12
-4
lines changed

1 file changed

+12
-4
lines changed

.github/workflows/ci.yml

Lines changed: 12 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -22,8 +22,16 @@ jobs:
2222
uses: actions/setup-dotnet@v4.0.0
2323
with:
2424
dotnet-version: 9.0.x
25+
- name: Compute version suffix for branch builds
26+
if: ${{ !startsWith(github.ref, 'refs/tags/') }}
27+
id: version
28+
run: |
29+
# Sanitize branch name: lowercase, replace non-alphanumeric with hyphen, trim to 20 chars
30+
BRANCH="${GITHUB_HEAD_REF:-${GITHUB_REF_NAME}}"
31+
SAFE_BRANCH=$(echo "$BRANCH" | tr '[:upper:]' '[:lower:]' | sed 's/[^a-z0-9]/-/g' | sed 's/--*/-/g' | sed 's/^-//' | sed 's/-$//' | cut -c1-20)
32+
echo "override=octopus.${SAFE_BRANCH}.${{ github.run_number }}" >> "$GITHUB_OUTPUT"
2533
- name: Build
26-
run: dotnet build LibGit2Sharp.sln --configuration Release
34+
run: dotnet build LibGit2Sharp.sln --configuration Release ${{ steps.version.outputs.override && format('/p:MinVerDefaultPreReleaseIdentifiers="{0}"', steps.version.outputs.override) || '' }}
2735
- name: Upload packages
2836
uses: actions/upload-artifact@v4.3.1
2937
with:
@@ -32,7 +40,7 @@ jobs:
3240
retention-days: 7
3341
- name: Verify trimming compatibility
3442
run: dotnet publish TrimmingTestApp
35-
43+
3644
test:
3745
name: Test / ${{ matrix.os }} / ${{ matrix.arch }} / ${{ matrix.tfm }}
3846
runs-on: ${{ matrix.os }}
@@ -93,7 +101,7 @@ jobs:
93101
git_command="git config --global --add safe.directory /app"
94102
test_command="dotnet test LibGit2Sharp.sln --configuration Release -p:TargetFrameworks=${{ matrix.tfm }} --logger "GitHubActions" -p:ExtraDefine=LEAKS_IDENTIFYING"
95103
docker run -t --rm --platform linux/${{ matrix.arch }} -v "$PWD:/app" -e OPENSSL_ENABLE_SHA1_SIGNATURES=1 gittools/build-images:${{ matrix.distro }}-sdk-${{ matrix.sdk }} sh -c "$git_command && $test_command"
96-
104+
97105
nuget-push:
98106
name: Octopus NuGet Push
99107
needs: [build, test, test-linux]
@@ -110,4 +118,4 @@ jobs:
110118
env:
111119
FEED_API_KEY: ${{ secrets.FEED_API_KEY }}
112120
FEED_SOURCE: ${{ secrets.FEED_SOURCE }}
113-
run: dotnet nuget push staging/**/*.nupkg --api-key "$FEED_API_KEY" --source "$FEED_SOURCE"
121+
run: dotnet nuget push staging/**/*.nupkg --api-key "$FEED_API_KEY" --source "$FEED_SOURCE" --skip-duplicate

0 commit comments

Comments
 (0)