Skip to content

Commit 26a6d20

Browse files
committed
upgrade to .NET 10
1 parent 4fe295c commit 26a6d20

File tree

14 files changed

+158
-118
lines changed

14 files changed

+158
-118
lines changed

.github/workflows/build.yml

Lines changed: 18 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -16,10 +16,26 @@ jobs:
1616
- name: Setup dotnet
1717
uses: actions/setup-dotnet@v5
1818
with:
19-
dotnet-version: 8.0.x
19+
dotnet-version: 10.0.x
20+
21+
- name: Restore NuGet packages (use repo NuGet.config)
22+
run: dotnet restore MyApp.slnx --configfile ./NuGet.Config
23+
24+
# If your feed requires authentication, enable and configure the step below.
25+
# This example uses a Personal Access Token stored in secrets.NUGET_API_KEY.
26+
# Alternatively, you can use the NuGet Authenticate action from Azure Pipelines.
27+
# - name: Authenticate private NuGet feed
28+
# env:
29+
# NUGET_API_KEY: ${{ secrets.NUGET_API_KEY }}
30+
# run: |
31+
# dotnet nuget add source "https://YOUR_FEED_URL/index.json" \
32+
# --name "PrivateFeed" \
33+
# --username "YOUR_USERNAME" \
34+
# --password "$NUGET_API_KEY" \
35+
# --store-password-in-clear-text
2036

2137
- name: build
22-
run: dotnet build
38+
run: dotnet build --no-restore
2339
working-directory: .
2440

2541
- name: test

.github/workflows/release.yml

Lines changed: 38 additions & 30 deletions
Original file line numberDiff line numberDiff line change
@@ -14,9 +14,11 @@ on:
1414

1515
env:
1616
DOCKER_BUILDKIT: 1
17-
KAMAL_REGISTRY_PASSWORD: ${{ secrets.GITHUB_TOKEN }}
18-
KAMAL_REGISTRY_USERNAME: ${{ github.actor }}
1917
SERVICESTACK_LICENSE: ${{ secrets.SERVICESTACK_LICENSE }}
18+
KAMAL_DEPLOY_IP: ${{ secrets.KAMAL_DEPLOY_IP }}
19+
KAMAL_DEPLOY_HOST: ${{ secrets.KAMAL_DEPLOY_HOST }}
20+
KAMAL_REGISTRY_USERNAME: ${{ github.actor }}
21+
KAMAL_REGISTRY_PASSWORD: ${{ secrets.GITHUB_TOKEN }}
2022

2123
jobs:
2224
release:
@@ -38,24 +40,12 @@ jobs:
3840
echo "HAS_MIGRATIONS=false" >> $GITHUB_ENV
3941
fi
4042
41-
# This step is for the deployment of the templates only, safe to delete
42-
- name: Modify deploy.yml
43-
env:
44-
KAMAL_DEPLOY_IP: ${{ secrets.KAMAL_DEPLOY_IP }}
45-
if: env.KAMAL_DEPLOY_IP != null
46-
run: |
47-
sed -i "s/service: my-app/service: ${{ env.repository_name_lower }}/g" config/deploy.yml
48-
sed -i "s#image: my-user/myapp#image: ${{ env.image_repository_name }}#g" config/deploy.yml
49-
sed -i "s/- 192.168.0.1/- ${{ secrets.KAMAL_DEPLOY_IP }}/g" config/deploy.yml
50-
sed -i "s/host: my-app.example.com/host: ${{ secrets.KAMAL_DEPLOY_HOST }}/g" config/deploy.yml
51-
sed -i "s/MyApp/${{ env.repository_name }}/g" config/deploy.yml
52-
5343
- name: Login to GitHub Container Registry
5444
uses: docker/login-action@v3
5545
with:
5646
registry: ghcr.io
57-
username: ${{ env.KAMAL_REGISTRY_USERNAME }}
58-
password: ${{ env.KAMAL_REGISTRY_PASSWORD }}
47+
username: ${{ github.actor }}
48+
password: ${{ secrets.GITHUB_TOKEN }}
5949

6050
- name: Set up SSH key
6151
uses: webfactory/[email protected]
@@ -80,29 +70,47 @@ jobs:
8070
run: |
8171
kamal server bootstrap
8272
73+
- name: Ensure directories exist with correct permissions
74+
run: |
75+
echo "Creating directories with correct permissions"
76+
kamal server exec "mkdir -p /opt/docker/${{ env.repository_name }}/App_Data /opt/docker/${{ env.repository_name }}/initdb.d"
77+
78+
echo "Setting app file permissions"
79+
kamal server exec "chown -R 1654:1654 /opt/docker/${{ env.repository_name }}/App_Data /opt/docker/${{ env.repository_name }}/initdb.d"
80+
8381
- name: Check if first run and execute kamal app boot if necessary
8482
run: |
85-
FIRST_RUN_FILE=".${{ env.repository_name }}"
86-
if ! kamal server exec --no-interactive -q "test -f $FIRST_RUN_FILE"; then
87-
kamal server exec --no-interactive -q "touch $FIRST_RUN_FILE" || true
83+
FIRST_RUN_FILE="~/first-run/${{ env.repository_name }}"
84+
if ! kamal server exec -q "test -f $FIRST_RUN_FILE"; then
85+
kamal server exec -q "mkdir -p ~/first-run && touch $FIRST_RUN_FILE" || true
86+
87+
if [ -n "${{env.INIT_DB_SQL}}" ]; then
88+
echo "Initializing DB with INIT_DB_SQL secret..."
89+
# Save the SQL content to a temporary file
90+
echo "${{ env.INIT_DB_SQL }}" > init-db.sql
91+
cat init-db.sql | kamal server exec -i "cat > /opt/docker/${{ env.repository_name }}/initdb.d/${{ env.repository_name }}.sql" && rm init-db.sql || true
92+
fi
93+
# Start all kamal accessories
94+
kamal accessory boot all || true
95+
96+
# Deploy latest version
8897
kamal deploy -q -P --version latest || true
8998
else
9099
echo "Not first run, skipping kamal app boot"
91-
fi
100+
fi
92101
93-
- name: Ensure file permissions
102+
- name: Verify file permissions before deploy
103+
run: |
104+
kamal server exec --no-interactive "chown -R 1654:1654 /opt/docker/${{ env.repository_name }}/App_Data /opt/docker/${{ env.repository_name }}/initdb.d"
105+
106+
- name: Deploy with Kamal
94107
run: |
95-
kamal server exec --no-interactive "mkdir -p /opt/docker/${{ env.repository_name }}/App_Data && chown -R 1654:1654 /opt/docker/${{ env.repository_name }}"
108+
kamal lock release -v
109+
kamal server exec --no-interactive 'echo "${{ secrets.GITHUB_TOKEN }}" | docker login ghcr.io -u ${{ github.actor }} --password-stdin'
110+
kamal server exec --no-interactive 'docker pull ghcr.io/${{ env.image_repository_name }}:latest'
111+
kamal deploy -P --version latest
96112
97113
- name: Migration
98114
if: env.HAS_MIGRATIONS == 'true'
99115
run: |
100-
kamal server exec --no-interactive 'echo "${{ env.KAMAL_REGISTRY_PASSWORD }}" | docker login ghcr.io -u ${{ env.KAMAL_REGISTRY_USERNAME }} --password-stdin'
101-
kamal server exec --no-interactive "docker pull ghcr.io/${{ env.image_repository_name }}:latest || true"
102116
kamal app exec --no-reuse --no-interactive --version=latest "--AppTasks=migrate"
103-
104-
- name: Deploy with Kamal
105-
run: |
106-
kamal lock release -v
107-
kamal server exec --no-interactive 'echo "${{ env.KAMAL_REGISTRY_PASSWORD }}" | docker login ghcr.io -u ${{ env.KAMAL_REGISTRY_USERNAME }} --password-stdin'
108-
kamal deploy -P --version latest

MyApp.ServiceInterface/MyApp.ServiceInterface.csproj

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
<Project Sdk="Microsoft.NET.Sdk">
22

33
<PropertyGroup>
4-
<TargetFramework>net8.0</TargetFramework>
4+
<TargetFramework>net10.0</TargetFramework>
55
<ImplicitUsings>enable</ImplicitUsings>
66
<Nullable>enable</Nullable>
77
</PropertyGroup>

MyApp.ServiceModel/MyApp.ServiceModel.csproj

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
<Project Sdk="Microsoft.NET.Sdk">
22

33
<PropertyGroup>
4-
<TargetFramework>net8.0</TargetFramework>
4+
<TargetFramework>net10.0</TargetFramework>
55
<ImplicitUsings>enable</ImplicitUsings>
66
<Nullable>enable</Nullable>
77
</PropertyGroup>

MyApp.Tests/MyApp.Tests.csproj

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
<Project Sdk="Microsoft.NET.Sdk">
22

33
<PropertyGroup>
4-
<TargetFramework>net8.0</TargetFramework>
4+
<TargetFramework>net10.0</TargetFramework>
55
<Nullable>enable</Nullable>
66
<ImplicitUsings>enable</ImplicitUsings>
77
<DebugType>portable</DebugType>

MyApp.sln

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

MyApp.slnx

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
<Solution>
2+
<Project Path="MyApp.ServiceInterface/MyApp.ServiceInterface.csproj" />
3+
<Project Path="MyApp.ServiceModel/MyApp.ServiceModel.csproj" />
4+
<Project Path="MyApp.Tests/MyApp.Tests.csproj" />
5+
<Project Path="MyApp/MyApp.csproj" />
6+
</Solution>

MyApp/Configure.AI.Chat.cs

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -27,12 +27,13 @@ public void Configure(IWebHostBuilder builder) => builder
2727
// "openrouter",
2828
]
2929
});
30-
30+
3131
// Persist AI Chat History, enables analytics at /admin-ui/chat
32-
services.AddSingleton<IChatStore,DbChatStore>();
32+
services.AddSingleton<IChatStore, DbChatStore>();
3333
// Or store history in monthly partitioned tables in PostgreSQL:
3434
// services.AddSingleton<IChatStore, PostgresChatStore>();
35-
35+
36+
// Add AI Chat link to /metadata
3637
services.ConfigurePlugin<MetadataFeature>(feature => {
3738
feature.AddPluginLink("/chat", "AI Chat");
3839
});

MyApp/Configure.ApiKeys.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -45,7 +45,7 @@ public void Configure(IWebHostBuilder builder) => builder
4545
// Optional: Create API Key for specified Users on Startup
4646
if (feature.ApiKeyCount(db) == 0 && db.TableExists(IdentityUsers.TableName))
4747
{
48-
var createApiKeysFor = new [] { "[email protected]", "[email protected]" };
48+
var createApiKeysFor = new [] { "[email protected]", "[email protected]", "[email protected]" };
4949
var users = IdentityUsers.GetByUserNames(db, createApiKeysFor);
5050
foreach (var user in users)
5151
{

MyApp/Configure.OpenApi.cs

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
using MyApp.Data;
1+
using ServiceStack;
22

33
[assembly: HostingStartup(typeof(MyApp.ConfigureOpenApi))]
44

@@ -12,11 +12,11 @@ public void Configure(IWebHostBuilder builder) => builder
1212
{
1313
services.AddEndpointsApiExplorer();
1414
services.AddSwaggerGen();
15-
1615
services.AddServiceStackSwagger();
17-
services.AddBasicAuth<ApplicationUser>();
18-
//services.AddJwtAuth();
19-
16+
services.AddBasicAuth<Data.ApplicationUser>();
17+
services.AddApiKeys();
18+
// services.AddJwtAuth();
19+
2020
services.AddTransient<IStartupFilter,StartupFilter>();
2121
}
2222
});

0 commit comments

Comments
 (0)