Skip to content

Commit 663a14e

Browse files
X16X16
authored andcommitted
Initial release
0 parents  commit 663a14e

29 files changed

Lines changed: 2133 additions & 0 deletions

.dockerignore

Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,21 @@
1+
**/bin/
2+
**/obj/
3+
**/out/
4+
**/publish/
5+
**/logs/
6+
**/.vs/
7+
**/.vscode/
8+
**/.idea/
9+
**/.git/
10+
**/.github/
11+
**/*.user
12+
**/*.suo
13+
appsettings.Development.json
14+
appsettings.Local.json
15+
appsettings.*.Local.json
16+
secrets.json
17+
.env
18+
.env.*
19+
Dockerfile
20+
.dockerignore
21+
README.md
Lines changed: 191 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,191 @@
1+
name: Build Release Packages
2+
3+
on:
4+
push:
5+
tags:
6+
- "v*"
7+
workflow_dispatch:
8+
9+
permissions:
10+
contents: write
11+
packages: write
12+
13+
jobs:
14+
publish:
15+
name: Publish ${{ matrix.base_name }}
16+
runs-on: ubuntu-latest
17+
strategy:
18+
fail-fast: false
19+
matrix:
20+
include:
21+
- rid: win-x64
22+
base_name: RouterOSMCPSharp-win-x64
23+
artifact_name: RouterOSMCPSharp-win-x64
24+
self_contained: false
25+
- rid: linux-x64
26+
base_name: RouterOSMCPSharp-linux-x64
27+
artifact_name: RouterOSMCPSharp-linux-x64
28+
self_contained: false
29+
- rid: linux-arm64
30+
base_name: RouterOSMCPSharp-linux-arm64
31+
artifact_name: RouterOSMCPSharp-linux-arm64
32+
self_contained: false
33+
- rid: win-x64
34+
base_name: RouterOSMCPSharp-win-x64-standalone
35+
artifact_name: RouterOSMCPSharp-win-x64-standalone
36+
self_contained: true
37+
- rid: linux-x64
38+
base_name: RouterOSMCPSharp-linux-x64-standalone
39+
artifact_name: RouterOSMCPSharp-linux-x64-standalone
40+
self_contained: true
41+
- rid: linux-arm64
42+
base_name: RouterOSMCPSharp-linux-arm64-standalone
43+
artifact_name: RouterOSMCPSharp-linux-arm64-standalone
44+
self_contained: true
45+
46+
steps:
47+
- name: Check out code
48+
uses: actions/checkout@v4
49+
50+
- name: Compute package version
51+
shell: bash
52+
run: |
53+
if [[ "${GITHUB_REF_TYPE}" == "tag" ]]; then
54+
echo "PACKAGE_VERSION=${GITHUB_REF_NAME}" >> "$GITHUB_ENV"
55+
else
56+
echo "PACKAGE_VERSION=dev-${GITHUB_RUN_NUMBER}" >> "$GITHUB_ENV"
57+
fi
58+
59+
- name: Set up .NET
60+
uses: actions/setup-dotnet@v4
61+
with:
62+
dotnet-version: 8.0.x
63+
64+
- name: Restore
65+
run: dotnet restore RouterOSMCPSharp.sln
66+
67+
- name: Build
68+
run: dotnet build RouterOSMCPSharp.sln -c Release --no-restore
69+
70+
- name: Test
71+
run: dotnet test RouterOSMCPSharp.sln -c Release --no-build --verbosity normal
72+
73+
- name: Publish ${{ matrix.rid }}
74+
run: >
75+
dotnet publish RouterOSMCPSharp.csproj
76+
-c Release
77+
-r ${{ matrix.rid }}
78+
--self-contained ${{ matrix.self_contained }}
79+
-o publish/${{ matrix.rid }}-${{ matrix.self_contained }}
80+
81+
- name: Package ${{ matrix.rid }}
82+
shell: bash
83+
run: |
84+
cd publish/${{ matrix.rid }}-${{ matrix.self_contained }}
85+
zip -r "../../${{ matrix.base_name }}-${PACKAGE_VERSION}.zip" .
86+
87+
- name: Upload workflow artifact
88+
uses: actions/upload-artifact@v4
89+
with:
90+
name: ${{ matrix.artifact_name }}
91+
path: ${{ matrix.base_name }}-${{ env.PACKAGE_VERSION }}.zip
92+
if-no-files-found: error
93+
94+
docker:
95+
name: Build multi-arch Docker image
96+
runs-on: ubuntu-latest
97+
needs: publish
98+
99+
steps:
100+
- name: Check out code
101+
uses: actions/checkout@v4
102+
103+
- name: Compute package version
104+
shell: bash
105+
run: |
106+
if [[ "${GITHUB_REF_TYPE}" == "tag" ]]; then
107+
VERSION="${GITHUB_REF_NAME#v}"
108+
else
109+
VERSION="dev-${GITHUB_RUN_NUMBER}"
110+
fi
111+
echo "PACKAGE_VERSION=${VERSION}" >> "$GITHUB_ENV"
112+
echo "IMAGE_REPO=ghcr.io/${GITHUB_REPOSITORY,,}" >> "$GITHUB_ENV"
113+
114+
- name: Set up QEMU
115+
uses: docker/setup-qemu-action@v3
116+
117+
- name: Set up Docker Buildx
118+
uses: docker/setup-buildx-action@v3
119+
120+
- name: Log in to GitHub Container Registry
121+
uses: docker/login-action@v3
122+
with:
123+
registry: ghcr.io
124+
username: ${{ github.actor }}
125+
password: ${{ secrets.GITHUB_TOKEN }}
126+
127+
- name: Compute docker tags
128+
id: tags
129+
shell: bash
130+
run: |
131+
TAGS="${IMAGE_REPO}:${PACKAGE_VERSION}"
132+
if [[ "${GITHUB_REF_TYPE}" == "tag" ]]; then
133+
TAGS="${TAGS},${IMAGE_REPO}:latest"
134+
fi
135+
echo "tags=${TAGS}" >> "$GITHUB_OUTPUT"
136+
137+
- name: Build and push multi-arch image
138+
uses: docker/build-push-action@v6
139+
with:
140+
context: .
141+
file: Dockerfile
142+
platforms: linux/amd64,linux/arm64
143+
push: true
144+
tags: ${{ steps.tags.outputs.tags }}
145+
provenance: false
146+
cache-from: type=gha
147+
cache-to: type=gha,mode=max
148+
149+
release:
150+
name: Publish GitHub release
151+
if: startsWith(github.ref, 'refs/tags/')
152+
needs: [publish, docker]
153+
runs-on: ubuntu-latest
154+
155+
steps:
156+
- name: Check out code
157+
uses: actions/checkout@v4
158+
159+
- name: Compute package version
160+
shell: bash
161+
run: echo "PACKAGE_VERSION=${GITHUB_REF_NAME}" >> "$GITHUB_ENV"
162+
163+
- name: Download packaged artifacts
164+
uses: actions/download-artifact@v4
165+
with:
166+
path: release-assets
167+
168+
- name: Show release assets
169+
shell: bash
170+
run: find release-assets -maxdepth 2 -type f | sort
171+
172+
- name: Create release if missing
173+
env:
174+
GH_TOKEN: ${{ secrets.GITHUB_TOKEN }}
175+
run: |
176+
gh release view "${GITHUB_REF_NAME}" >/dev/null 2>&1 || \
177+
gh release create "${GITHUB_REF_NAME}" --generate-notes
178+
179+
- name: Upload release assets
180+
env:
181+
GH_TOKEN: ${{ secrets.GITHUB_TOKEN }}
182+
shell: bash
183+
run: |
184+
gh release upload "${GITHUB_REF_NAME}" \
185+
release-assets/RouterOSMCPSharp-win-x64/RouterOSMCPSharp-win-x64-${PACKAGE_VERSION}.zip \
186+
release-assets/RouterOSMCPSharp-linux-x64/RouterOSMCPSharp-linux-x64-${PACKAGE_VERSION}.zip \
187+
release-assets/RouterOSMCPSharp-linux-arm64/RouterOSMCPSharp-linux-arm64-${PACKAGE_VERSION}.zip \
188+
release-assets/RouterOSMCPSharp-win-x64-standalone/RouterOSMCPSharp-win-x64-standalone-${PACKAGE_VERSION}.zip \
189+
release-assets/RouterOSMCPSharp-linux-x64-standalone/RouterOSMCPSharp-linux-x64-standalone-${PACKAGE_VERSION}.zip \
190+
release-assets/RouterOSMCPSharp-linux-arm64-standalone/RouterOSMCPSharp-linux-arm64-standalone-${PACKAGE_VERSION}.zip \
191+
--clobber

.gitignore

Lines changed: 59 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,59 @@
1+
# Build output
2+
bin/
3+
obj/
4+
out/
5+
publish/
6+
*.binlog
7+
8+
# Logs (Serilog rolling files)
9+
logs/
10+
*.log
11+
12+
# Local secrets / overrides (real credentials must never be committed)
13+
appsettings.Development.json
14+
appsettings.Local.json
15+
appsettings.*.Local.json
16+
secrets.json
17+
.env
18+
.env.*
19+
20+
# Private keys / certificates that may sit alongside the project
21+
*.pem
22+
*.key
23+
*.pfx
24+
*.p12
25+
26+
# .NET / NuGet
27+
project.lock.json
28+
*.nuget.props
29+
*.nuget.targets
30+
*.nupkg
31+
*.snupkg
32+
.packages/
33+
34+
# Rider / ReSharper
35+
.idea/
36+
*.DotSettings.user
37+
_ReSharper*/
38+
39+
# Visual Studio
40+
.vs/
41+
*.user
42+
*.userosscache
43+
*.suo
44+
*.sln.docstates
45+
*.userprefs
46+
47+
# VS Code (keep launch.json/tasks.json/extensions.json/settings.json, ignore the rest)
48+
.vscode/*
49+
!.vscode/launch.json
50+
!.vscode/tasks.json
51+
!.vscode/extensions.json
52+
!.vscode/settings.json
53+
54+
# Docker leftovers
55+
.docker/
56+
57+
# OS junk
58+
.DS_Store
59+
Thumbs.db

.vscode/launch.json

Lines changed: 26 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,26 @@
1+
{
2+
"version": "0.2.0",
3+
"configurations": [
4+
{
5+
"name": ".NET Core Launch (RouterOSMCPSharp)",
6+
"type": "coreclr",
7+
"request": "launch",
8+
"preLaunchTask": "build",
9+
"program": "${workspaceFolder}/bin/Debug/net8.0/RouterOSMCPSharp.dll",
10+
"args": [],
11+
"cwd": "${workspaceFolder}",
12+
"stopAtEntry": false,
13+
"console": "integratedTerminal",
14+
"env": {
15+
"DOTNET_ENVIRONMENT": "Development",
16+
"ASPNETCORE_ENVIRONMENT": "Development",
17+
"Serilog__MinimumLevel__Override__Microsoft.Hosting.Lifetime": "Information"
18+
}
19+
},
20+
{
21+
"name": ".NET Core Attach",
22+
"type": "coreclr",
23+
"request": "attach"
24+
}
25+
]
26+
}

.vscode/tasks.json

Lines changed: 59 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,59 @@
1+
{
2+
"version": "2.0.0",
3+
"tasks": [
4+
{
5+
"label": "build",
6+
"command": "dotnet",
7+
"type": "process",
8+
"args": [
9+
"build",
10+
"${workspaceFolder}/RouterOSMCPSharp.csproj",
11+
"/property:GenerateFullPaths=true",
12+
"/consoleloggerparameters:NoSummary"
13+
],
14+
"problemMatcher": "$msCompile",
15+
"group": {
16+
"kind": "build",
17+
"isDefault": true
18+
}
19+
},
20+
{
21+
"label": "publish",
22+
"command": "dotnet",
23+
"type": "process",
24+
"args": [
25+
"publish",
26+
"${workspaceFolder}/RouterOSMCPSharp.csproj",
27+
"-c",
28+
"Release",
29+
"/property:GenerateFullPaths=true",
30+
"/consoleloggerparameters:NoSummary"
31+
],
32+
"problemMatcher": "$msCompile"
33+
},
34+
{
35+
"label": "watch",
36+
"command": "dotnet",
37+
"type": "process",
38+
"args": [
39+
"watch",
40+
"run",
41+
"--project",
42+
"${workspaceFolder}/RouterOSMCPSharp.csproj"
43+
],
44+
"problemMatcher": "$msCompile"
45+
},
46+
{
47+
"label": "docker-build",
48+
"command": "docker",
49+
"type": "process",
50+
"args": [
51+
"build",
52+
"-t",
53+
"routerosmcpsharp:dev",
54+
"${workspaceFolder}"
55+
],
56+
"problemMatcher": []
57+
}
58+
]
59+
}

0 commit comments

Comments
 (0)