-
Notifications
You must be signed in to change notification settings - Fork 0
74 lines (71 loc) · 2.47 KB
/
release.yaml
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
67
68
69
70
71
72
73
74
name: Release
on:
workflow_dispatch:
release:
types: [published]
env:
DOTNET_CLI_TELEMETRY_OPTOUT: 1
DOTNET_NOLOGO: 1
jobs:
pack:
runs-on: ubuntu-latest
steps:
- name: Check out the repository
uses: actions/checkout@v4
- name: Setup .NET
uses: actions/setup-dotnet@v4
with:
dotnet-version: 9.x
- name: Extract version information
id: version-info
# expects x.x.x[-previewN]
run: |
echo "version=$(echo ${{ github.ref_name }} | cut -d "-" -f 1)" >> $GITHUB_OUTPUT
echo "full-version=${{ github.ref_name }}" >> $GITHUB_OUTPUT
- name: Validate extracted version information
run: |
if [[ ${{ steps.version-info.outputs.full-version }} =~ ^[[:digit:]]\.[[:digit:]]\.[[:digit:]](-preview([[:digit:]])+)?$ ]]; then
echo "Found valid version";
exit 0;
else
echo "Expected version to match 'x.x.x[-previewN]' got ${{ steps.version-info.outputs.full-version }}";
exit 1;
fi
- name: Verify package short version matches short version in tag
shell: pwsh
run: |
$version = (Select-String -Pattern "<Version>(\d\.\d\.\d)</Version>" -Path .\src\Quarer\Quarer.csproj).Matches.Groups[1].Value;
if ($version -eq "${{ steps.version-info.outputs.version }}")
{
Write-Host "Version matches"
}
else
{
Write-Error "Version '$version' does not match expected ref_name version '${{ steps.version-info.outputs.version }}' (from ${{ github.ref_name }})"
Exit 1
}
- name: Pack
run: dotnet pack "src/Quarer/Quarer.csproj" -c Release -o ./pack /p:Version=${{ steps.version-info.outputs.full-version }}
- name: Upload package artifacts
uses: actions/upload-artifact@v4
with:
name: nuget-packages
path: ./pack
push:
needs: pack
environment: release
runs-on: ubuntu-latest
steps:
- name: Check out the repository
uses: actions/checkout@v4
- name: Setup .NET
uses: actions/setup-dotnet@v4
with:
dotnet-version: 9.x
- name: Download package artifacts
uses: actions/download-artifact@v4
with:
name: nuget-packages
path: ./pack
- name: Publish
run: dotnet nuget push ./pack/*.nupkg --api-key ${{ secrets.NUGET_KEY }} --source ${{ vars.NUGET_FEED }}