-
-
Notifications
You must be signed in to change notification settings - Fork 20
96 lines (81 loc) · 3.28 KB
/
nuget_preview_publish_and_app_deploy.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
name: Publish Nuget Preview Package and deploy Test App
on:
push:
branches:
- '**'
env:
AZURE_WEBAPP_NAME: MudEx
AZURE_WEBAPP_PACKAGE_PATH: SampleApplication/publish
AZURE_WEBAPP_PUBLISH_PROFILE: ${{ secrets.MudEx_016e }}
CONFIGURATION: Release
DOTNET_CORE_VERSION: 8.0.x
WORKING_DIRECTORY: Samples/MainSample.WebAssembly
jobs:
build_and_deploy_preview_package:
runs-on: ubuntu-latest
steps:
- name: Set Branch Name as Environment Variable
run: |
# Extract branch name
BRANCH_NAME=${GITHUB_REF#refs/heads/}
# Ensure branch name is safe for NuGet versioning (replace '/' with '-')
SAFE_BRANCH_NAME=${BRANCH_NAME////-}
# Set SAFE_BRANCH_NAME as an environment variable for subsequent steps
echo "SAFE_BRANCH_NAME=$SAFE_BRANCH_NAME" >> $GITHUB_ENV
- name: Checkout code
uses: actions/checkout@v2
- name: Setup .NET
uses: actions/setup-dotnet@v1
with:
dotnet-version: '8.0.x'
- name: Restore dependencies
run: dotnet restore ./MudBlazor.Extensions/MudBlazor.Extensions.csproj
- name: First Build (ignore errors)
continue-on-error: true
run: dotnet build ./MudBlazor.Extensions/MudBlazor.Extensions.csproj --configuration Debug --no-restore
- name: Build with Branch Name Suffix
shell: pwsh
run: |
dotnet build ./MudBlazor.Extensions/MudBlazor.Extensions.csproj -p:VersionSuffix=prev-$([System.DateTime]::Now.ToString('yyMMddHHm'))-$env:SAFE_BRANCH_NAME --configuration Debug --no-restore
#- name: Run Tests
# run: dotnet test ./MudBlazor.Extensions.Tests/MudBlazor.Extensions.Tests.csproj
- name: Publish Package
env:
NUGET_API_KEY: ${{ secrets.NUGET_API_KEY }}
shell: pwsh
run: |
Get-ChildItem -Path MudBlazor.Extensions/bin/Debug -Filter *.nupkg | ForEach-Object {
dotnet nuget push $_.FullName -k $env:NUGET_API_KEY -s https://api.nuget.org/v3/index.json --skip-duplicate
}
deploy_application_to_azure:
needs: build_and_deploy_preview_package
runs-on: windows-latest
if: github.ref == 'refs/heads/main'
steps:
- uses: actions/checkout@v2
- name: Setup .NET Core
uses: actions/setup-dotnet@v1
with:
dotnet-version: ${{ env.DOTNET_CORE_VERSION }}
# Delay to ensure the Nuget package is indexed before Azure deployment
- name: Delay
run: sleep 300
- name: Restore
run: dotnet restore "${{ env.WORKING_DIRECTORY }}"
- name: Build
run: dotnet build "${{ env.WORKING_DIRECTORY }}" --configuration ${{ env.CONFIGURATION }} --no-restore
- name: Test
run: dotnet test "${{ env.WORKING_DIRECTORY }}" --no-build
- name: Publish
run: dotnet publish "${{ env.WORKING_DIRECTORY }}" --configuration ${{ env.CONFIGURATION }} --no-build --output "${{ env.AZURE_WEBAPP_PACKAGE_PATH }}"
- name: Deploy to Azure WebApp
uses: azure/webapps-deploy@v2
with:
app-name: ${{ env.AZURE_WEBAPP_NAME }}
package: ${{ env.AZURE_WEBAPP_PACKAGE_PATH }}
publish-profile: ${{ env.AZURE_WEBAPP_PUBLISH_PROFILE }}
- name: Publish Artifacts
uses: actions/[email protected]
with:
name: webapp
path: ${{ env.AZURE_WEBAPP_PACKAGE_PATH }}