Skip to content

Commit bc51d71

Browse files
committed
feat: add GitHub Actions workflows for release and .NET build, enhance PWA support with service worker and manifest
1 parent b3a6fab commit bc51d71

File tree

13 files changed

+513
-178
lines changed

13 files changed

+513
-178
lines changed

.github/workflows/dotnet.yml

Lines changed: 68 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,68 @@
1+
name: .NET
2+
3+
on:
4+
push:
5+
branches: [ main, develop ]
6+
pull_request:
7+
branches: [ main ]
8+
9+
jobs:
10+
build:
11+
runs-on: ${{ matrix.os }}
12+
strategy:
13+
matrix:
14+
os: [ubuntu-latest, windows-latest, macos-latest]
15+
dotnet-version: ['9.0.x']
16+
17+
steps:
18+
- uses: actions/checkout@v4
19+
20+
- name: Setup .NET
21+
uses: actions/setup-dotnet@v4
22+
with:
23+
dotnet-version: ${{ matrix.dotnet-version }}
24+
25+
- name: Restore dependencies
26+
run: dotnet restore
27+
28+
- name: Build
29+
run: dotnet build --no-restore --configuration Release
30+
31+
- name: Test
32+
run: dotnet test --no-build --verbosity normal --configuration Release --logger "trx;LogFileName=test-results.trx"
33+
34+
- name: Upload test results
35+
uses: actions/upload-artifact@v4
36+
if: always()
37+
with:
38+
name: test-results-${{ matrix.os }}
39+
path: "**/test-results.trx"
40+
41+
publish-demo:
42+
runs-on: ubuntu-latest
43+
needs: build
44+
if: github.event_name == 'push' && github.ref == 'refs/heads/main'
45+
46+
steps:
47+
- uses: actions/checkout@v4
48+
49+
- name: Setup .NET
50+
uses: actions/setup-dotnet@v4
51+
with:
52+
dotnet-version: '9.0.x'
53+
54+
- name: Restore dependencies
55+
run: dotnet restore Demo.BlazorWasm/Demo.BlazorWasm.csproj
56+
57+
- name: Build Blazor Demo
58+
run: dotnet build Demo.BlazorWasm/Demo.BlazorWasm.csproj --configuration Release
59+
60+
- name: Publish Blazor Demo
61+
run: dotnet publish Demo.BlazorWasm/Demo.BlazorWasm.csproj --configuration Release --output dist
62+
63+
- name: Deploy to GitHub Pages
64+
uses: peaceiris/actions-gh-pages@v3
65+
with:
66+
github_token: ${{ secrets.GITHUB_TOKEN }}
67+
publish_dir: ./dist/wwwroot
68+
force_orphan: true

.github/workflows/main.yml

Lines changed: 0 additions & 137 deletions
This file was deleted.

.github/workflows/release.yml

Lines changed: 153 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,153 @@
1+
name: Release
2+
3+
on:
4+
push:
5+
branches: [ main ]
6+
workflow_dispatch:
7+
8+
permissions:
9+
contents: write
10+
packages: write
11+
pull-requests: write
12+
13+
jobs:
14+
release:
15+
runs-on: ubuntu-latest
16+
if: github.event_name == 'push' && github.ref == 'refs/heads/main'
17+
18+
steps:
19+
- name: Checkout
20+
uses: actions/checkout@v4
21+
with:
22+
fetch-depth: 0
23+
token: ${{ secrets.GITHUB_TOKEN }}
24+
25+
- name: Check for existing tags
26+
id: check_tags
27+
run: |
28+
if git describe --tags --abbrev=0 2>/dev/null; then
29+
echo "has_tags=true" >> $GITHUB_OUTPUT
30+
echo "Found existing tags"
31+
else
32+
echo "has_tags=false" >> $GITHUB_OUTPUT
33+
echo "No tags found - will create initial release"
34+
fi
35+
36+
- name: Get next version
37+
id: get_version
38+
uses: mathieudutour/github-tag-action@v6.2
39+
with:
40+
github_token: ${{ secrets.GITHUB_TOKEN }}
41+
release_branches: main
42+
pre_release_branches: develop
43+
dry_run: true
44+
default_bump: ${{ steps.check_tags.outputs.has_tags == 'false' && 'major' || 'false' }}
45+
custom_release_rules: |
46+
breaking:major,
47+
feat:minor,
48+
fix:patch,
49+
perf:patch,
50+
revert:patch,
51+
docs:patch:README,
52+
refactor:patch,
53+
test:false,
54+
style:false,
55+
chore:false,
56+
ci:false
57+
58+
- name: Check if should release
59+
id: should_release
60+
run: |
61+
if [[ "${{ steps.get_version.outputs.new_version }}" != "" ]]; then
62+
echo "new_release=true" >> $GITHUB_OUTPUT
63+
echo "New version will be: ${{ steps.get_version.outputs.new_version }}"
64+
else
65+
echo "new_release=false" >> $GITHUB_OUTPUT
66+
echo "No new version to release"
67+
fi
68+
69+
- name: Setup .NET
70+
if: steps.should_release.outputs.new_release == 'true'
71+
uses: actions/setup-dotnet@v4
72+
with:
73+
dotnet-version: '9.0.x'
74+
75+
- name: Update version in csproj files
76+
if: steps.should_release.outputs.new_release == 'true'
77+
run: |
78+
VERSION=${{ steps.get_version.outputs.new_version }}
79+
find . -name "*.csproj" -type f | while read -r file; do
80+
if grep -q "<Version>" "$file"; then
81+
sed -i "s|<Version>.*</Version>|<Version>${VERSION}</Version>|g" "$file"
82+
fi
83+
done
84+
85+
- name: Restore dependencies
86+
if: steps.should_release.outputs.new_release == 'true'
87+
run: dotnet restore
88+
89+
- name: Build
90+
if: steps.should_release.outputs.new_release == 'true'
91+
run: dotnet build --configuration Release --no-restore
92+
93+
- name: Test
94+
if: steps.should_release.outputs.new_release == 'true'
95+
run: dotnet test --configuration Release --no-build --verbosity normal
96+
97+
- name: Pack
98+
if: steps.should_release.outputs.new_release == 'true'
99+
run: |
100+
dotnet pack src/TechnicalAnalysis.Common/TechnicalAnalysis.Common.csproj --configuration Release --no-build --output ./artifacts
101+
dotnet pack src/TechnicalAnalysis.Functions/TechnicalAnalysis.Functions.csproj --configuration Release --no-build --output ./artifacts
102+
dotnet pack src/TechnicalAnalysis.Candles/TechnicalAnalysis.Candles.csproj --configuration Release --no-build --output ./artifacts
103+
104+
- name: Install NuGet validator
105+
if: steps.should_release.outputs.new_release == 'true'
106+
run: dotnet tool update Meziantou.Framework.NuGetPackageValidation.Tool --global
107+
108+
- name: Validate NuGet packages
109+
if: steps.should_release.outputs.new_release == 'true'
110+
run: |
111+
for file in ./artifacts/*.nupkg; do
112+
echo "Validating $file"
113+
meziantou.validate-nuget-package "$file"
114+
done
115+
116+
- name: Generate changelog
117+
if: steps.should_release.outputs.new_release == 'true'
118+
id: changelog
119+
uses: TriPSs/conventional-changelog-action@v6
120+
with:
121+
github-token: ${{ secrets.GITHUB_TOKEN }}
122+
skip-commit: true
123+
output-file: false
124+
125+
- name: Create tag
126+
if: steps.should_release.outputs.new_release == 'true'
127+
uses: mathieudutour/github-tag-action@v6.2
128+
with:
129+
github_token: ${{ secrets.GITHUB_TOKEN }}
130+
custom_tag: ${{ steps.get_version.outputs.new_version }}
131+
132+
- name: Push to NuGet
133+
if: steps.should_release.outputs.new_release == 'true'
134+
run: |
135+
dotnet nuget push ./artifacts/*.nupkg \
136+
--api-key ${{ secrets.NUGET_API_KEY }} \
137+
--source https://api.nuget.org/v3/index.json \
138+
--skip-duplicate
139+
140+
- name: Create GitHub Release
141+
if: steps.should_release.outputs.new_release == 'true'
142+
uses: softprops/action-gh-release@v2
143+
with:
144+
tag_name: v${{ steps.get_version.outputs.new_version }}
145+
name: Release v${{ steps.get_version.outputs.new_version }}
146+
body: ${{ steps.changelog.outputs.clean_changelog }}
147+
files: |
148+
./artifacts/*.nupkg
149+
./artifacts/*.snupkg
150+
draft: false
151+
prerelease: false
152+
env:
153+
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}

0 commit comments

Comments
 (0)