-
Notifications
You must be signed in to change notification settings - Fork 5
102 lines (84 loc) · 3.19 KB
/
main.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
name: Main
on:
push:
branches: [ main ]
release:
types: [ published ]
workflow_dispatch:
env:
PROJECT_NAME: PinguApps.Blazor.QRCode
DOTNET_VERSION: '8.0'
BASE_HREF: 'Blazor.QRCode'
BRANCH: 'main'
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
NUGET_FEED: https://api.nuget.org/v3/index.json
NUGET_KEY: ${{ secrets.NUGET_KEY }}
jobs:
build:
name: Build & Test
runs-on: ubuntu-latest
steps:
- name: Checkout
uses: actions/checkout@eef61447b9ff4aafe5dcd4e0bbf5d482be7e7871 # v4
- name: Setup .NET
uses: actions/setup-dotnet@6bd8b7f7774af54e05809fcc5431931b3eb1ddee # v4
with:
dotnet-version: ${{ env.DOTNET_VERSION }}
- name: Restore
run: dotnet restore
- name: Build
run: dotnet build -c Release --no-restore src/$PROJECT_NAME/$PROJECT_NAME.csproj
- name: Test
run: dotnet test -c Release --no-restore --verbosity normal tests/$PROJECT_NAME.Tests/
deploy:
needs: build
if: ${{ github.event_name == 'push' || github.event_name == 'workflow_dispatch' }}
name: Deploy
runs-on: ubuntu-latest
permissions:
contents: write
steps:
- name: Checkout
uses: actions/checkout@eef61447b9ff4aafe5dcd4e0bbf5d482be7e7871 # v4
- name: Setup .NET
uses: actions/setup-dotnet@6bd8b7f7774af54e05809fcc5431931b3eb1ddee # v4
with:
dotnet-version: ${{ env.DOTNET_VERSION }}
- name: Publish
run: dotnet publish -c Release src/BlazorWasmNet6/BlazorWasmNet6.csproj
- name: Rewrite base href
uses: SteveSandersonMS/ghaction-rewrite-base-href@5b54862a8831e012d4f1a8b2660894415fdde8ec # v1
with:
html_path: src/BlazorWasmNet6/bin/Release/net6.0/publish/wwwroot/index.html
base_href: /${{ env.BASE_HREF }}/
- name: copy index.html to 404.html
run: cp src/BlazorWasmNet6/bin/Release/net6.0/publish/wwwroot/index.html src/BlazorWasmNet6/bin/Release/net6.0/publish/wwwroot/404.html
- name: Add .nojekyll file
run: touch src/BlazorWasmNet6/bin/Release/net6.0/publish/wwwroot/.nojekyll
- name: Commit wwwroot to GitHub Pages
uses: JamesIves/github-pages-deploy-action@881db5376404c5c8d621010bcbec0310b58d5e29 # v4
with:
branch: gh-pages
folder: src/BlazorWasmNet6/bin/Release/net6.0/publish/wwwroot
push-nuget:
needs: build
if: github.event_name == 'release'
name: Push Nuget
runs-on: ubuntu-latest
steps:
- name: Checkout
uses: actions/checkout@eef61447b9ff4aafe5dcd4e0bbf5d482be7e7871 # v4
- name: Setup .NET
uses: actions/setup-dotnet@6bd8b7f7774af54e05809fcc5431931b3eb1ddee # v4
with:
dotnet-version: ${{ env.DOTNET_VERSION }}
- name: Create Nuget Package
run: |
arrTag=(${GITHUB_REF//\// })
VERSION="${arrTag[2]}"
echo Version: $VERSION
VERSION="${VERSION:1}"
echo Clean Version: $VERSION
dotnet pack -c Release --verbosity normal --include-symbols --include-source -p:PackageVersion=$VERSION -o nupkg src/$PROJECT_NAME/$PROJECT_NAME.csproj
- name: Push to NuGet Feed
run: dotnet nuget push ./nupkg/*.nupkg --source $NUGET_FEED --api-key $NUGET_KEY --skip-duplicate