Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
478 changes: 478 additions & 0 deletions .editorconfig

Large diffs are not rendered by default.

9 changes: 9 additions & 0 deletions .gitattributes
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
# Set the default behavior, in case people don't have core.autocrlf set.
* text=auto

# Explicitly declare text files you want to always be normalized and converted
# to native line endings on checkout.
*.cs text

# Declare files that will always have CRLF line endings on checkout.
*.sln text eol=crlf
135 changes: 135 additions & 0 deletions .github/workflows/nuget-publish.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,135 @@
name: Build and Publish NuGet Packages

on:
push:
branches: [ main, master ]
tags: [ 'v*' ]
pull_request:
branches: [ main, master ]

env:
DOTNET_VERSION: '9.0.x'
NUGET_SOURCE: 'https://api.nuget.org/v3/index.json'

jobs:
build-and-test:
runs-on: ubuntu-latest

steps:
- name: Checkout code
uses: actions/checkout@v4
with:
fetch-depth: 0 # Required for GitVersion

- name: Setup .NET
uses: actions/setup-dotnet@v4
with:
dotnet-version: ${{ env.DOTNET_VERSION }}

- name: Install GitVersion
uses: gittools/actions/gitversion/setup@v0.10.2
with:
versionSpec: '5.x'

- name: Determine Version
uses: gittools/actions/gitversion/execute@v0.10.2
id: gitversion

- name: Display Version
run: |
echo "Version: ${{ steps.gitversion.outputs.semVer }}"
echo "NuGetVersionV2: ${{ steps.gitversion.outputs.nuGetVersionV2 }}"

- name: Restore dependencies for core projects
run: |
dotnet restore EightBot.Orbit.Core/EightBot.Orbit.Core.csproj
dotnet restore EightBot.Orbit.Client/EightBot.Orbit.Client.csproj
dotnet restore EightBot.Orbit.Server/EightBot.Orbit.Server.csproj
dotnet restore EightBot.Orbit.Server.Web/EightBot.Orbit.Server.Web.csproj
dotnet restore EightBot.Orbit.Tests/EightBot.Orbit.Tests.csproj

- name: Build core projects
run: |
dotnet build EightBot.Orbit.Core/EightBot.Orbit.Core.csproj --configuration Release --no-restore /p:Version=${{ steps.gitversion.outputs.assemblySemVer }} /p:PackageVersion=${{ steps.gitversion.outputs.nuGetVersionV2 }}
dotnet build EightBot.Orbit.Client/EightBot.Orbit.Client.csproj --configuration Release --no-restore /p:Version=${{ steps.gitversion.outputs.assemblySemVer }} /p:PackageVersion=${{ steps.gitversion.outputs.nuGetVersionV2 }}
dotnet build EightBot.Orbit.Server/EightBot.Orbit.Server.csproj --configuration Release --no-restore /p:Version=${{ steps.gitversion.outputs.assemblySemVer }} /p:PackageVersion=${{ steps.gitversion.outputs.nuGetVersionV2 }}
dotnet build EightBot.Orbit.Server.Web/EightBot.Orbit.Server.Web.csproj --configuration Release --no-restore /p:Version=${{ steps.gitversion.outputs.assemblySemVer }} /p:PackageVersion=${{ steps.gitversion.outputs.nuGetVersionV2 }}
dotnet build EightBot.Orbit.Tests/EightBot.Orbit.Tests.csproj --configuration Release --no-restore

- name: Run tests
continue-on-error: true
run: dotnet test EightBot.Orbit.Tests/EightBot.Orbit.Tests.csproj --configuration Release --no-build --verbosity normal --filter "FullyQualifiedName~OrbitClientTests"

- name: Pack NuGet packages
run: |
dotnet pack EightBot.Orbit.Core/EightBot.Orbit.Core.csproj --configuration Release --no-build --output ./artifacts /p:PackageVersion=${{ steps.gitversion.outputs.nuGetVersionV2 }}
dotnet pack EightBot.Orbit.Client/EightBot.Orbit.Client.csproj --configuration Release --no-build --output ./artifacts /p:PackageVersion=${{ steps.gitversion.outputs.nuGetVersionV2 }}
dotnet pack EightBot.Orbit.Server/EightBot.Orbit.Server.csproj --configuration Release --no-build --output ./artifacts /p:PackageVersion=${{ steps.gitversion.outputs.nuGetVersionV2 }}
dotnet pack EightBot.Orbit.Server.Web/EightBot.Orbit.Server.Web.csproj --configuration Release --no-build --output ./artifacts /p:PackageVersion=${{ steps.gitversion.outputs.nuGetVersionV2 }}

- name: Upload NuGet packages as artifacts
uses: actions/upload-artifact@v4
with:
name: nuget-packages
path: ./artifacts/*.nupkg

outputs:
version: ${{ steps.gitversion.outputs.nuGetVersionV2 }}

publish:
needs: build-and-test
runs-on: ubuntu-latest
if: github.event_name == 'push' && (github.ref == 'refs/heads/main' || github.ref == 'refs/heads/master' || startsWith(github.ref, 'refs/tags/'))

steps:
- name: Download NuGet packages
uses: actions/download-artifact@v4
with:
name: nuget-packages
path: ./artifacts

- name: Setup .NET
uses: actions/setup-dotnet@v4
with:
dotnet-version: ${{ env.DOTNET_VERSION }}

- name: Publish to NuGet (Release)
if: startsWith(github.ref, 'refs/tags/')
run: |
for package in ./artifacts/*.nupkg; do
echo "Publishing $package to NuGet..."
dotnet nuget push "$package" --api-key ${{ secrets.EIGHTBOT_NUGET_APIKEY }} --source ${{ env.NUGET_SOURCE }} --skip-duplicate
done

- name: Publish to NuGet (Prerelease)
if: github.ref == 'refs/heads/main' || github.ref == 'refs/heads/master'
run: |
for package in ./artifacts/*.nupkg; do
echo "Publishing $package to NuGet as prerelease..."
dotnet nuget push "$package" --api-key ${{ secrets.EIGHTBOT_NUGET_APIKEY }} --source ${{ env.NUGET_SOURCE }} --skip-duplicate
done

create-release:
needs: [build-and-test, publish]
runs-on: ubuntu-latest
if: startsWith(github.ref, 'refs/tags/')

steps:
- name: Checkout code
uses: actions/checkout@v4

- name: Download NuGet packages
uses: actions/download-artifact@v4
with:
name: nuget-packages
path: ./artifacts

- name: Create GitHub Release
uses: softprops/action-gh-release@v1
with:
files: ./artifacts/*.nupkg
generate_release_notes: true
draft: false
prerelease: false
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
Loading