Skip to content

Commit e019bf3

Browse files
committed
ci: add CI workflow and make publish manual-only
- Add ci.yml: automated build + test on push/PR to main/master - Update publish-packages.yml: manual-only via workflow_dispatch, remove automatic triggers - Update deploy-pages.yml: fix paths for src/ layout, add test step
1 parent 12271e3 commit e019bf3

File tree

3 files changed

+50
-20
lines changed

3 files changed

+50
-20
lines changed

.github/workflows/ci.yml

Lines changed: 40 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,40 @@
1+
name: CI
2+
3+
on:
4+
push:
5+
branches: [ master, main ]
6+
pull_request:
7+
branches: [ master, main ]
8+
9+
env:
10+
DOTNET_VERSION: '9.0.x'
11+
12+
jobs:
13+
build-and-test:
14+
runs-on: ubuntu-latest
15+
16+
steps:
17+
- name: Checkout repository
18+
uses: actions/checkout@v4
19+
20+
- name: Setup .NET
21+
uses: actions/setup-dotnet@v4
22+
with:
23+
dotnet-version: ${{ env.DOTNET_VERSION }}
24+
25+
- name: Cache NuGet packages
26+
uses: actions/cache@v4
27+
with:
28+
path: ~/.nuget/packages
29+
key: ${{ runner.os }}-nuget-${{ hashFiles('**/*.csproj') }}
30+
restore-keys: |
31+
${{ runner.os }}-nuget-
32+
33+
- name: Restore dependencies
34+
run: dotnet restore
35+
36+
- name: Build
37+
run: dotnet build --no-restore --configuration Release
38+
39+
- name: Test
40+
run: dotnet test --no-build --configuration Release --verbosity normal

.github/workflows/deploy-pages.yml

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -4,8 +4,8 @@ on:
44
push:
55
branches: [ main, master ]
66
paths:
7-
- 'BlazorTextDiff.Web/**'
8-
- 'BlazorTextDiff/**'
7+
- 'src/BlazorTextDiff.Web/**'
8+
- 'src/BlazorTextDiff/**'
99
workflow_dispatch:
1010

1111
# Sets permissions of the GITHUB_TOKEN to allow deployment to GitHub Pages
@@ -57,8 +57,11 @@ jobs:
5757
dotnet workload restore
5858
dotnet restore
5959
60+
- name: Run tests
61+
run: dotnet test --no-restore --configuration Release --verbosity normal
62+
6063
- name: Build Blazor WebAssembly
61-
run: dotnet publish BlazorTextDiff.Web/BlazorTextDiff.Web.csproj -c Release -o dist/ -p:Version=${{ steps.version.outputs.version }} -p:PublishUrl=/BlazorTextDiff/
64+
run: dotnet publish src/BlazorTextDiff.Web/BlazorTextDiff.Web.csproj -c Release -o dist/ -p:Version=${{ steps.version.outputs.version }} -p:PublishUrl=/BlazorTextDiff/
6265

6366
- name: Add .nojekyll file
6467
run: touch dist/wwwroot/.nojekyll

.github/workflows/publish-packages.yml

Lines changed: 4 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -1,19 +1,11 @@
1-
name: Build and Publish Packages
1+
name: Publish Packages
22

33
on:
4-
push:
5-
branches: [ master, main ]
6-
paths:
7-
- 'BlazorTextDiff/**'
8-
pull_request:
9-
branches: [ master, main ]
10-
paths:
11-
- 'BlazorTextDiff/**'
124
workflow_dispatch:
135

146
env:
157
DOTNET_VERSION: '9.0.x'
16-
PROJECT_PATH: 'BlazorTextDiff/BlazorTextDiff.csproj'
8+
PROJECT_PATH: 'src/BlazorTextDiff/BlazorTextDiff.csproj'
179
ARTIFACT_NAME: 'BlazorTextDiff-Package'
1810

1911
jobs:
@@ -80,13 +72,8 @@ jobs:
8072
- name: Check if should publish
8173
id: check-publish
8274
run: |
83-
if [[ ("${{ github.event_name }}" == "push" && ("${{ github.ref }}" == "refs/heads/master" || "${{ github.ref }}" == "refs/heads/main")) || "${{ github.event_name }}" == "workflow_dispatch" ]]; then
84-
echo "should-publish=true" >> $GITHUB_OUTPUT
85-
echo "Will publish packages (triggered by: ${{ github.event_name }})"
86-
else
87-
echo "should-publish=false" >> $GITHUB_OUTPUT
88-
echo "Will not publish packages (event: ${{ github.event_name }}, ref: ${{ github.ref }})"
89-
fi
75+
echo "should-publish=true" >> $GITHUB_OUTPUT
76+
echo "Will publish packages (manual trigger)"
9077
9178
- name: Upload build artifacts
9279
uses: actions/upload-artifact@v4

0 commit comments

Comments
 (0)