Skip to content

Commit a85f99d

Browse files
committed
CI/CD
1 parent 5c2a497 commit a85f99d

File tree

3 files changed

+77
-30
lines changed

3 files changed

+77
-30
lines changed
Lines changed: 17 additions & 30 deletions
Original file line numberDiff line numberDiff line change
@@ -1,15 +1,7 @@
11
# yaml-language-server: $schema=https://json.schemastore.org/github-workflow.json
22

3-
name: publish
3+
name: CD
44
on:
5-
workflow_dispatch:
6-
push:
7-
branches:
8-
- 'main'
9-
- 'master'
10-
pull_request:
11-
branches:
12-
- '*'
135
release:
146
types:
157
- published
@@ -24,7 +16,7 @@ defaults:
2416
shell: pwsh
2517

2618
jobs:
27-
create_nuget:
19+
publish-nuget:
2820
runs-on: ubuntu-latest
2921
steps:
3022
- uses: actions/checkout@v4
@@ -45,32 +37,17 @@ jobs:
4537
- name: Test
4638
run: dotnet test --configuration Release --no-build --verbosity normal
4739

48-
- name: Pack NuGet Packages
40+
- name: Pack NuGet Package
4941
run: dotnet pack src/BlazorFrame/BlazorFrame.csproj --configuration Release --output ${{ env.NuGetDirectory }} --no-build
5042

5143
- uses: actions/upload-artifact@v4
5244
with:
53-
name: nuget
45+
name: nuget-package
5446
if-no-files-found: error
55-
retention-days: 7
47+
retention-days: 30
5648
path: ${{ env.NuGetDirectory }}/*.nupkg
5749

58-
deploy:
59-
if: github.event_name == 'release'
60-
runs-on: ubuntu-latest
61-
needs: [ create_nuget ]
62-
steps:
63-
- uses: actions/download-artifact@v4
64-
with:
65-
name: nuget
66-
path: ${{ env.NuGetDirectory }}
67-
68-
- name: Setup .NET
69-
uses: actions/setup-dotnet@v4
70-
with:
71-
dotnet-version: '8.0.x'
72-
73-
- name: Publish NuGet package
50+
- name: Publish to NuGet
7451
run: |
7552
foreach ($file in Get-ChildItem "${{ env.NuGetDirectory }}" -Recurse -Include *.nupkg) {
7653
if ($file.Name -like "BlazorFrame.*.nupkg") {
@@ -80,4 +57,14 @@ jobs:
8057
--source https://api.nuget.org/v3/index.json `
8158
--skip-duplicate
8259
}
83-
}
60+
}
61+
62+
- name: Create GitHub Release Asset
63+
run: |
64+
foreach ($file in Get-ChildItem "${{ env.NuGetDirectory }}" -Recurse -Include *.nupkg) {
65+
if ($file.Name -like "BlazorFrame.*.nupkg") {
66+
gh release upload ${{ github.event.release.tag_name }} $file
67+
}
68+
}
69+
env:
70+
GH_TOKEN: ${{ github.token }}

.github/workflows/ci.yml

Lines changed: 58 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,58 @@
1+
# yaml-language-server: $schema=https://json.schemastore.org/github-workflow.json
2+
3+
name: CI
4+
on:
5+
push:
6+
branches:
7+
- 'main'
8+
- 'master'
9+
pull_request:
10+
branches:
11+
- 'main'
12+
- 'master'
13+
14+
env:
15+
DOTNET_SKIP_FIRST_TIME_EXPERIENCE: 1
16+
DOTNET_NOLOGO: true
17+
18+
defaults:
19+
run:
20+
shell: pwsh
21+
22+
jobs:
23+
build-and-test:
24+
runs-on: ubuntu-latest
25+
steps:
26+
- uses: actions/checkout@v4
27+
with:
28+
fetch-depth: 0
29+
30+
- name: Setup .NET
31+
uses: actions/setup-dotnet@v4
32+
with:
33+
dotnet-version: '8.0.x'
34+
35+
- name: Restore dependencies
36+
run: dotnet restore
37+
38+
- name: Build Solution
39+
run: dotnet build --configuration Release --no-restore
40+
41+
- name: Test
42+
run: dotnet test --configuration Release --no-build --verbosity normal --collect:"XPlat Code Coverage"
43+
44+
- name: Upload test results
45+
uses: actions/upload-artifact@v4
46+
if: always()
47+
with:
48+
name: test-results
49+
path: |
50+
**/TestResults/**/*.xml
51+
**/TestResults/**/*.trx
52+
retention-days: 7
53+
54+
- name: Validate package can be created
55+
run: dotnet pack src/BlazorFrame/BlazorFrame.csproj --configuration Release --no-build --output ./temp-packages
56+
57+
- name: Cleanup temp packages
58+
run: Remove-Item -Path ./temp-packages -Recurse -Force

README.md

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,8 @@ A security-first Blazor iframe component with automatic resizing, cross-frame me
55
[![NuGet](https://img.shields.io/nuget/v/BlazorFrame.svg)](https://www.nuget.org/packages/BlazorFrame)
66
[![Downloads](https://img.shields.io/nuget/dt/BlazorFrame.svg)](https://www.nuget.org/packages/BlazorFrame)
77
[![GitHub](https://img.shields.io/github/license/Tim-Maes/BlazorFrame.svg)](https://github.com/Tim-Maes/BlazorFrame/blob/main/LICENSE.txt)
8+
[![CI](https://github.com/Tim-Maes/BlazorFrame/actions/workflows/ci.yml/badge.svg)](https://github.com/Tim-Maes/BlazorFrame/actions/workflows/ci.yml)
9+
[![CD](https://github.com/Tim-Maes/BlazorFrame/actions/workflows/cd.yml/badge.svg)](https://github.com/Tim-Maes/BlazorFrame/actions/workflows/cd.yml)
810

911
## Features
1012

0 commit comments

Comments
 (0)