-
Notifications
You must be signed in to change notification settings - Fork 0
66 lines (52 loc) · 1.94 KB
/
Copy pathci.yml
File metadata and controls
66 lines (52 loc) · 1.94 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
name: CI
on: [push, pull_request]
jobs:
build:
runs-on: ubuntu-latest
permissions:
contents: read
steps:
- uses: actions/checkout@v4
with:
fetch-depth: 0
- name: Setup .NET
uses: actions/setup-dotnet@v4
with:
dotnet-version: '10.0.x'
- name: Compute version suffix
id: version
shell: pwsh
run: |
$ErrorActionPreference = 'Stop'
# Short SHA for build metadata
$shortSha = $env:GITHUB_SHA.Substring(0,7)
# Sanitize branch for metadata
$rawBranch = $env:GITHUB_REF_NAME
$safeBranch = $rawBranch -replace '[/_]', '-'
$safeBranch = $safeBranch.ToLowerInvariant()
# Find nearest version tag vX.Y.Z and get distance
$baseTag = $null
try {
$baseTag = git describe --tags --match "v[0-9]*.[0-9]*.[0-9]*" --abbrev=0 2>$null
} catch {
Write-Host "No version tag found"
}
if ([string]::IsNullOrWhiteSpace($baseTag)) {
# No tag found, count all commits
$distance = git rev-list --count HEAD
} else {
# Count commits since tag
$distance = git rev-list --count "$baseTag..HEAD"
}
$VERSION_SUFFIX = "ci.$distance+$safeBranch.$shortSha"
Write-Host "Computed VERSION_SUFFIX=$VERSION_SUFFIX"
"VERSION_SUFFIX=$VERSION_SUFFIX" | Out-File -FilePath $Env:GITHUB_OUTPUT -Append -Encoding utf8
- name: dotnet build
run: dotnet build -c Release
- name: dotnet test
run: dotnet test -c Release --no-build
- name: dotnet pack
run: dotnet pack -c Release --no-build -p:VersionSuffix=${{ steps.version.outputs.VERSION_SUFFIX }}
- name: Push to feedz.io
if: github.event_name == 'push' && github.ref == 'refs/heads/main'
run: dotnet nuget push ./artifacts/*.nupkg -s https://f.feedz.io/davidfowl/aspire/nuget/index.json -k ${{ secrets.FEEDZ_TOKEN }} --skip-duplicate