From 192cf70d209e78446c7a2d35c4db549bef7db3ae Mon Sep 17 00:00:00 2001
From: Kamron Batman <3953314+kamronbatman@users.noreply.github.com>
Date: Wed, 2 Sep 2020 17:50:57 -0700
Subject: [PATCH] Adds gitversioning for releases (#209)
---
.github/workflows/create-release.yml | 34 +++++++-------
.github/workflows/dotnet-core.yml | 64 ++++++++++++++-------------
Directory.Build.props | 2 +-
Projects/Server/Main.cs | 16 ++++---
Projects/Server/Server.csproj | 4 ++
Projects/Server/packages.lock.json | 6 +++
Projects/UOContent/UOContent.csproj | 4 ++
Projects/UOContent/packages.lock.json | 6 +++
version.json | 4 ++
9 files changed, 82 insertions(+), 58 deletions(-)
create mode 100644 version.json
diff --git a/.github/workflows/create-release.yml b/.github/workflows/create-release.yml
index 26937f434..2c088042b 100644
--- a/.github/workflows/create-release.yml
+++ b/.github/workflows/create-release.yml
@@ -10,25 +10,21 @@ jobs:
if: "contains(github.event.head_commit.message, 'Release')"
runs-on: ubuntu-latest
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
uses: actions/setup-dotnet@v1
with:
dotnet-version: 3.1.401
- - name: Get Project Version
- id: get-version
- uses: mavrosxristoforos/get-xml-info@1.0
- with:
- xml-file: 'Directory.Build.props'
- xpath: '/Project/PropertyGroup/Version'
- env:
- GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
+ - uses: dotnet/nbgv@master
+ id: nbgv
- name: Create Release
id: create_release
uses: actions/create-release@v1
with:
- tag_name: ${{ steps.get-version.output.info }}
- release_name: ${{ steps.get-version.output.info }}
+ tag_name: ${{ steps.nbgv.outputs.Version }}
+ release_name: ${{ steps.nbgv.outputs.Version }}
draft: false
prerelease: false
env:
@@ -36,30 +32,30 @@ jobs:
- name: Build Windows
run: ./publish.cmd win core Release
- 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
uses: actions/upload-release-asset@v1
with:
upload_url: ${{ steps.create_release.outputs.upload_url }}
- asset_path: ./modernuo-win-x64-${{ steps.get-version.output.info }}.zip
- asset_name: 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.nbgv.outputs.Version }}.zip
asset_content_type: application/zip
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
- 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
run: ./publish.cmd ubuntu.18.04 core Release
- 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
uses: actions/upload-release-asset@v1
with:
upload_url: ${{ steps.create_release.outputs.upload_url }}
- asset_path: ./modernuo-ubuntu.18.04-x64-${{ steps.get-version.output.info }}.zip
- asset_name: 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.nbgv.outputs.Version }}.zip
asset_content_type: application/zip
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
- 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
diff --git a/.github/workflows/dotnet-core.yml b/.github/workflows/dotnet-core.yml
index de6d0c6bf..884b4f6e1 100644
--- a/.github/workflows/dotnet-core.yml
+++ b/.github/workflows/dotnet-core.yml
@@ -1,31 +1,33 @@
-name: Build
-
-on:
- push:
- branches: [ master ]
- pull_request:
- branches: [ master ]
-
-jobs:
- build:
- runs-on: ${{ matrix.os }}
- strategy:
- fail-fast: false
- matrix:
- include:
- - os: macos-latest
-
- steps:
- - uses: actions/checkout@v2
- - name: Setup .NET Core
- uses: actions/setup-dotnet@v1
- with:
- dotnet-version: 3.1.401
- - name: Restore NuGet Packages
- run: dotnet restore --force-evaluate
- - name: Build Server
- run: dotnet build -c Release -f netcoreapp3.1 --no-restore Projects/Server/Server.csproj
- - name: Build UO Content
- run: dotnet build -c Release -f netcoreapp3.1 --no-restore Projects/UOContent/UOContent.csproj
- - name: Test
- run: dotnet test --no-restore -f netcoreapp3.1
+name: Build
+
+on:
+ push:
+ branches: [ master ]
+ pull_request:
+ branches: [ master ]
+
+jobs:
+ build:
+ runs-on: ${{ matrix.os }}
+ strategy:
+ fail-fast: false
+ matrix:
+ include:
+ - os: macos-latest
+
+ steps:
+ - uses: actions/checkout@v2
+ with:
+ fetch-depth: 0 # avoid shallow clone so nbgv can do its work.
+ - name: Setup .NET Core
+ uses: actions/setup-dotnet@v1
+ with:
+ dotnet-version: 3.1.401
+ - name: Restore NuGet Packages
+ run: dotnet restore --force-evaluate
+ - name: Build Server
+ run: dotnet build -c Release -f netcoreapp3.1 --no-restore Projects/Server/Server.csproj
+ - name: Build UO Content
+ run: dotnet build -c Release -f netcoreapp3.1 --no-restore Projects/UOContent/UOContent.csproj
+ - name: Test
+ run: dotnet test --no-restore -f netcoreapp3.1
diff --git a/Directory.Build.props b/Directory.Build.props
index 6b16574f9..8b0d592c8 100644
--- a/Directory.Build.props
+++ b/Directory.Build.props
@@ -7,8 +7,8 @@
netcoreapp3.1
x64
x64
- 0.6.1
8.0
+ true
WINDOWS
UNIX
true
diff --git a/Projects/Server/Main.cs b/Projects/Server/Main.cs
index 866f44a25..6fbaff18b 100644
--- a/Projects/Server/Main.cs
+++ b/Projects/Server/Main.cs
@@ -119,7 +119,11 @@ namespace Server
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 Thread Thread { get; private set; }
@@ -354,16 +358,14 @@ namespace Server
if (BaseDirectory.Length > 0)
Directory.SetCurrentDirectory(BaseDirectory);
- var ver = Assembly.GetName().Version ?? new Version();
-
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
Console.WriteLine(
"ModernUO - [https://github.com/modernuo/modernuo] Version {0}.{1}.{2}.{3}",
- ver.Major,
- ver.Minor,
- ver.Build,
- ver.Revision
+ Version.Major,
+ Version.Minor,
+ Version.Build,
+ Version.Revision
);
Console.WriteLine("Core: Running on {0}\n", RuntimeInformation.FrameworkDescription);
Utility.PopColor();
diff --git a/Projects/Server/Server.csproj b/Projects/Server/Server.csproj
index 622d89ee2..c9b5f06cd 100644
--- a/Projects/Server/Server.csproj
+++ b/Projects/Server/Server.csproj
@@ -61,6 +61,10 @@
+
+ all
+ runtime; build; native; contentfiles; analyzers; buildtransitive
+
diff --git a/Projects/Server/packages.lock.json b/Projects/Server/packages.lock.json
index f05c3ec35..9c5510573 100644
--- a/Projects/Server/packages.lock.json
+++ b/Projects/Server/packages.lock.json
@@ -36,6 +36,12 @@
"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": {
"type": "Direct",
"requested": "[4.7.2, )",
diff --git a/Projects/UOContent/UOContent.csproj b/Projects/UOContent/UOContent.csproj
index b3a466db0..d1f2ee69d 100644
--- a/Projects/UOContent/UOContent.csproj
+++ b/Projects/UOContent/UOContent.csproj
@@ -58,6 +58,10 @@
+
+ all
+ runtime; build; native; contentfiles; analyzers; buildtransitive
+
diff --git a/Projects/UOContent/packages.lock.json b/Projects/UOContent/packages.lock.json
index 6182f2980..7680b01f3 100644
--- a/Projects/UOContent/packages.lock.json
+++ b/Projects/UOContent/packages.lock.json
@@ -54,6 +54,12 @@
"resolved": "3.1.5",
"contentHash": "ZvwowjRSWXewdPI+whPFXgwF4Qme6Q9KV9SCPEITSGiqHLArct7q5hTBtTzj3GPsVLjTqehvTg6Bd/EQk9JS0A=="
},
+ "Nerdbank.GitVersioning": {
+ "type": "Direct",
+ "requested": "[3.2.31, )",
+ "resolved": "3.2.31",
+ "contentHash": "19grBnpqHLxViOt1cwE+cI+brQ2swdm4gfM97P+9KbbgWGfXtdy4EmpVAkUZ3MgntFYYbUvfldM4pUOmks5q0w=="
+ },
"Zlib.Bindings": {
"type": "Direct",
"requested": "[1.2.0, )",
diff --git a/version.json b/version.json
new file mode 100644
index 000000000..6399c4071
--- /dev/null
+++ b/version.json
@@ -0,0 +1,4 @@
+{
+ "$schema": "https://raw.githubusercontent.com/dotnet/Nerdbank.GitVersioning/master/src/NerdBank.GitVersioning/version.schema.json",
+ "version": "0.6.1"
+}