-
Notifications
You must be signed in to change notification settings - Fork 2
160 lines (140 loc) · 5.14 KB
/
dotnet-core.yml
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
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
name: demoapp
on:
push:
branches:
- develop
- master
env:
GITVERSION_VERSION: 5.12.0
DOTNET_SDK_VERSION: 8.0.403
DOTNET_SKIP_FIRST_TIME_EXPERIENCE: 1
DOTNET_CLI_TELEMETRY_OPTOUT: 1
SNAPX_LOG_EXCEPTIONS: 1
concurrency:
group: ${{ github.workflow }}-${{ github.event.pull_request.number || github.ref }}
cancel-in-progress: ${{ github.ref_name != 'master' }}
jobs:
setup:
name: Setup
runs-on: ubuntu-latest
outputs:
BUILD_VERSION: ${{ steps.set-build-version.outputs.BUILD_VERSION }}
SNAPX_VERSION: ${{ steps.set-snapx-version.outputs.SNAPX_VERSION }}
steps:
- name: Checkout
uses: actions/checkout@v4
with:
fetch-depth: 0
- name: Add dotnet tools to environment path
shell: pwsh
run: echo "${HOME}/.dotnet/tools" | Out-File -FilePath $env:GITHUB_PATH -Encoding utf8 -Append
- id: set-build-version
name: Read current application version
shell: pwsh
run: |
dotnet tool update GitVersion.Tool --global --version ${{ env.GITVERSION_VERSION }}
$BUILD_VERSION = (dotnet gitversion /showVariable NugetVersionv2) | out-string
echo "BUILD_VERSION=$BUILD_VERSION" >> $env:GITHUB_OUTPUT
- id: set-snapx-version
name: Read current snapx version
shell: pwsh
run: |
[xml] $xml_content = Get-Content ".\$GITHUB_WORKSPACE\Directory.Packages.props";
$SNAPX_VERSION = Select-Xml -Xml $xml_content -XPath "//Project/PropertyGroup/SnapxVersion" | Select -Expand Node | Select -Expand "#text"
echo "SNAPX_VERSION=$SNAPX_VERSION" >> $env:GITHUB_OUTPUT
build:
name: Build ${{ matrix.os }}-${{ matrix.rid }}
runs-on: ${{ matrix.os }}
needs: [setup]
strategy:
matrix:
include:
- os: ubuntu-latest
id: demoapp-linux-arm64
rid: linux-arm64
- os: ubuntu-latest
id: demoapp-linux-x64
rid: linux-x64
- os: windows-latest
id: demoapp-win-x86
rid: win-x86
- os: windows-latest
id: demoapp-win-x64
rid: win-x64
env:
BUILD_VERSION: ${{ needs.setup.outputs.BUILD_VERSION }}
SNAPX_VERSION: ${{ needs.setup.outputs.SNAPX_VERSION }}
steps:
- name: Checkout
uses: actions/checkout@v4
with:
fetch-depth: 0
lfs: true
- name: Setup dotnet ${{ env.DOTNET_SDK_VERSION }}
uses: actions/[email protected]
with:
dotnet-version: "${{ env.DOTNET_SDK_VERSION }}"
- name: Build
shell: pwsh
run: .\build.ps1 -Version ${{ env.BUILD_VERSION }} -Rid ${{ matrix.rid }}
- name: Upload artifacts
if: success()
uses: actions/upload-artifact@v4
with:
name: ${{ matrix.id }}-artifacts
path: ${{ github.workspace }}/.snapx/artifacts/${{ matrix.id }}/${{ matrix.rid }}/${{ env.BUILD_VERSION }}
publish:
if: success()
name: Publish ${{ matrix.rid }}
runs-on: ${{ matrix.os }}
needs: [setup, build]
strategy:
fail-fast: false
matrix:
include:
- os: ubuntu-latest
id: demoapp-linux-arm64
rid: linux-arm64
- os: ubuntu-latest
id: demoapp-linux-x64
rid: linux-x64
- os: windows-latest
id: demoapp-win-x86
rid: win-x86
- os: windows-latest
id: demoapp-win-x64
rid: win-x64
env:
BUILD_VERSION: ${{ needs.setup.outputs.BUILD_VERSION }}
SNAPX_VERSION: ${{ needs.setup.outputs.SNAPX_VERSION }}
steps:
- name: Checkout
uses: actions/checkout@v4
with:
fetch-depth: 0
lfs: true
- name: Setup dotnet ${{ env.DOTNET_SDK_VERSION }}
uses: actions/[email protected]
with:
dotnet-version: "${{ env.DOTNET_SDK_VERSION }}"
- name: Setup dotnet snapx
run: dotnet tool update snapx --global --version ${{ env.SNAPX_VERSION }}
- name: Download ${{ matrix.id }}-artifacts
uses: actions/download-artifact@v4
with:
name: ${{ matrix.id }}-artifacts
path: ${{ github.workspace }}/.snapx/artifacts/${{ matrix.id }}/${{ matrix.rid }}/${{ env.BUILD_VERSION }}
- name: Add demoapp nuget publish feed
shell: pwsh
run: |
$SourceUrl = Get-Content .snapx/update.json | ConvertFrom-Json | Select -ExpandProperty source
dotnet nuget add source ${SourceUrl} --name demoapp-publish-feed
- name: Generate snapx cache files
run: snapx restore --package-file ${{ matrix.id }}
- name: Restore snapx nuget packages for test release channel
uses: actions/cache@v4
with:
path: .snapx/packages/${{ matrix.id }}/${{ matrix.rid }}
key: ${{ matrix.id }}-test-${{ hashFiles('packages-test.txt') }}
- name: Publish ${{ matrix.id }} to test channel
run: snapx pack ${{ matrix.id }} --api-key ${{ secrets.DEMOAPP_PUBLISH_FEED_API_KEY }} -r ${{ matrix.rid }} -v ${{ env.BUILD_VERSION }} --lock-token ${{ secrets.SNAPX_TOKEN }} --lock-retries -1 -y