Skip to content

Commit 7a4b23a

Browse files
committed
ci: add GitHub Actions workflow for build, test, and release
1 parent 011adb3 commit 7a4b23a

1 file changed

Lines changed: 71 additions & 0 deletions

File tree

.github/workflows/ci.yml

Lines changed: 71 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,71 @@
1+
name: CI
2+
3+
on:
4+
push:
5+
branches:
6+
- '**'
7+
tags:
8+
- 'v*'
9+
pull_request:
10+
branches:
11+
- main
12+
workflow_dispatch:
13+
14+
jobs:
15+
build-and-test:
16+
runs-on: windows-latest
17+
18+
steps:
19+
- name: Checkout code
20+
uses: actions/checkout@v4
21+
22+
- name: Setup .NET 10 SDK
23+
uses: actions/setup-dotnet@v4
24+
with:
25+
dotnet-version: '10.0.x'
26+
27+
- name: Restore dependencies
28+
run: dotnet restore RunDialog.slnx
29+
30+
- name: Build solution
31+
run: dotnet build RunDialog.slnx --configuration Release --no-restore
32+
33+
- name: Run tests
34+
run: dotnet test RunDialog.Tests/RunDialog.Tests.csproj --configuration Release --no-build
35+
36+
release:
37+
needs: build-and-test
38+
if: (github.event_name == 'push' && startsWith(github.ref, 'refs/tags/v')) || github.event_name == 'workflow_dispatch'
39+
runs-on: windows-latest
40+
41+
steps:
42+
- name: Checkout code
43+
uses: actions/checkout@v4
44+
45+
- name: Setup .NET 10 SDK
46+
uses: actions/setup-dotnet@v4
47+
with:
48+
dotnet-version: '10.0.x'
49+
50+
- name: Publish app for win-x64
51+
run: |
52+
dotnet publish RunDialog.App/RunDialog.App.csproj `
53+
-c Release `
54+
-r win-x64 `
55+
--self-contained true `
56+
-p:PublishReadyToRun=true `
57+
-p:PublishTrimmed=true `
58+
-o ./publish/win-x64
59+
60+
- name: Create ZIP archive
61+
run: |
62+
Compress-Archive -Path "./publish/win-x64/*" `
63+
-DestinationPath "./RunDialog-${{ github.ref_name || github.run_id }}-win-x64.zip"
64+
65+
- name: Create GitHub Release
66+
uses: softprops/action-gh-release@v2
67+
with:
68+
tag_name: ${{ github.ref_type == 'tag' && github.ref_name || format('manual-build-{0}', github.run_number) }}
69+
name: ${{ github.ref_type == 'tag' && github.ref_name || format('RunDialog-manual-build-{0}', github.run_number) }}
70+
files: ./RunDialog-${{ github.ref_name || github.run_id }}-win-x64.zip
71+
generate_release_notes: ${{ github.ref_type == 'tag' }}

0 commit comments

Comments
 (0)