Skip to content

Commit 8b008cd

Browse files
Initial commit
0 parents  commit 8b008cd

27 files changed

+1272
-0
lines changed

.github/workflows/codeql.yml

Lines changed: 143 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,143 @@
1+
# For most projects, this workflow file will not need changing; you simply need
2+
# to commit it to your repository.
3+
#
4+
# You may wish to alter this file to override the set of languages analyzed,
5+
# or to provide custom queries or build logic.
6+
#
7+
# ******** NOTE ********
8+
# We have attempted to detect the languages in your repository. Please check
9+
# the `language` matrix defined below to confirm you have the correct set of
10+
# supported CodeQL languages.
11+
#
12+
name: "CodeQL"
13+
14+
on:
15+
push:
16+
branches: [ "main" ]
17+
pull_request:
18+
branches: [ "main" ]
19+
schedule:
20+
- cron: '41 6 * * 6'
21+
22+
jobs:
23+
build:
24+
name: Roslyn Compiler Warnings
25+
runs-on: [ self-hosted ]
26+
env:
27+
# Required for actions/setup-dotnet@v3 on self-hosted runners where runners don't have sudo permissions
28+
DOTNET_INSTALL_DIR: "./.dotnet"
29+
steps:
30+
- name: Checkout repository
31+
uses: actions/checkout@v4
32+
with:
33+
submodules: 'recursive'
34+
35+
# Install the .NET Core workload
36+
- name: Install .NET Core
37+
uses: actions/setup-dotnet@v3
38+
with:
39+
dotnet-version: 8.x.x
40+
41+
# Execute the build
42+
- name: Execute Release Build
43+
working-directory: ./src
44+
run: dotnet build --configuration Release
45+
test:
46+
name: Tests
47+
runs-on: [ self-hosted ]
48+
env:
49+
# Required for actions/setup-dotnet@v3 on self-hosted runners where runners don't have sudo permissions
50+
DOTNET_INSTALL_DIR: "./.dotnet"
51+
steps:
52+
- name: Checkout repository
53+
uses: actions/checkout@v4
54+
with:
55+
submodules: 'recursive'
56+
57+
# Install the .NET Core workload
58+
- name: Install .NET Core
59+
uses: actions/setup-dotnet@v3
60+
with:
61+
dotnet-version: 8.x.x
62+
63+
# Execute the tests
64+
- name: Execute Tests
65+
working-directory: ./src
66+
run: dotnet test
67+
68+
code-ql:
69+
name: Analyze
70+
# Runner size impacts CodeQL analysis time. To learn more, please see:
71+
# - https://gh.io/recommended-hardware-resources-for-running-codeql
72+
# - https://gh.io/supported-runners-and-hardware-resources
73+
# - https://gh.io/using-larger-runners
74+
# Consider using larger runners for possible analysis time improvements.
75+
runs-on: [ self-hosted ]
76+
timeout-minutes: ${{ (matrix.language == 'swift' && 120) || 360 }}
77+
permissions:
78+
# required for all workflows
79+
security-events: write
80+
81+
# only required for workflows in private repositories
82+
actions: read
83+
contents: read
84+
85+
strategy:
86+
fail-fast: false
87+
matrix:
88+
language: [ 'csharp' ]
89+
# CodeQL supports [ 'c-cpp', 'csharp', 'go', 'java-kotlin', 'javascript-typescript', 'python', 'ruby', 'swift' ]
90+
# Use only 'java-kotlin' to analyze code written in Java, Kotlin or both
91+
# Use only 'javascript-typescript' to analyze code written in JavaScript, TypeScript or both
92+
# Learn more about CodeQL language support at https://aka.ms/codeql-docs/language-support
93+
env:
94+
# Required for actions/setup-dotnet@v3 on self-hosted runners where runners don't have sudo permissions
95+
DOTNET_INSTALL_DIR: "./.dotnet"
96+
steps:
97+
- name: Checkout repository
98+
uses: actions/checkout@v4
99+
with:
100+
submodules: 'recursive'
101+
102+
# Initializes the CodeQL tools for scanning.
103+
- name: Initialize CodeQL
104+
uses: github/codeql-action/init@v3
105+
with:
106+
languages: ${{ matrix.language }}
107+
# If you wish to specify custom queries, you can do so here or in a config file.
108+
# By default, queries listed here will override any specified in a config file.
109+
# Prefix the list here with "+" to use these queries and those in the config file.
110+
111+
# For more details on CodeQL's query packs, refer to: https://docs.github.com/en/code-security/code-scanning/automatically-scanning-your-code-for-vulnerabilities-and-errors/configuring-code-scanning#using-queries-in-ql-packs
112+
# queries: security-extended,security-and-quality
113+
114+
115+
# Autobuild attempts to build any compiled languages (C/C++, C#, Go, Java, or Swift).
116+
# If this step fails, then you should remove it and run the build manually (see below)
117+
# - name: Autobuild
118+
# uses: github/codeql-action/autobuild@v3
119+
# Install the .NET Core workload
120+
- name: Install .NET Core
121+
uses: actions/setup-dotnet@v3
122+
with:
123+
dotnet-version: 8.x.x
124+
125+
# Execute the build
126+
- name: Execute Build
127+
working-directory: ./src
128+
run: dotnet build
129+
130+
# ℹ️ Command-line programs to run using the OS shell.
131+
# 📚 See https://docs.github.com/en/actions/using-workflows/workflow-syntax-for-github-actions#jobsjob_idstepsrun
132+
133+
# If the Autobuild fails above, remove it and uncomment the following three lines.
134+
# modify them (or add more) to build your code if your project, please refer to the EXAMPLE below for guidance.
135+
136+
# - run: |
137+
# echo "Run, Build Application using script"
138+
# ./location_of_script_within_repo/buildscript.sh
139+
140+
- name: Perform CodeQL Analysis
141+
uses: github/codeql-action/analyze@v3
142+
with:
143+
category: "/language:${{matrix.language}}"

.gitignore

Lines changed: 72 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,72 @@
1+
*.swp
2+
*.*~
3+
project.lock.json
4+
.DS_Store
5+
*.pyc
6+
nupkg/
7+
8+
# Visual Studio Code
9+
.vscode
10+
11+
# Rider
12+
.idea
13+
14+
# User-specific files
15+
*.suo
16+
*.user
17+
*.userosscache
18+
*.sln.docstates
19+
20+
# Build results
21+
[Dd]ebug/
22+
[Dd]ebugPublic/
23+
[Rr]elease/
24+
[Rr]eleases/
25+
x64/
26+
x86/
27+
build/
28+
bld/
29+
[Bb]in/
30+
[Oo]bj/
31+
[Oo]ut/
32+
msbuild.log
33+
msbuild.err
34+
msbuild.wrn
35+
36+
# Visual Studio 2015
37+
.vs/
38+
39+
# Common IntelliJ Platform excludes
40+
41+
# User specific
42+
**/.idea/**/workspace.xml
43+
**/.idea/**/tasks.xml
44+
**/.idea/shelf/*
45+
**/.idea/dictionaries
46+
**/.idea/httpRequests/
47+
48+
# Sensitive or high-churn files
49+
**/.idea/**/dataSources/
50+
**/.idea/**/dataSources.ids
51+
**/.idea/**/dataSources.xml
52+
**/.idea/**/dataSources.local.xml
53+
**/.idea/**/sqlDataSources.xml
54+
**/.idea/**/dynamic.xml
55+
56+
# Rider
57+
# Rider auto-generates .iml files, and contentModel.xml
58+
**/.idea/**/*.iml
59+
**/.idea/**/contentModel.xml
60+
**/.idea/**/modules.xml
61+
62+
*.suo
63+
*.user
64+
.vs/
65+
[Bb]in/
66+
[Oo]bj/
67+
_UpgradeReport_Files/
68+
[Pp]ackages/
69+
70+
Thumbs.db
71+
Desktop.ini
72+
.DS_Store

.gitmodules

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
[submodule "src/nullinside-api"]
2+
path = src/nullinside-api
3+
url = https://github.com/nullinside-development-group/nullinside-api.git

Dockerfile

Lines changed: 59 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,59 @@
1+
FROM mcr.microsoft.com/dotnet/aspnet:8.0 AS base
2+
USER $APP_UID
3+
WORKDIR /app
4+
5+
FROM mcr.microsoft.com/dotnet/sdk:8.0 AS build
6+
ARG BUILD_CONFIGURATION=Release
7+
ARG TAG_VERSION
8+
WORKDIR /src
9+
COPY ["src/[ApplicationNameUpperCamelCase]/[ApplicationNameUpperCamelCase].csproj", "src/[ApplicationNameUpperCamelCase]/"]
10+
RUN dotnet restore "src/[ApplicationNameUpperCamelCase]/[ApplicationNameUpperCamelCase].csproj"
11+
COPY src/ .
12+
WORKDIR "/src/[ApplicationNameUpperCamelCase]"
13+
RUN dotnet build "[ApplicationNameUpperCamelCase].csproj" -p:Version="$TAG_VERSION" -c $BUILD_CONFIGURATION -o /app/build
14+
15+
FROM build AS publish
16+
ARG BUILD_CONFIGURATION=Release
17+
ARG TAG_VERSION
18+
ARG GITHUB_TOKEN
19+
ARG DESCRIPTION
20+
RUN apt-get update && apt-get dist-upgrade -y && apt-get install zip jq -y
21+
22+
# Generate the executables
23+
RUN dotnet publish "[ApplicationNameUpperCamelCase].csproj" -p:Version="$TAG_VERSION" -c $BUILD_CONFIGURATION -o /app/publish/win-x64 -r win-x64
24+
RUN dotnet publish "[ApplicationNameUpperCamelCase].csproj" -p:Version="$TAG_VERSION" -c $BUILD_CONFIGURATION -o /app/publish/win-x86 -r win-x86
25+
RUN cd /app/publish/win-x64 && zip -r ../windows-x64.zip *
26+
RUN cd /app/publish/win-x86 && zip -r ../windows-x86.zip *
27+
28+
# Create a tag and associate it with a release in GitHub. We don't need to check if it already exist, if it already
29+
# exists the command won't do anything.
30+
RUN curl -L \
31+
-X POST \
32+
-H "Accept: application/vnd.github+json" \
33+
-H "Authorization: Bearer $GITHUB_TOKEN" \
34+
https://api.github.com/repos/[GitOwnerAndRepoName]/releases \
35+
-d '{"tag_name":"'$TAG_VERSION'","target_commitish":"main","name":"'$TAG_VERSION'","body":"'$DESCRIPTION'","draft":false,"prerelease":false,"generate_release_notes":false}'
36+
37+
# Upload the files to the release. We need to get the ID for the release we created first and then upload the zips.
38+
# This needs to be done in a single run command to provide the $RELEASE_ID to the rest of the commands. We don't need to
39+
# check if it already exist, if it already exists the command won't do anything.
40+
RUN export RELEASE_ID=$(curl -L \
41+
-H "Accept: application/vnd.github+json" \
42+
-H "Authorization: Bearer $GITHUB_TOKEN" \
43+
"https://api.github.com/repos/[GitOwnerAndRepoName]/releases/latest" \
44+
| jq .id) && \
45+
echo "Release ID: "$RELEASE_ID && \
46+
curl -L \
47+
-X POST \
48+
-H "Accept: application/vnd.github+json" \
49+
-H "Authorization: Bearer $GITHUB_TOKEN" \
50+
-H "Content-Type: application/octet-stream" \
51+
"https://uploads.github.com/repos/[GitOwnerAndRepoName]/releases/$RELEASE_ID/assets?name=windows-x64.zip" \
52+
--data-binary "@/app/publish/windows-x64.zip" && \
53+
curl -L \
54+
-X POST \
55+
-H "Accept: application/vnd.github+json" \
56+
-H "Authorization: Bearer $GITHUB_TOKEN" \
57+
-H "Content-Type: application/octet-stream" \
58+
"https://uploads.github.com/repos/[GitOwnerAndRepoName]/releases/$RELEASE_ID/assets?name=windows-x86.zip" \
59+
--data-binary "@/app/publish/windows-x86.zip"

Jenkinsfile

Lines changed: 32 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,32 @@
1+
pipeline {
2+
agent any
3+
options {
4+
ansiColor('xterm')
5+
}
6+
7+
stages {
8+
stage('Checkout') {
9+
steps {
10+
git branch: env.BRANCH_NAME, credentialsId: 'GitHub PAT', url: 'https://github.com/[GitOwnerAndRepoName].git'
11+
}
12+
}
13+
14+
stage('Build & Deploy') {
15+
steps {
16+
withCredentials([
17+
string(credentialsId: 'GITHUB_NULLINSIDE_ORG_RELEASE_TOKEN', variable: 'GITHUB_NULLINSIDE_ORG_RELEASE_TOKEN')
18+
]) {
19+
sh """
20+
bash go.sh
21+
"""
22+
}
23+
}
24+
}
25+
}
26+
27+
post {
28+
always {
29+
cleanWs cleanWhenFailure: false, notFailBuild: true
30+
}
31+
}
32+
}

README.md

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,13 @@
1+
# nullinside-template-desktop-gui
2+
3+
This is a template for creating desktop applications for C# using Avalonia.
4+
5+
## Setup
6+
7+
1. When creating a new git repo you can select the `nullinside-template-desktop-gui` project as your template.
8+
2. Perform a rename through the application files for the following:
9+
1. `[ApplicationNameUpperCamelCase]`: The desired name of the application in UpperCamelCase format.
10+
2. `[GitOwnerAndRepoName]`: The github owner and repo combination name. (Ex: `nullinside-development-group/nullinside-site-monitor`)
11+
3. Update the namespaces in the application using an IDE.
12+
4. Update the name of the documentation file in the project settings under Debug and Release
13+
5. Update the git repo location in the new version dialog's view model: https://github.com/nullinside-development-group/nullinside-template-desktop-gui/blob/main/src/%5BApplicationNameUpperCamelCase%5D/ViewModels/NewVersionWindowViewModel.cs#L44

go.sh

Lines changed: 25 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,25 @@
1+
#!/usr/bin/env bash
2+
# If there is already a version number don't make a new one.
3+
export TAG_VERSION=$(git tag --points-at HEAD)
4+
if [[ -z "$TAG_VERSION" ]]; then
5+
# Get the latest version for the repo
6+
export CURRENT_VERSION=$(curl "https://api.github.com/repos/[GitOwnerAndRepoName]/tags" | jq -r '.[0].name')
7+
major=1
8+
minor=0
9+
build=-1
10+
11+
# Break down the version number into it's components
12+
regex="([0-9]+).([0-9]+).([0-9]+)"
13+
if [[ $CURRENT_VERSION =~ $regex ]]; then
14+
major="${BASH_REMATCH[1]}"
15+
minor="${BASH_REMATCH[2]}"
16+
build="${BASH_REMATCH[3]}"
17+
fi
18+
19+
# Increment the build always
20+
build=$(echo $build+1 | bc)
21+
export TAG_VERSION=${major}.${minor}.${build}
22+
fi
23+
24+
docker system prune -af
25+
docker build --build-arg="TAG_VERSION="$TAG_VERSION --build-arg="GITHUB_TOKEN="$GITHUB_NULLINSIDE_ORG_RELEASE_TOKEN --progress=plain --no-cache .
Lines changed: 31 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,31 @@
1+
2+
Microsoft Visual Studio Solution File, Format Version 12.00
3+
Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "SolutionFolder", "SolutionFolder", "{9894F6E0-42A7-4A9D-96F8-8ECB2221230A}"
4+
ProjectSection(SolutionItems) = preProject
5+
..\.gitignore = ..\.gitignore
6+
..\README.md = ..\README.md
7+
..\Dockerfile = ..\Dockerfile
8+
..\go.sh = ..\go.sh
9+
..\Jenkinsfile = ..\Jenkinsfile
10+
EndProjectSection
11+
EndProject
12+
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Nullinside.Api.Common", "nullinside-api\src\Nullinside.Api.Common\Nullinside.Api.Common.csproj", "{D9EF6294-DF13-4901-B7EF-2DBC50B9E4E1}"
13+
EndProject
14+
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "[ApplicationNameUpperCamelCase]", "[ApplicationNameUpperCamelCase]\[ApplicationNameUpperCamelCase].csproj", "{D16A0A78-91C3-4098-AF67-2AD287522274}"
15+
EndProject
16+
Global
17+
GlobalSection(SolutionConfigurationPlatforms) = preSolution
18+
Debug|Any CPU = Debug|Any CPU
19+
Release|Any CPU = Release|Any CPU
20+
EndGlobalSection
21+
GlobalSection(ProjectConfigurationPlatforms) = postSolution
22+
{D9EF6294-DF13-4901-B7EF-2DBC50B9E4E1}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
23+
{D9EF6294-DF13-4901-B7EF-2DBC50B9E4E1}.Debug|Any CPU.Build.0 = Debug|Any CPU
24+
{D9EF6294-DF13-4901-B7EF-2DBC50B9E4E1}.Release|Any CPU.ActiveCfg = Release|Any CPU
25+
{D9EF6294-DF13-4901-B7EF-2DBC50B9E4E1}.Release|Any CPU.Build.0 = Release|Any CPU
26+
{D16A0A78-91C3-4098-AF67-2AD287522274}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
27+
{D16A0A78-91C3-4098-AF67-2AD287522274}.Debug|Any CPU.Build.0 = Debug|Any CPU
28+
{D16A0A78-91C3-4098-AF67-2AD287522274}.Release|Any CPU.ActiveCfg = Release|Any CPU
29+
{D16A0A78-91C3-4098-AF67-2AD287522274}.Release|Any CPU.Build.0 = Release|Any CPU
30+
EndGlobalSection
31+
EndGlobal

0 commit comments

Comments
 (0)