-
Notifications
You must be signed in to change notification settings - Fork 0
108 lines (88 loc) · 3.57 KB
/
release.yml
File metadata and controls
108 lines (88 loc) · 3.57 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
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
name: Release
on:
push:
branches:
- 'release/v*'
jobs:
verify-frameworks:
runs-on: ubuntu-latest
strategy:
matrix:
dotnet-version: ['8.0', '9.0', '10.0']
steps:
- uses: actions/checkout@v6
with:
fetch-depth: 0
- name: Setup .NET SDKs
uses: actions/setup-dotnet@v5
with:
dotnet-version: |
8.0.x
9.0.x
10.0.x
- name: Build Example Apps
run: |
dotnet build tests/SimpleBranchVersioning.ExampleApp -c Release
dotnet build tests/SimpleBranchVersioning.ConfiguredApp -c Release
- name: Run ExampleApp
run: dotnet run --project tests/SimpleBranchVersioning.ExampleApp -f net${{ matrix.dotnet-version }} -c Release --no-build
- name: Run ConfiguredApp
run: dotnet run --project tests/SimpleBranchVersioning.ConfiguredApp -f net${{ matrix.dotnet-version }} -c Release --no-build
- name: Verify version.json
run: |
# ConfiguredApp should have version.json (GenerateVersionFile=true)
if [ ! -f "tests/SimpleBranchVersioning.ConfiguredApp/bin/Release/net${{ matrix.dotnet-version }}/version.json" ]; then
echo "::error::ConfiguredApp is missing version.json for net${{ matrix.dotnet-version }}"
exit 1
fi
echo "ConfiguredApp version.json exists for net${{ matrix.dotnet-version }}"
cat tests/SimpleBranchVersioning.ConfiguredApp/bin/Release/net${{ matrix.dotnet-version }}/version.json
# ExampleApp should NOT have version.json (GenerateVersionFile=false by default)
if [ -f "tests/SimpleBranchVersioning.ExampleApp/bin/Release/net${{ matrix.dotnet-version }}/version.json" ]; then
echo "::error::ExampleApp should not have version.json for net${{ matrix.dotnet-version }}"
exit 1
fi
echo "ExampleApp correctly has no version.json for net${{ matrix.dotnet-version }}"
release:
needs: verify-frameworks
runs-on: ubuntu-latest
permissions:
contents: write
id-token: write
steps:
- uses: actions/checkout@v6
with:
fetch-depth: 0
- name: Extract version from branch
id: version
run: |
BRANCH=${GITHUB_REF#refs/heads/}
VERSION=${BRANCH#release/v}
echo "version=$VERSION" >> $GITHUB_OUTPUT
echo "tag=v$VERSION" >> $GITHUB_OUTPUT
- name: Setup .NET
uses: actions/setup-dotnet@v5
with:
dotnet-version: 10.0.x
- name: Restore
run: dotnet restore
- name: Build
run: dotnet build --no-restore -c Release -p:Version=${{ steps.version.outputs.version }}
- name: Test
run: dotnet test --no-build -c Release --verbosity normal
- name: Pack
run: dotnet pack src/SimpleBranchVersioning/SimpleBranchVersioning.csproj --no-build -c Release -o ./artifacts -p:Version=${{ steps.version.outputs.version }}
- name: NuGet login
id: nuget-login
uses: nuget/login@v1
with:
user: ${{ secrets.NUGET_USER }}
- name: Publish to NuGet
run: dotnet nuget push ./artifacts/*.nupkg --api-key "${{ steps.nuget-login.outputs.NUGET_API_KEY }}" --source https://api.nuget.org/v3/index.json --skip-duplicate
- name: Create GitHub Release
uses: softprops/action-gh-release@v3
with:
tag_name: ${{ steps.version.outputs.tag }}
name: ${{ steps.version.outputs.tag }}
generate_release_notes: true
files: ./artifacts/*.nupkg