Adds gitversioning for releases (#209)

This commit is contained in:
Kamron Batman 2020-09-02 17:50:57 -07:00 committed by GitHub
parent 584d4bc1d9
commit 192cf70d20
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
9 changed files with 82 additions and 58 deletions

View file

@ -10,25 +10,21 @@ jobs:
if: "contains(github.event.head_commit.message, 'Release')" if: "contains(github.event.head_commit.message, 'Release')"
runs-on: ubuntu-latest runs-on: ubuntu-latest
steps: steps:
- uses: actions/checkout@v2 - uses: actions/checkout@
with:
fetch-depth: 0 # avoid shallow clone so nbgv can do its work.
- name: Setup .NET Core - name: Setup .NET Core
uses: actions/setup-dotnet@v1 uses: actions/setup-dotnet@v1
with: with:
dotnet-version: 3.1.401 dotnet-version: 3.1.401
- name: Get Project Version - uses: dotnet/nbgv@master
id: get-version id: nbgv
uses: mavrosxristoforos/get-xml-info@1.0
with:
xml-file: 'Directory.Build.props'
xpath: '/Project/PropertyGroup/Version'
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
- name: Create Release - name: Create Release
id: create_release id: create_release
uses: actions/create-release@v1 uses: actions/create-release@v1
with: with:
tag_name: ${{ steps.get-version.output.info }} tag_name: ${{ steps.nbgv.outputs.Version }}
release_name: ${{ steps.get-version.output.info }} release_name: ${{ steps.nbgv.outputs.Version }}
draft: false draft: false
prerelease: false prerelease: false
env: env:
@ -36,30 +32,30 @@ jobs:
- name: Build Windows - name: Build Windows
run: ./publish.cmd win core Release run: ./publish.cmd win core Release
- name: Create Windows Artifact - name: Create Windows Artifact
run: rm -rf ./Projects/*/bin && rm -rf ./Projects/*/obj && zip -r modernuo-win-x64-${{ steps.get-version.output.info }}.zip ./* run: rm -rf ./Projects/*/bin && rm -rf ./Projects/*/obj && zip -r modernuo-win-x64-${{ steps.nbgv.outputs.Version }}.zip ./*
- name: Upload Windows Build - name: Upload Windows Build
uses: actions/upload-release-asset@v1 uses: actions/upload-release-asset@v1
with: with:
upload_url: ${{ steps.create_release.outputs.upload_url }} upload_url: ${{ steps.create_release.outputs.upload_url }}
asset_path: ./modernuo-win-x64-${{ steps.get-version.output.info }}.zip asset_path: ./modernuo-win-x64-${{ steps.nbgv.outputs.Version }}.zip
asset_name: modernuo-win-x64-${{ steps.get-version.output.info }}.zip asset_name: modernuo-win-x64-${{ steps.nbgv.outputs.Version }}.zip
asset_content_type: application/zip asset_content_type: application/zip
env: env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
- name: Clean Windows Build - name: Clean Windows Build
run: rm modernuo-win-x64-${{ steps.get-version.output.info }}.zip run: rm modernuo-win-x64-${{ steps.nbgv.outputs.Version }}.zip
- name: Build Ubuntu 18 LTS - name: Build Ubuntu 18 LTS
run: ./publish.cmd ubuntu.18.04 core Release run: ./publish.cmd ubuntu.18.04 core Release
- name: Create Ubuntu 18 LTS Artifact - name: Create Ubuntu 18 LTS Artifact
run: rm -rf ./Projects/*/bin && rm -rf ./Projects/*/obj && zip -r ubuntu.18.04-x64-${{ steps.get-version.output.info }}.zip ./* run: rm -rf ./Projects/*/bin && rm -rf ./Projects/*/obj && zip -r ubuntu.18.04-x64-${{ steps.nbgv.outputs.Version }}.zip ./*
- name: Upload Ubuntu 18 LTS Build - name: Upload Ubuntu 18 LTS Build
uses: actions/upload-release-asset@v1 uses: actions/upload-release-asset@v1
with: with:
upload_url: ${{ steps.create_release.outputs.upload_url }} upload_url: ${{ steps.create_release.outputs.upload_url }}
asset_path: ./modernuo-ubuntu.18.04-x64-${{ steps.get-version.output.info }}.zip asset_path: ./modernuo-ubuntu.18.04-x64-${{ steps.nbgv.outputs.Version }}.zip
asset_name: modernuo-ubuntu.18.04-x64-${{ steps.get-version.output.info }}.zip asset_name: modernuo-ubuntu.18.04-x64-${{ steps.nbgv.outputs.Version }}.zip
asset_content_type: application/zip asset_content_type: application/zip
env: env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
- name: Clean Ubuntu 18 LTS Build - name: Clean Ubuntu 18 LTS Build
run: rm modernuo-ubuntu.18.04-x64-${{ steps.get-version.output.info }}.zip run: rm modernuo-ubuntu.18.04-x64-${{ steps.nbgv.outputs.Version }}.zip

View file

@ -1,31 +1,33 @@
name: Build name: Build
on: on:
push: push:
branches: [ master ] branches: [ master ]
pull_request: pull_request:
branches: [ master ] branches: [ master ]
jobs: jobs:
build: build:
runs-on: ${{ matrix.os }} runs-on: ${{ matrix.os }}
strategy: strategy:
fail-fast: false fail-fast: false
matrix: matrix:
include: include:
- os: macos-latest - os: macos-latest
steps: steps:
- uses: actions/checkout@v2 - uses: actions/checkout@v2
- name: Setup .NET Core with:
uses: actions/setup-dotnet@v1 fetch-depth: 0 # avoid shallow clone so nbgv can do its work.
with: - name: Setup .NET Core
dotnet-version: 3.1.401 uses: actions/setup-dotnet@v1
- name: Restore NuGet Packages with:
run: dotnet restore --force-evaluate dotnet-version: 3.1.401
- name: Build Server - name: Restore NuGet Packages
run: dotnet build -c Release -f netcoreapp3.1 --no-restore Projects/Server/Server.csproj run: dotnet restore --force-evaluate
- name: Build UO Content - name: Build Server
run: dotnet build -c Release -f netcoreapp3.1 --no-restore Projects/UOContent/UOContent.csproj run: dotnet build -c Release -f netcoreapp3.1 --no-restore Projects/Server/Server.csproj
- name: Test - name: Build UO Content
run: dotnet test --no-restore -f netcoreapp3.1 run: dotnet build -c Release -f netcoreapp3.1 --no-restore Projects/UOContent/UOContent.csproj
- name: Test
run: dotnet test --no-restore -f netcoreapp3.1

View file

@ -7,8 +7,8 @@
<TargetFramework>netcoreapp3.1</TargetFramework> <TargetFramework>netcoreapp3.1</TargetFramework>
<Platforms>x64</Platforms> <Platforms>x64</Platforms>
<PlatformTarget>x64</PlatformTarget> <PlatformTarget>x64</PlatformTarget>
<Version>0.6.1</Version>
<LangVersion>8.0</LangVersion> <LangVersion>8.0</LangVersion>
<PublicRelease>true</PublicRelease>
<DefineConstants Condition="$(RuntimeIdentifier.StartsWith('win'))">WINDOWS</DefineConstants> <DefineConstants Condition="$(RuntimeIdentifier.StartsWith('win'))">WINDOWS</DefineConstants>
<DefineConstants Condition="$(RuntimeIdentifier.StartsWith(`win`)) != true">UNIX</DefineConstants> <DefineConstants Condition="$(RuntimeIdentifier.StartsWith(`win`)) != true">UNIX</DefineConstants>
<AutoGenerateBindingRedirects>true</AutoGenerateBindingRedirects> <AutoGenerateBindingRedirects>true</AutoGenerateBindingRedirects>

View file

@ -119,7 +119,11 @@ namespace Server
public static Assembly Assembly { get; set; } public static Assembly Assembly { get; set; }
public static Version Version => Assembly.GetName().Version; // Assembly file version
public static Version Version => Version.Parse(
FileVersionInfo.GetVersionInfo(Assembly.Location).FileVersion
);
public static Process Process { get; private set; } public static Process Process { get; private set; }
public static Thread Thread { get; private set; } public static Thread Thread { get; private set; }
@ -354,16 +358,14 @@ namespace Server
if (BaseDirectory.Length > 0) if (BaseDirectory.Length > 0)
Directory.SetCurrentDirectory(BaseDirectory); Directory.SetCurrentDirectory(BaseDirectory);
var ver = Assembly.GetName().Version ?? new Version();
Utility.PushColor(ConsoleColor.Green); Utility.PushColor(ConsoleColor.Green);
// Added to help future code support on forums, as a 'check' people can ask for to it see if they recompiled core or not // Added to help future code support on forums, as a 'check' people can ask for to it see if they recompiled core or not
Console.WriteLine( Console.WriteLine(
"ModernUO - [https://github.com/modernuo/modernuo] Version {0}.{1}.{2}.{3}", "ModernUO - [https://github.com/modernuo/modernuo] Version {0}.{1}.{2}.{3}",
ver.Major, Version.Major,
ver.Minor, Version.Minor,
ver.Build, Version.Build,
ver.Revision Version.Revision
); );
Console.WriteLine("Core: Running on {0}\n", RuntimeInformation.FrameworkDescription); Console.WriteLine("Core: Running on {0}\n", RuntimeInformation.FrameworkDescription);
Utility.PopColor(); Utility.PopColor();

View file

@ -61,6 +61,10 @@
<PackageReference Include="Microsoft.AspNetCore.Connections.Abstractions" Version="3.1.5" /> <PackageReference Include="Microsoft.AspNetCore.Connections.Abstractions" Version="3.1.5" />
<PackageReference Include="Microsoft.AspNetCore.Server.Kestrel.Transport.Libuv" Version="3.1.5" /> <PackageReference Include="Microsoft.AspNetCore.Server.Kestrel.Transport.Libuv" Version="3.1.5" />
<PackageReference Include="Microsoft.Extensions.Hosting.Abstractions" Version="3.1.5" /> <PackageReference Include="Microsoft.Extensions.Hosting.Abstractions" Version="3.1.5" />
<PackageReference Include="Nerdbank.GitVersioning" Version="3.2.31">
<PrivateAssets>all</PrivateAssets>
<IncludeAssets>runtime; build; native; contentfiles; analyzers; buildtransitive</IncludeAssets>
</PackageReference>
<PackageReference Include="System.IO.Pipelines" Version="4.7.2" /> <PackageReference Include="System.IO.Pipelines" Version="4.7.2" />
<PackageReference Include="Zlib.Bindings" Version="1.2.0" /> <PackageReference Include="Zlib.Bindings" Version="1.2.0" />
</ItemGroup> </ItemGroup>

View file

@ -36,6 +36,12 @@
"Microsoft.Extensions.Logging.Abstractions": "3.1.5" "Microsoft.Extensions.Logging.Abstractions": "3.1.5"
} }
}, },
"Nerdbank.GitVersioning": {
"type": "Direct",
"requested": "[3.2.31, )",
"resolved": "3.2.31",
"contentHash": "19grBnpqHLxViOt1cwE+cI+brQ2swdm4gfM97P+9KbbgWGfXtdy4EmpVAkUZ3MgntFYYbUvfldM4pUOmks5q0w=="
},
"System.IO.Pipelines": { "System.IO.Pipelines": {
"type": "Direct", "type": "Direct",
"requested": "[4.7.2, )", "requested": "[4.7.2, )",

View file

@ -58,6 +58,10 @@
<PackageReference Include="Microsoft.Extensions.Logging.Abstractions" Version="3.1.5" /> <PackageReference Include="Microsoft.Extensions.Logging.Abstractions" Version="3.1.5" />
<!-- Direct packages --> <!-- Direct packages -->
<PackageReference Include="MailKit" Version="2.8.0" /> <PackageReference Include="MailKit" Version="2.8.0" />
<PackageReference Include="Nerdbank.GitVersioning" Version="3.2.31">
<PrivateAssets>all</PrivateAssets>
<IncludeAssets>runtime; build; native; contentfiles; analyzers; buildtransitive</IncludeAssets>
</PackageReference>
<PackageReference Include="Zlib.Bindings" Version="1.2.0" /> <PackageReference Include="Zlib.Bindings" Version="1.2.0" />
<PackageReference Include="Argon2.Bindings" Version="1.6.0" /> <PackageReference Include="Argon2.Bindings" Version="1.6.0" />
</ItemGroup> </ItemGroup>

View file

@ -54,6 +54,12 @@
"resolved": "3.1.5", "resolved": "3.1.5",
"contentHash": "ZvwowjRSWXewdPI+whPFXgwF4Qme6Q9KV9SCPEITSGiqHLArct7q5hTBtTzj3GPsVLjTqehvTg6Bd/EQk9JS0A==" "contentHash": "ZvwowjRSWXewdPI+whPFXgwF4Qme6Q9KV9SCPEITSGiqHLArct7q5hTBtTzj3GPsVLjTqehvTg6Bd/EQk9JS0A=="
}, },
"Nerdbank.GitVersioning": {
"type": "Direct",
"requested": "[3.2.31, )",
"resolved": "3.2.31",
"contentHash": "19grBnpqHLxViOt1cwE+cI+brQ2swdm4gfM97P+9KbbgWGfXtdy4EmpVAkUZ3MgntFYYbUvfldM4pUOmks5q0w=="
},
"Zlib.Bindings": { "Zlib.Bindings": {
"type": "Direct", "type": "Direct",
"requested": "[1.2.0, )", "requested": "[1.2.0, )",

4
version.json Normal file
View file

@ -0,0 +1,4 @@
{
"$schema": "https://raw.githubusercontent.com/dotnet/Nerdbank.GitVersioning/master/src/NerdBank.GitVersioning/version.schema.json",
"version": "0.6.1"
}